﻿/*
global.js
// handles all generic js calls 

*/
function swapImg(p_id, p_imgSrc){
//    alert("bang!");
	if (document.images && document.getElementById){
		var img = document.getElementById(p_id);
		if (img != null){
			img.src = p_imgSrc;
		}
	}
}

function setCookie(value, expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie="e2c65c48-d5f2-455f-8be7-9e1db60d93f2=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
	if (document.cookie.length > 0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start != -1)
		{ 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end == -1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}

function existsCookie()
{
	cartItems = getCookie('e2c65c48-d5f2-455f-8be7-9e1db60d93f2');
	if (cartItems != null && cartItems != "")
	{
		return true;
	}
	else 
	{
		return false;
	}
}




        function getParameter(queryString, parameterName) 
        {   
            // Add "=" to the parameter name (i.e. parameterName=value)   
            var parameterName = parameterName + "=";   
            if ( queryString.length > 0 ) 
            {      
                // Find the beginning of the string      
                begin = queryString.indexOf ( parameterName );      
                // If the parameter name is not found, skip it, otherwise return the value      
                if ( begin != -1 ) 
                {         
                    // Add the length (integer) to the beginning         
                    begin += parameterName.length;         
                    // Multiple parameters are separated by the "&" sign         
                    end = queryString.indexOf ( "&" , begin );      
                    if ( end == -1 ) 
                    {         
                        end = queryString.length      
                    }      
                    // Return the string      
                    return unescape ( queryString.substring ( begin, end ) );   
                }   
                // Return "null" if no parameter has been found   
                return "null";   
            }
        }
