// ---------------------------------------------------------------------------
// Common js functions used in Search Extreme functionality - 
//
// ---------------------------------------------------------------------------

var defaultMsg = "Processing request...";
var commonSearchLoadingMsg = "Please wait while we retrieve your results...";
function getLink(url)
{
	centerDiv(document.getElementById("loading"));
	setTimeout('document.images["imgLoading"].src = "/CDA/images/loading.gif"', 20); 	
	window.location=url;
}

function getLinkWOW(url)
{
	centerDivWOW(document.getElementById("loadingOuter"));
	setTimeout('document.images["imgLoading"].src = "/CDA/images/loading.gif"', 20); 	
	window.location=url;
}

function getLinkPOW(url)
{
	centerDivPOW(document.getElementById("loadingOuter"));
	setTimeout('document.images["imgLoading"].src = "/CDA/images/loading.gif"', 20); 	
	window.location=url;
}
function hideLoadingWOW()
{
	if(document.getElementById("loadingOuter"))
	{
		document.getElementById("loadingOuter").style.display="none";
		if(document.getElementById("loadingWOW")!=null)
			document.getElementById("loadingWOW").style.display="none";
		if(document.getElementById("loadingPOW"))// because of common pages search and funnel. in search and funnel we call showLoadingPOW rather then showLoadingWOW. 
			document.getElementById("loadingPOW").style.display="none";
	}
}

function hideLoadingPOW()
{
	if(document.getElementById("loadingOuter"))
	{
		document.getElementById("loadingOuter").style.display="none";
		if(document.getElementById("loadingPOW")!=null)
			document.getElementById("loadingPOW").style.display="none";
		if(document.getElementById("loadingWOW"))// because of common pages search and funnel. in search and funnel we call showLoadingPOW rather then showLoadingWOW. 
			document.getElementById("loadingWOW").style.display="none";
		
	}
}

function centerDivWOW(divobj)
{
	divHeight = divobj.style.height.substring(0,divobj.style.height.indexOf("px"));
	divWidth = divobj.style.width.substring(0,divobj.style.width.indexOf("px"));
	 
	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body

	var dsocleft=document.all? iebody.scrollLeft : pageXOffset;
	var dsoctop=document.all? iebody.scrollTop : pageYOffset;

	divobj.style.top = dsoctop + (document.documentElement.clientHeight/2 - divHeight/2)+'px';
	
	divobj.style.left = dsocleft + (document.documentElement.clientWidth/2 - divWidth/2)+'px';

	divobj.style.display="inline";
}

function showLoadingWOW(message) {
	if(message == null)
		message = defaultMsg;
	if(!document.getElementById("loadingOuter"))
		createLoadingDivs('/CDA/images/',message, "loadingWOW");
		
	if(document.getElementById("loadingWOW"))
		centerDivWOW(document.getElementById("loadingWOW"));
		
	setOuterDivStyle(document.getElementById("loadingOuter"));
	
	setTimeout('document.images["imgLoading"].src = "/CDA/images/loading.gif"', 200); 
	document.getElementById("loadingMessage").innerHTML=message;
	//alert('after showing loading msg');	
}

