var expDays = 30;
var dateExpire = new Date(); 
dateExpire.setTime(dateExpire.getTime() + (expDays*24*60*60*1000));

// Print web page
function printpage() {
	window.print();
}

//Suckerfish JavaScript menu
sfHover = function() {
	if (document.getElementById("nav") != null ){
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover); 

// Open print page using _print extension.
function showPrint() {
	var strPage = window.location.pathname;
	
	alert ("This will be activated soon"); return false;
	strPage = strPage.substring(0, strPage.indexOf("_1.aspx"));
	if(strPage.toLowerCase().indexOf("news") != -1) {
		strPage = "news";	
	}
	else if(strPage.toLowerCase().indexOf("search") != -1) {
		strPage = "search";	
	}
	else {
		// set document as default
		strPage = "document";
	}
	/*window.location = strPage + "_print_1.aspx" + window.location.search;*/
	window.open(strPage + "_print_1.aspx" + window.location.search);
	
}

// Search site
function checkSearchFields(objForm)
{	
		if(trim(objForm.keywords.value) == "") {
			alert("Please enter your keyword(s)");
			objForm.keywords.focus();
			return false;
		}
		else {
			return true;
		}
}


// Cookie functions
function getCookieVal (offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
	endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
	var j = i + alen;    
	if (document.cookie.substring(i, j) == arg)      
	return getCookieVal (j);    
	i = document.cookie.indexOf(" ", i) + 1;    
	if (i == 0) break;   
	}  
	return null;
}
function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
// End Cookie functions

//Trim string
function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}
//End Function

//Right Trim string
function rtrim(str)
{
	return str.replace(/\s*$/, ""); 
}
//End Function

//Left Trim string
function ltrim(str)
{
	return str.replace(/^\s*/, ""); 
}
//End Function


// Email to a friend
function sendToFriend(iSessionID) {
		window.location = "mailto:?subject=Edeptive Ltd - interesting site&body=" + escape(window.location.href + "&email=1&ssid=" + iSessionID);
}
// end Email to a friend


// Set stylesheet for text size
function setActiveStyleSheet(name) 
{
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel") && a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == name) 
	  	{
		 a.disabled = false;
		}
    }
  }
	// Set small txt image on
	if (name == 'medium') {
	   	// Set styleSheet cookie to small
		SetCookie ('styleSheet', 'medium', dateExpire);
	}
	// Set large txt image on
	else if (name == 'large') {
	   // Set styleSheet cookie to small
	   SetCookie ('styleSheet', 'large', dateExpire);
	}
	// Set medium txt image on
	else {
	  // Set styleSheet cookie to small
	  SetCookie ('styleSheet', 'small', dateExpire);
	} 
}
// end Set stylesheet for text size

// Set styleSheet to cookie value
var styleSheet = GetCookie('styleSheet');
// Set page to the active style sheet
setActiveStyleSheet(styleSheet);

document.write("<script type=\"text/javascript\" src=\"assets/scripts/EdeptiveAjax.js\"></script>");

/*** keep alive ***/
document.write("<script type=\"text/javascript\" src=\"assets/scripts/EdeptiveAjax.js\"></script>");
var goAjax = null;
function keepAlive() {
	var strUrl = "";
	var sTiming = document.documentElement.lastChild.lastChild.innerHTML;
	var sParams = "";

	sTiming = sTiming.substring(sTiming.lastIndexOf("<!--"));
	sTiming = sTiming.substring(5, sTiming.indexOf(" -->"));
	strUrl = window.location.protocol + "//" + window.location.host + "/webservices/keep_alive.asmx/PingWithTiming";
	sParams = "Timing=" + sTiming;
	try {
		goAjax = new EdeptiveAjax();
		goAjax.postRequest(strUrl, sParams, onKeepAliveResponse);
	} catch(e) {
		setTimeout("keepAlive()", 1000*1);
	}
}
function onKeepAliveResponse() {
	if(goAjax.checkReadyState("keepAlive", "ping.", "ping..", "ping...") == "OK") {
		if(document.getElementById("keepAlive")) {
			var response = goAjax.request.responseXML.documentElement;
			document.getElementById("keepAlive").innerText = "sid=" + getText(response.firstChild);
		}
		setTimeout("keepAlive()", 1000*60);
	}
}
setTimeout("keepAlive()", 1000*2);

