// Object declaration of object that are reference through out the site
var oPopUpCal = document.getElementById('PopUpCal'); 

// There is code that executes with every page load at the bottom of this script......



/********************************************************************************************
** Name		:GetCookie(sName)
** 
** 
** Purpose	: Retrieve the value of the cookie with the specified name.
** Inputs	: 
** Outputs	: 
** Revisions: 
**********************************************************************************************/
function GetCookie(sName)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }

  // a cookie with the requested name does not exist
  return null;
}

 /********************************************************************************************
** Name		:fnSetCookie(sCookieName,sValue)
** 
** 
** Purpose	: Set Cookie for the passed sCookieName
** Inputs	: 
** Outputs	: 
** Revisions: 
**********************************************************************************************/
var fnSetCookie = function(sCookieName,sValue,sPath){
	
	  if (typeof sPath == "undefined") {
	    sPath = "/";
	  }
	document.cookie = sCookieName+"="+sValue+";Thu, 01-Jan-1970 00:00:01 GMT;path="+sPath;	  
}

 /********************************************************************************************
** Name		:fnChangePage(sElement, sPageNumber)
** 
** 
** Purpose	: Function used to navigate the result pages
** Inputs	: 
** Outputs	: 
** Revisions: 
**********************************************************************************************/
var fnChangePage = function(sElement, sPageNumber){
	document.getElementById(sElement).value = sPageNumber;
	document.getElementById("SearchForm").submit();
}


/********************************************************************************************
** Name		:fnAlert(sMessage)
** 
** 
** Purpose	: custom alert function 
** Inputs	: 
** Outputs	: 
** Revisions: 
**********************************************************************************************/
var fnAlert = function(sMessage){
	alert(sMessage);
}


/********************************************************************************************
** Name		:fnCharCount(oElement)
** 
** 
** Purpose	: count string in element. 
** Inputs	: 
** Outputs	: 
** Revisions: 
**********************************************************************************************/
var fnCharCount = function(oElement){
	var oElementValue = oElement.value;
	return oElementValue.length;
}


function fixImage(img, width, height) {
   var isIE = navigator.userAgent.toLowerCase().indexOf("msie") >= 0;
   if (!isIE)
      return;

   var currentSrc = img.src;

   var imgStyle = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + currentSrc + "', sizingMethod='scale')";
   img.src = 'images/clearpixel.gif';
   img.style.width  = width + "px";
   img.style.height = height + "px";
   img.style.filter =  imgStyle;
}

var navigationPages = [ "home.page",  "demos.page", "docs.page",  "downloads.page" ];
var navigationLinks = [ "homeLink",  "demosLink", "resourcesLink", "downloadsLink" ];

function showMenuContext() {
   var currentLocation = document.location.href;
   for ( var i = 0 ; i < navigationPages.length ; i++ )
      if ( currentLocation.indexOf(navigationPages[i]) != -1 ) { setLinkStyle($(navigationLinks[i])); break; }
}

function setLinkStyle(link) {
   link.style.fontWeight = 'bold';
   var currentFontSize = parseInt(RicoUtil.getElementsComputedStyle(link, "fontSize", "font-size" ));
   link.style.fontSize = (currentFontSize+2) + "px";
   link.style.color    = 'white';
}
