/*function closeOTMLightBox(){
	document.getElementById('oneTimeMessageOuter').value = "";
	document.getElementById('oneTimeMessageInner').value = "";
	document.getElementById('oneTimeMessageOuter').style.display='none';
	document.getElementById('oneTimeMessageInner').style.display='none';
}

function showOneTimeMessage(message) {
	
	if(!document.getElementById("oneTimeMessageOuter")) {
		//createLoadingDivs('/CDA/images/',message, "loadingWOW");
		var loadingDiv = '<div id="oneTimeMessageOuter" class="loadingOuter"></div>';
		loadingDiv += '<div id="oneTimeMessageInner" class="loadingWOW" style="display:none;height:300px;width:800px">';
		loadingDiv += '	<table height="100%" width="100%">';
		loadingDiv += '		<TR vAlign=bottom >';
		loadingDiv += '			<TD  class=displayText onclick="closeOTMLightBox();" align=right vAlign=top width="100%">';
		loadingDiv += '				&nbsp;&nbsp;x';
		loadingDiv += '			</TD>';
		loadingDiv += '		</TR>';
		loadingDiv += '		<TR >';
		loadingDiv += '			<TD  class=displayText align=left width="100%">';
		loadingDiv += '				<B>Points Exchange - New Features';
		loadingDiv += '				<li> <span class="autotip" name="Take advantage of enhanced Weeks Reservation search tools.;8311_RCI_Autotip_07_en_US"></span> Home Reservation </li>';
		loadingDiv += '				<li> Inventory Recommendation to Members </li>';
		loadingDiv += '			</TD>';
				
		loadingDiv += '		</TR>';
		
		loadingDiv += '	</table>';
		loadingDiv += '</div>';
	
		var tempDiv = document.createElement("div");
		tempDiv.innerHTML = loadingDiv;
		document.write(tempDiv.innerHTML);
	}
		
	if(document.getElementById("oneTimeMessageInner"))
		centerDivPOW(document.getElementById("oneTimeMessageInner"));
		
	setOuterDivStyle(document.getElementById("oneTimeMessageOuter"));

}
*/
// ---------------------------------------------------------------------------
// Common js functions used in Search Extreme functionality - 
//
// ---------------------------------------------------------------------------

var defaultMsg = "Processing request...";
var commonSearchLoadingMsg = "Please wait while we retrieve your results...";
function getLink(url)
{
	centerDiv(document.getElementById("loading"));
	setTimeout('document.images["imgLoading"].src = "/CDA/images/loading.gif"', 20); 	
	window.location=url;
}

function getLinkWOW(url)
{
	centerDivWOW(document.getElementById("loadingOuter"));
	setTimeout('document.images["imgLoading"].src = "/CDA/images/loading.gif"', 20); 	
	window.location=url;
}

function getLinkPOW(url)
{
	centerDivPOW(document.getElementById("loadingOuter"));
	setTimeout('document.images["imgLoading"].src = "/CDA/images/loading.gif"', 20); 	
	window.location=url;
}
function hideLoadingWOW()
{
	if(document.getElementById("loadingOuter"))
	{
		document.getElementById("loadingOuter").style.display="none";
		if(document.getElementById("loadingWOW")!=null)
			document.getElementById("loadingWOW").style.display="none";
		if(document.getElementById("loadingPOW"))// because of common pages search and funnel. in search and funnel we call showLoadingPOW rather then showLoadingWOW. 
			document.getElementById("loadingPOW").style.display="none";
	}
}

function hideLoadingPOW()
{
	if(document.getElementById("loadingOuter"))
	{
		document.getElementById("loadingOuter").style.display="none";
		if(document.getElementById("loadingPOW")!=null)
			document.getElementById("loadingPOW").style.display="none";
		if(document.getElementById("loadingWOW"))// because of common pages search and funnel. in search and funnel we call showLoadingPOW rather then showLoadingWOW. 
			document.getElementById("loadingWOW").style.display="none";
		
	}
}

function centerDivWOW(divobj)
{
//	alert('set outer div');
	divHeight = divobj.style.height.substring(0,divobj.style.height.indexOf("px"));
	divWidth = divobj.style.width.substring(0,divobj.style.width.indexOf("px"));
	 
	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body

	var dsocleft=document.all? iebody.scrollLeft : pageXOffset;
	var dsoctop=document.all? iebody.scrollTop : pageYOffset;
	
	divobj.style.top = dsoctop + (document.documentElement.clientHeight/2) - (divHeight/2)+'px';
	
	divobj.style.left = dsocleft + (document.documentElement.clientWidth/2 - divWidth/2)+'px';

	divobj.style.display="inline";
}

function showLoadingWOW(message, messageSec) {
//alert('showLoadingWOW : messageSec : -- ' + messageSec );
	if((message == null || message == "" || message == 'undefined') && typeof(loadingMessageLayout1) != 'undefined')
	{
		message = loadingMessageLayout1;
	}
	if((messageSec == null || messageSec == "" || messageSec == 'undefined') && typeof(loadingMessageLayout2) != 'undefined')
	{
		messageSec = loadingMessageLayout2;
	}

	if(message == null)
		message = defaultMsg;
	if(messageSec == null)
		messageSec = defaultMsg;
	if(!document.getElementById("loadingOuter"))
		createLoadingDivs('/CDA/images/',message, messageSec, "loadingWOW");
		
	if(document.getElementById("loadingWOW"))
		centerDivWOW(document.getElementById("loadingWOW"));
		
	setOuterDivStyle(document.getElementById("loadingOuter"));
	
//	setTimeout('document.images["imgLoading"].src = "/CDA/images/loading.gif"', 200); 
	document.getElementById("loadingMessage").innerHTML=message;
	document.getElementById("loadingMessageSec").innerHTML=messageSec;

}

