var globalProdName;
function sendEnter(e)
   {
		
		var keyCodePressed
		if (!e) var e = window.event;
		if (e.keyCode) keyCodePressed = e.keyCode;
		else if (e.which) keyCodePressed = e.which;
		
		if(keyCodePressed == 13)
		   getSearchItem();
		 
			
   }
   function getSearchItem()
   {
   	
   	
		//var theGlid = (getQstringValue('gclid') != - 10) ? '&gclid=' + getQstringValue('gclid') : "";
		var replaceTxt = document.getElementById('textfield').value.replace("1. Type Your Search","");
		if(replaceTxt == '' && document.getElementById('search').value =='')
		{
					alert('Please insert text to search');
		}
		else if(replaceTxt != '' && document.getElementById('search').value !='')
		{
			var regSpace =/\s/;
				
				var newPhrase = replaceTxt;// + ' ' + document.getElementById('search').value;
				
						window.location.href='/search/' +  newPhrase.replace(regSpace,'-');	
		}
		else if(replaceTxt != '')
		{
			var regSpace =/\s/;
				
						
						window.location.href='/search/' +  replaceTxt.replace(regSpace,'-');
		}
		else
		{
				var regSpace =/\s/;
				
						
						window.location.href='/search/' +  document.getElementById('search').value.replace(regSpace,'-');
				
		}
   }
function goToPage()
  {
        window.location.href="http://stage01.ecardmountain.com/splash.htm?prodId=" + globalProdName;
  }
 function previewRollOver(objElement,prodId) {
             //alert(objElement);
       globalProdName = prodId;
       var elem = document.getElementById(objElement);
       showPreviewIcon(GetLeft(elem), GetTop(elem));
   }
   
   function showPreviewIcon(x, y) {
       var divPreview = document.getElementById('divPreview');
       divPreview.style.visibility = "visible";
       
       var leftTmp = x - 30;
       leftTmp = leftTmp + 'px';
       divPreview.style.left = leftTmp;
       
       var topTmp = y + 30;
       topTmp = topTmp + 'px';
       divPreview.style.top = topTmp;
   }

   function hidePreviewIcon() {
       var divPreview = document.getElementById('divPreview');
       divPreview.style.visibility = "hidden";
   }
   
   function GetLeft(eElement) {
       if (!eElement && this)                    // if argument is invalid
       {                                         // (not specified, is null or is 0)
           eElement = this;                       // and function is a method
       }                                         // identify the element as the method owner

       var DL_bIE = document.all ? true : false; // initialize var to identify IE

       var nLeftPos = eElement.offsetLeft;       // initialize var to store calculations
       var eParElement = eElement.offsetParent;  // identify first offset parent element

       while (eParElement != null) {                                         // move up through element hierarchy
           if (DL_bIE)                             // if browser is IE, then...
           {
               if (eParElement.tagName == "TD")     // if parent a table cell, then...
               {
                   nLeftPos += eParElement.clientLeft; // append cell border width to calcs
               }
           }
           else                                   // if browser is Gecko, then...
           {
               if (eParElement.tagName == "TABLE")  // if parent is a table, then...
               {                                   // get its border as a number
                   var nParBorder = parseInt(eParElement.border);
                   if (isNaN(nParBorder))            // if no valid border attribute, then...
                   {                                // check the table's frame attribute
                       var nParFrame = eParElement.getAttribute('frame');
                       if (nParFrame != null)         // if frame has ANY value, then...
                       {
                           nLeftPos += 1;             // append one pixel to counter
                       }
                   }
                   else if (nParBorder > 0)          // if a border width is specified, then...
                   {
                       nLeftPos += nParBorder;       // append the border width to counter
                   }
               }
           }

           nLeftPos += eParElement.offsetLeft;    // append left offset of parent
           eParElement = eParElement.offsetParent; // and move up the element hierarchy
       }                                         // until no more offset parents exist
       return nLeftPos;                          // return the number calculated
   }

   function GetTop(eElement) {
       if (!eElement && this)                    // if argument is invalid
       {                                         // (not specified, is null or is 0)
           eElement = this;                       // and function is a method
       }                                         // identify the element as the method owner

       var DL_bIE = document.all ? true : false; // initialize var to identify IE

       var nTopPos = eElement.offsetTop;         // initialize var to store calculations
       var eParElement = eElement.offsetParent;  // identify first offset parent element

       while (eParElement != null) {                                         // move up through element hierarchy
           if (DL_bIE)                             // if browser is IE, then...
           {
               if (eParElement.tagName == "TD")     // if parent a table cell, then...
               {
                   nTopPos += eParElement.clientTop; // append cell border width to calcs
               }
           }
           else                                   // if browser is Gecko, then...
           {
               if (eParElement.tagName == "TABLE")  // if parent is a table, then...
               {                                   // get its border as a number
                   var nParBorder = parseInt(eParElement.border);
                   if (isNaN(nParBorder))            // if no valid border attribute, then...
                   {                                // check the table's frame attribute
                       var nParFrame = eParElement.getAttribute('frame');
                       if (nParFrame != null)         // if frame has ANY value, then...
                       {
                           nTopPos += 1;              // append one pixel to counter
                       }
                   }
                   else if (nParBorder > 0)          // if a border width is specified, then...
                   {
                       nTopPos += nParBorder;        // append the border width to counter
                   }
               }
           }

           nTopPos += eParElement.offsetTop;      // append top offset of parent
           eParElement = eParElement.offsetParent; // and move up the element hierarchy
       }                                         // until no more offset parents exist
       return nTopPos;                           // return the number calculated
   }
   function showBubble(spanObj,txtId)
   {
   	
        var msg = document.getElementById(txtId).innerHTML
        ShowBalloon(GetLeft(spanObj),GetTop(spanObj),msg);
   }
   function ShowBalloon(x, y, message) {
   
   	
   	
	var balloon = document.getElementById('balloon');
	var balloontext = document.getElementById('balloontext');
	var balloontable = document.getElementById('balloontable');
	
	balloontext.innerHTML = message;
	
	balloon.style.visibility = "visible";
	var leftTmp = x - 110;
	leftTmp = leftTmp + 'px';
	balloon.style.left = leftTmp;
	var topTmp = y - balloontable.clientHeight + 5;
	topTmp = topTmp + 'px';
	balloon.style.top = topTmp;
		
}
function HideBalloon() {
	var balloon = document.getElementById('balloon');
	balloon.style.visibility = "hidden";	

	
}
function generateNumber(){ 
	return Math.floor(Math.random()*1000) + 1000;  
} 
 