function showLoadingPOW(message, messageSec) {

	if((message == null || message == "" || message == 'undefined') && typeof(loadingMessageLayout1) != 'undefined')
	{
		message = loadingMessageLayout1;
	}
	if((messageSec == null || messageSec == "" || messageSec == 'undefined') && typeof(loadingMessageLayout2) != 'undefined')
	{
		messageSec = loadingMessageLayout2;
	}
		
	if(message == null)
		message = defaultMsg;
	if(messageSec == null)
		messageSec = defaultMsg;
	if(!document.getElementById("loadingOuter"))
		createLoadingDivs('/CDA/images/',message, messageSec, "loadingPOW");
	
	if(document.getElementById("loadingPOW")!=null)
		centerDivPOW(document.getElementById("loadingPOW"));
	if(document.getElementById("loadingWOW") != null)
		centerDivWOW(document.getElementById("loadingWOW"));
	setOuterDivStyle(document.getElementById("loadingOuter"));
//	setTimeout('document.images["imgLoading"].src = "/CDA/images/loading.gif"', 200); 
	document.getElementById("loadingMessage").innerHTML=message;

	document.getElementById("loadingMessageSec").innerHTML=messageSec;
}

function createLoadingDivs(imageURL, message, messageSec, innterLoadingName){
//	alert('inside create divs') ;
	var loadingDiv = '<div id="loadingOuter" class="loadingOuter"></div>';
		loadingDiv += '<div id="'+innterLoadingName+'" class="'+innterLoadingName+'" style="display:none;height:450px;width:816px">';
		loadingDiv += '	<table height="100%">';
		loadingDiv += '		<tr>';
		loadingDiv += '			<td class="loadingText" valign="middle">';
		loadingDiv += '			<span id="loadingMessage">'+message+'</span>';
		loadingDiv += '			</td>';
		loadingDiv += '		</tr>';
		loadingDiv += '		<tr>';
		loadingDiv += '			<td class="loadingTextSec" valign="middle">';
		loadingDiv += '			<span id="loadingMessageSec" style="font-size:18px; font-weight:bold;">'+messageSec+'</span>';
		loadingDiv += '			</td>';
		loadingDiv += '		</tr>';
		loadingDiv += '	</table>';
		loadingDiv += '</div>';
	
	//alert(loadingDiv);
	var tempDiv = document.createElement("div");
	tempDiv.innerHTML = loadingDiv;
	document.write(tempDiv.innerHTML);
}
function centerDivPOW(divobj)
{
	divHeight = divobj.style.height.substring(0,divobj.style.height.indexOf("px"));
	divWidth = divobj.style.width.substring(0,divobj.style.width.indexOf("px"));
	 
	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body

	var dsocleft=document.all? iebody.scrollLeft : pageXOffset;
	var dsoctop=document.all? iebody.scrollTop : pageYOffset;
	
	divobj.style.top = dsoctop + (document.documentElement.clientHeight/2 - divHeight/2)+'px';
	
	divobj.style.left = dsocleft + (document.documentElement.clientWidth/2 - divWidth/2)+'px';

	divobj.style.display="inline";
}

function setOuterDivStyle(divObj){

	divObj.style.top = 0;
	divObj.style.left = 0;
	
	var body = document.body;
    var html = document.documentElement;

	var height = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );

	divObj.style.height = height;
	divObj.style.width = document.body.clientWidth;

	divObj.style.display="inline";

}