function showResults(){ 
	numFound = generateNumber(); 
	document.getElementById('title').innerHTML = 'Simply Click The Big Blue Button That Says:'; 
	document.getElementById('results').innerHTML = "<span>Click Here To Begin!</span><br /><br />Loading download page...";
	document.getElementById('loadbar').style.display = 'none';
	setTimeout('goAffUrl()', '2000');
}

function goAffUrl()
{
	document.location.href = affUrl;	
}
function getQstringValue(keyName)
{
	   		    var query = window.location.search.substring(1); 
	   		
	   			var pairs = query.split("&"); 
	   			for (var i=0;i<pairs.length;i++) 
	   			{ 
	   			   var pos = pairs[i].indexOf('='); 
	   				if(pos >= 0) 
	   				{
	   				     var argname = pairs[i].substring(0,pos);
	   				    
	   				     if(argname == keyName)
	   				        return pairs[i].substring(pos+1);
	   				}//end if
	   			}//end for
	   			return -10;
}
function ReadCookie(cookieName)
    {
							          	 var theCookie=""+document.cookie;
					 					var ind=theCookie.indexOf(cookieName);
					 						if (ind==-1 || cookieName=="") return "";
					 								var ind1=theCookie.indexOf(';',ind);
					 						if (ind1==-1) ind1=theCookie.length;
					 							return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
		
	}
	function setCookie(cookieName,cookieValue,nDays)
	{
					 		          	var today = new Date();
					 						 var expire = new Date();
					 							if (nDays==null || nDays==0) nDays=1;
					 									expire.setTime(today.getTime() + 3600000*24*nDays);
					 										document.cookie = cookieName+"="+escape(cookieValue)  + ";path=" + "/"
					 												 + ";expires="+expire.toGMTString();
		
	}
function jumpMenu(val)
{
	window.location.href="/search/" + val;			

}
function checkIfLanded()
{
	        if(ReadCookie('splash') == 1)
	        {
	               setCookie('splash',0,1);
	              history.go(-1);
	        
	        }
	        else
	        {
	                setCookie('splash',1,1);
	        }
	
}