function centerDiv(divobj)
{
	divobj.style.top = 0+'px';
	divobj.style.left = 0+"px";
	//alert (document.body.clientHeight);
	//divobj.style.height = document.body.clientHeight;
	divobj.style.opacity='0.75';
	window.scrollTo(200,0);


	//alert(divobj.style.top);
	//alert(divobj.style.left);

	divobj.style.display="block";
}

function centerDivDim(divobj, x, y)
{
	divheight = divobj.style.height.substring(0,divobj.style.height.indexOf("px"));
	divwidth = divobj.style.width.substring(0,divobj.style.width.indexOf("px"));

	divobj.style.top = Math.round((document.body.clientHeight/2)-(divheight/2)+document.body.scrollTop-20)+'px';
	divobj.style.left = Math.round((document.body.clientWidth/2)-(divwidth/2)+90)+"px";

	//alert(divobj.style.top);
	//alert(divobj.style.left);
	//window.scrollTo(200,0);
	//document.getElementById("sortDD").style.display = "none";
	divobj = document.getElementById("loading");
	document.getElementById("loading").style.opacity='0.75';
	divobj.style.top = y +5;
	divobj.style.left = x + 20;
	divobj.style.display="block";

	//put in to override old style 06/02/09

	divobj.style.top = 0+'px';
	divobj.style.left = 0+"px";
	divobj.style.height = 3000+"px";
	divobj.style.width = 1000+"px";
}

function centerDivAULoad(divobj, x, y, rowObj)
{

	divheight = divobj.style.height.substring(0,divobj.style.height.indexOf("px"));
	divwidth = divobj.style.width.substring(0,divobj.style.width.indexOf("px"));

	divobj.style.top = Math.round((document.body.clientHeight/2)-(divheight/2)+document.body.scrollTop-20)+'px';
	divobj.style.left = Math.round((document.body.clientWidth/2)-(divwidth/2)+90)+"px";

	//alert(divobj.style.top);
	//alert(divobj.style.left);

	//window.scrollTo(200,0);
	//document.getElementById("sortDD").style.display = "none";
	document.getElementById("loading").style.opacity='0.75';
	divobj.style.top = y +0;
	divobj.style.left = x + 20;
	if (x > 25) {
	divobj.style.display="block"
	} else {
	divobj.style.display="none"
	}
}



function deleteRow(element) {
	document.getElementById('tblSavedSearches').deleteRow(element.parentNode.parentNode.rowIndex);
}

function viewGoogleMap(lat, long, rName, rUrl)
{
	//Single Resort Map
	str = "/RCI/RCICommon/ERCP/EVLC/RCI_ERCPMapResort.jsp?lattDegree=" +lat +"&longDegree="+long +"&resName="+rName +"&resUrl=" + rUrl;
		
	javascript:window.open(str,'map','menubar=0,scrollbars=no,status=no,width=599,height=499');
	return false;
}

function saveThisSearch() {
//		alert(window.innerHeight);
//		alert(document.body.offsetHeight);
//		alert(document.getElementById("bodyBack").offsetHeight);
		if (document.getElementById('frmPopUp').style.display == "none") {
			document.getElementById('frmPopUp').style.display = "";
			var height = 0;
			if(window.innerHeight)
			{
				if(window.innerHeight > document.getElementById("bodyBack").offsetHeight)
				{
					height = window.innerHeight;
				}
				else
				{
					height = document.getElementById("bodyBack").offsetHeight;
				}
			}
			else
			{
				if(document.body.offsetHeight > document.getElementById("bodyBack").offsetHeight)
				{
					height = document.body.offsetHeight;
				}
				else
				{
					height = document.getElementById("bodyBack").offsetHeight;
				}
			}
			document.getElementById("frmPopUpBackground").style.height=height;
			document.getElementById("frmPopUpBackground").style.width=document.body.offsetWidth;
			document.getElementById("frmPopUpBackground").style.display='';
			document.getElementById("frmPopUpContentTable").style.display='';
//			document.getElementById('saveSearchName').focus();
			backToTop();

		} else {
			document.getElementById('frmPopUp').style.display = "none";
			document.getElementById("frmPopUpBackground").style.display='none';
			document.getElementById("frmPopUpContentTable").style.display='none';

		}

}

function back() {

		if (document.getElementById('frmPopUp').style.display == "") {
			document.getElementById('frmPopUp').style.display = "none";
			document.getElementById("frmPopUpBackground").style.display='none';
			document.getElementById("frmPopUpContentTable").style.display='none';
		}
}

function setConstraintsForToDate(idFrom,idTo){
	var dateToMin = dijit.byId(idFrom).attr('value');
	var dateToMax = dijit.byId(idFrom).attr('value');
	if(dateToMax == null)
		return;
	dateToMax.setDate(dateToMax.getDate() + 730);
	dijit.byId(idTo).constraints.min=dateToMin;
	dijit.byId(idTo).constraints.max=dateToMax;
	if(dijit.byId(idTo).attr('value') < dateToMin || dijit.byId(idTo).attr('value') > dateToMax)
	{
		dijit.byId(idTo).attr('value',dateToMin);
	}
}

function setConstraintsForToDateForWeeks(idFrom,idTo) {
	var dateToMin = dijit.byId(idFrom).attr('value');
	var dateToMax = dijit.byId(idFrom).attr('value');
	if(dateToMax == null)
		return;
	dateToMax.setDate(dateToMax.getDate() + 730);
	dijit.byId(idTo).constraints.min=dateToMin;
	dijit.byId(idTo).constraints.max=dateToMax;
	if(dijit.byId(idTo).attr('value') < dateToMin || dijit.byId(idTo).attr('value') > dateToMax)
	{
		dijit.byId(idTo).attr('value',dateToMin);
	}	
}

function setConstraintsForWRToDate(idFrom,idTo,dateRange,resEndDate){
	var dateToMin = dijit.byId(idFrom).attr('value');
	var dateToMax = dijit.byId(idFrom).attr('value');
	if(dateRange!= 'undefined' && dateRange!=null && dateRange!=""){
		dateToMax.setDate(dateToMax.getDate() + eval(dateRange) - 1);
	} else {
		dateToMax.setDate(dateToMax.getDate() + 70 - 1);
	}
	if(dateToMax>resEndDate){
		dateToMax=resEndDate;
	}
	dijit.byId(idTo).constraints.min=dateToMin;
	dijit.byId(idTo).constraints.max=dateToMax;
	if(dijit.byId(idTo).attr('value') < dateToMin || dijit.byId(idTo).attr('value') > dateToMax)
	{
		dijit.byId(idTo).attr('value',dateToMin);
	}
}
function setConstraintsSREndDate(idFrom,idTo,dateRange,resEndDate){
	var dateToMin = dijit.byId(idFrom).attr('value');
	var dateToMax = dijit.byId(idFrom).attr('value');
	var consToDate=dijit.byId(idFrom).attr('value');
	if(dateRange!= 'undefined' && dateRange!=null && dateRange!=""){
		dateToMax.setDate(dateToMax.getDate() + eval(dateRange));
	} 
	if(dateToMax>resEndDate){
		dateToMax=resEndDate;
	}
	consToDate.setDate(consToDate.getDate() + eval(29));
	if(consToDate>resEndDate){
		consToDate=resEndDate;
	}
	dijit.byId(idTo).constraints.min=dateToMin;
	dijit.byId(idTo).constraints.max=consToDate;
	if(dijit.byId(idTo).attr('value') < dateToMin || dijit.byId(idTo).attr('value') > consToDate)
	{
		dijit.byId(idTo).attr('value',dateToMax);
	}
}
//  Added by Cognizant for Assyst# 940661
function setConstraintsForToDateFasst(idFrom,idTo){
    var dateToMin = dijit.byId(idFrom).attr('value');
    var dateToMax = dijit.byId(idFrom).attr('value');
    if(dateToMin && dateToMax)
    {
          dateToMax.setDate(dateToMax.getDate() + 730);
          dijit.byId(idTo).constraints.min=dateToMin;
          dijit.byId(idTo).constraints.max=dateToMax;
          if(dijit.byId(idTo).attr('value') < dateToMin || dijit.byId(idTo).attr('value') > dateToMax)
          {
                dijit.byId(idTo).attr('value',dateToMin);
          }
          dijit.byId(idTo).focus();
    }
}
//----------------------
function getRegionElementFromValue(id , value)
{
	var ulElement = document.getElementById(id + "_popup");
	var arrayLis = ulElement.getElementsByTagName('li');
	for(var i = 0 ; i < arrayLis.length ; i++)
	{
		if(arrayLis[i].innerText == value)
		{
			setValueForWidget(id , arrayLis[i].id);
		}
	}
}

function callOnMouseDownForWidget(id , regionValueOnLoad)
{
	var subarea1Div = document.getElementById('widget_' + id);
	var subarea1DivMain = subarea1Div.getElementsByTagName('div')[0];
	var subarea1DivArrowButton = subarea1DivMain.getElementsByTagName('div')[0];
	var evt;
	if(!document.createEvent)
	{
		evt = document.createEventObject();
		evt.srcElement=subarea1DivArrowButton;
		evt.target=subarea1DivArrowButton;
		evt.type="mousedown";
	}
	else
	{
		evt = document.createEvent("MouseEvents");
		evt.initMouseEvent( 'mousedown', true, false, window, 0, 0, 0, 0, 0, false, false, true, false, 0, subarea1DivArrowButton );
	}
	dijit.byId(id)._onArrowMouseDown(evt);
	if(regionValueOnLoad)
	{
		setTimeout("getRegionElementFromValue('" + id + "','" + regionValueOnLoad + "')",100);
	}
}

function setValueForWidget(id , regionElement){
	var evt;
	if(!document.createEvent)
	{
		evt = document.createEventObject();
		evt.keyCode='40';
		if(!regionElement)
		{
			evt.srcElement=document.getElementById(id + '_popup0');
			evt.target=document.getElementById(id + '_popup0');
		}
		else
		{
			evt.srcElement=document.getElementById(regionElement);
			evt.target=document.getElementById(regionElement);
		}
		evt.type="mouseup";
		dijit.byId(id + '_popup')._onMouseUp(evt);
	}
	else
	{
		evt = document.createEvent("MouseEvents");
		var target;
		if(!regionElement)
		{
			target = document.getElementById(id + '_popup0');
		}
		else
		{
			target = document.getElementById(regionElement);
		}
		evt.initMouseEvent( 'mouseup', true, false, window, 0, 0, 0, 0, 0, false, false, true, false, 0, null );
		target.dispatchEvent(evt);
	}
}

function checkExists(id , nextId , regionId)
{
	var idExists = false;
	if(document.getElementById(id + '_popup')) {
		var ulElement = document.getElementById(id + "_popup");
		var arrayLis = ulElement.getElementsByTagName('li');
		if(arrayLis.length >= 3)
		{
			idExists = true;;
		}
	}
	if(idExists == false)
	{
		document.getElementById(id).value='Enter/Select a Sub Region';
		document.getElementById(id + "Row").style.display='none';
		dijit.byId(id).attr("disabled", true);

		if(nextId)
		{
			document.getElementById(nextId + "Row").style.display='';
			dijit.byId(nextId).attr("disabled", false);
			dijit.byId(nextId).query.parentRegionId = regionId;
			callOnMouseDownForWidget(nextId);
			setTimeout("checkExists('" + nextId + "')",100);
			document.getElementById(nextId).value='';
		}
	}
	else
	{
		if(nextId)
		{
			document.getElementById(nextId).value='Enter/Select a Destination';
			document.getElementById(nextId + "Row").style.display='none';
			dijit.byId(nextId).attr("disabled", true);
		}
	}
}


function Trim(str)
{

  return LTrim(RTrim(str));

}

function LTrim(str)
{

  for (var i=0; str.charAt(i)==" " || str.charAt(i) == "\n" || str.charAt(i) == "\r" ; i++)
  {
    str =  str.substring(i,str.length-1);
  }
  return str;
}

function RTrim(str)
{

  for (var i=str.length-1; str.charAt(i)==" " || str.charAt(i) == "\n" || str.charAt(i) == "\r"; i--)
  {
    str = str.substring(0,i);
  }
  return str;
}


function backToTop() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));

    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("backToTop()", 25);
    }
}

function includeJSFile(filename , id) {
	var script = document.createElement('script'); 
	script.src = filename;
	script.type = 'text/javascript'; 
	if(id)
	{
		script.id=id;
	}
	document.getElementsByTagName('head').item(0).appendChild(script);
//	eval(script);
}

function printConfirmation(x) {
	var url = x;
	var parms = "toolbar=yes,menubar=yes,location=no,directories=no,status=no,scrolling=yes,scrollbars=yes,resizeable=yes,width=750,height=580,left=30px,top=30px";
	op=window.open(url, "confirmWindow", parms);
	op.print();
} 

function showToolTip(evt, toolTipDivId , message){
	 var toolTipDiv;;
	 if(!document.getElementById(toolTipDivId))
	 {
	 	toolTipDiv = document.createElement('div');
	 	toolTipDiv.id=toolTipDivId;
	 	toolTipDiv.className = "popupMessage";
	 	document.body.appendChild(toolTipDiv);		 
	 }
	 else
	 {
	 	toolTipDiv = document.getElementById(toolTipDivId);
	 }
	 
     var eventForThis = evt || window.event;

	 toolTipDiv.innerHTML = ""+message;
	 toolTipDiv.style.width="300px";
     toolTipDiv.style.position="absolute";
     toolTipPosX = eventForThis.clientX + 20 + document.body.scrollLeft;
     toolTipPosY = eventForThis.clientY + document.body.scrollTop;     
     if(toolTipPosY + 40 >= document.clientHeight)
     	toolTipPosY = toolTipPosY-40;     	
     toolTipDiv.style.left = eventForThis.clientX + 20 + document.body.scrollLeft;
     toolTipDiv.style.top = eventForThis.clientY + document.body.scrollTop;
     toolTipDiv.style.display="";

	 
}

function hideToolTip(toolTipDivId){
       document.getElementById(toolTipDivId).style.display='none';           
}

function changeAccordionIndicator(idPrefix , idSuffix , count)
{
	for(var i = 1 ; i <= count ; i++)
	{
		if(i==idSuffix)
		{
			if(document.getElementById(idPrefix+i).innerHTML == "+") {
				document.getElementById(idPrefix+i).innerHTML = "-";
			} else {
				document.getElementById(idPrefix+i).innerHTML = "+";
			}
		}
		else
		{
			if(document.getElementById(idPrefix+i) != null) {
				document.getElementById(idPrefix+i).innerHTML = "+";
			}
		}
	}
} 


function toggleHomeWeekContent(containerId , contentId , indicatorId , mainContainerId, mainContentId)
{
	if(document.getElementById(indicatorId).innerHTML == "+")
	{
		if(document.getElementById(containerId) != null && document.getElementById(contentId) != null)
		{
			var contentHeight = parseInt(document.getElementById(contentId).offsetHeight);
			contentHeight = contentHeight + 15;
			var mainContentHeight = parseInt(document.getElementById(mainContentId).offsetHeight);

			var animateOuterDiv = dojo.animateProperty({
					  node:containerId, duration:700,
					  properties: {
						  height: contentHeight
					  }
					});
			animateOuterDiv.play();
			
			var animateMainDiv = dojo.animateProperty({
				node:mainContainerId, duration:700,
				properties:{
					height: contentHeight + mainContentHeight
				}
			});
			animateMainDiv.play();
		}
		document.getElementById(indicatorId).innerHTML = "- ";
	}
	else
	{
		if(document.getElementById(containerId) != null)
		{
			var contentHeight = parseInt(document.getElementById(contentId).offsetHeight);
			var mainContentHeight = parseInt(document.getElementById(mainContentId).offsetHeight);
			
			var animateOuterDiv = dojo.animateProperty({
				  node:containerId, duration:700,
				  properties: {
					  height: 1
				  }
				});
				animateOuterDiv.play();
				var animateMainDiv = dojo.animateProperty({
					node:mainContainerId, duration:700,
					properties:{
						height: mainContentHeight - contentHeight
					}
				});
				animateMainDiv.play();
		}
		document.getElementById(indicatorId).innerHTML = "+";
	}
	

}

function addLoadEvent(func) {
   var oldonload = window.onload; 
   if (typeof window.onload != 'function') { 
     window.onload = func;  
   } else {  
     window.onload = function() { 
       if (oldonload) {  
         oldonload();  
       }  
       func(); 
     }  
   }
 } 

