
function initHomePageMethod(){
		
		initTooltip();//tooltip
		showBannerInit();//Banner Home
		onLoadWebformMethod();//Webforms 
}

attachEventListener(window, "load", initHomePageMethod, false);

/* webforms*/
function onLoadWebformMethod()
{
var divObjs=document.getElementsByTagName('DIV');
	for(var i=0;i<divObjs.length;i++)
	{
		if(divObjs[i].className=="toShowOnLoad")
		{
			divObjs[i].className="toHideOnLoad";
		}
		else if(divObjs[i].className=="toHideOnLoad")
		{
			divObjs[i].className="toShowOnLoad";
		}
	}
}
/* webforms*/


/* banner Home*/
var width=0;

function showHidden(e,inputId){
	if(!inputId)inputId = this.id;
		inputId = inputId +'';
		var numericId = inputId.replace(/[^0-9]/g,'');
		var outDiv=document.getElementById('outDiv'+numericId);
		var overDiv=document.getElementById('overDiv'+numericId);
		var BgoutDiv=document.getElementById('outBg'+numericId);
		var BgoverDiv=document.getElementById('overBg'+numericId);
		outDiv.style.display='none';
		BgoutDiv.style.display='none';
		overDiv.style.display='block';
		BgoverDiv.style.display='block';
		overDiv.onmousemove=retainShowOver;
		BgoverDiv.onmousemove=retainShowOver;
		overDiv.onmouseout=hideShowOver;
		BgoverDiv.onmouseout=hideShowOver;
 }


function hideShowOver(e,inputId){

		if(!inputId)inputId = this.id;
		inputId = inputId + '';
		var numericId = inputId.replace(/[^0-9]/g,'');
		var outDiv=document.getElementById('outDiv'+numericId);
		var overDiv=document.getElementById('overDiv'+numericId);
		var BgoutDiv=document.getElementById('outBg'+numericId);
		var BgoverDiv=document.getElementById('overBg'+numericId);
		outDiv.style.display='block';
		BgoutDiv.style.display='block';
		overDiv.style.display='none';
		BgoverDiv.style.display='none';
}

function retainShowOver(e,inputId){
			
		if(!inputId)inputId = this.id;
		inputId = inputId + '';
		var numericId = inputId.replace(/[^0-9]/g,'');
		var outDiv=document.getElementById('outDiv'+numericId);
		var overDiv=document.getElementById('overDiv'+numericId);
		var BgoutDiv=document.getElementById('outBg'+numericId);
		var BgoverDiv=document.getElementById('overBg'+numericId);
		outDiv.style.display='none';
		BgoutDiv.style.display='none';
		overDiv.style.display='block';
		BgoverDiv.style.display='block';
}



function showBannerInit(){

		var divs=document.getElementsByTagName('DIV');
		var outdivCounter = 1;
		var overdivCounter=1;
		var counter=0;
		var overcounter=0;
		for(var no=0;no<divs.length;no++){
			if(divs[no].className=='outDiv'){
			divs[no].onmouseover = showHidden;
			// divs[no].onmouseout = hide;   
			divs[no].id = 'outDiv'+outdivCounter;
			divs[no].style.display='block';
			counter++;
			outdivCounter++;
			}
			if(divs[no].className==('overDiv'+overdivCounter)){
			divs[no].id = 'overDiv'+overdivCounter;
			overcounter++;
			divs[no].className='overDiv';
			divs[no].style.display='none';
			var bg = divs[no].nextSibling;
			while(bg && bg.tagName!='DIV'){
			    bg = bg.nextSibling;
			}
			bg.id='overBg'+overdivCounter;
			bg.className='overBg';
			bg.style.display='none';
			overdivCounter++;
		    }
	    }
		width=666/counter;
		var divs=document.getElementsByTagName('DIV');
		var divCounter=1;
		leftValue=0;
		for(var no=0;no<divs.length;no++){
					if(divs[no].className=='outDiv'){
					divs[no].style.left=leftValue+'px';
					divs[no].style.width=width-10+'px';
					var bg = divs[no].nextSibling;
					while(bg && bg.tagName!='DIV'){
					     bg = bg.nextSibling;
					}
					bg.id='outBg'+divCounter;
					bg.style.display='block';
					bg.style.left=leftValue+'px';
					bg.style.width=width-1+'px';
					divCounter++;
					leftValue=leftValue+width;
				}
		}
		var divs=document.getElementsByTagName('DIV');
		var val=0;
		var overValue=0;
		for(var no=0;no<divs.length;no++){
				if(divs[no].className=='overBg'){
						divs[no].style.left=val+'px';
						divs[no].style.width=width-1+'px';
						divs[no].style.display='none';
						val=val+width;
				}
				if(divs[no].className=='overDiv'){
						divs[no].style.left=overValue+'px';
						divs[no].style.width=width-10+'px';
						overValue=overValue+width;
				}
		}

}

/*Banner Home*/


// Contextual Help ---- start

var currShow = false; 
var boxHeight, cntHeight;
function setOpacity(obj, opacity) {
	  opacity = (opacity == 100)?99.999:opacity;
	  // IE/Win
	  obj.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+ opacity + ");";
	  // Safari<1.2, Konqueror
	  obj.style.KHTMLOpacity = opacity/100;
	  // Older Mozilla and Firefox
	  obj.style.MozOpacity = opacity/100;
	  // Safari 1.2, newer Firefox and Mozilla, CSS3
	  obj.style.opacity = opacity/100;
}

var maxTooltipHt=false;

function ShowChildFunction(inputId, numericId){
		var inputId= inputId;
		var numericId=numericId;
		currShow=numericId;	
		var x = document.getElementById("tooltipBody"+numericId);	
		//leftX = x.offsetLeft;
		//topY = x.offsetTop;	
		//alert(currShow);
		leftX = findPosX(x);
		topY = findPosY(x);
		//alert(leftX+" "+topY);
		//alert(leftX+"------"+topY);
		if(maxTooltipHt){
		//alert("showed max height before");
				var element = document.getElementById('toolTip');
				while (element.firstChild) {
				   element.removeChild(element.firstChild);
				}
				//alert(document.getElementById('toolTip').innerHTML);
				var newTooltip=document.createElement('div');
				newTooltip.id='tooltipBox';
				var parTooltip=document.getElementById('toolTip');
				parTooltip.appendChild(newTooltip);
				maxTooltipHt=false;  
		}
		if(numericId==1){
				//alert("showed max height before");
				var element = document.getElementById('toolTip');
				while (element.firstChild) {
				     element.removeChild(element.firstChild);
				}
				//alert(document.getElementById('toolTip').innerHTML);
				var newTooltip=document.createElement('div');
				newTooltip.id='tooltipBox';
				var parTooltip=document.getElementById('toolTip');
				parTooltip.appendChild(newTooltip);
				//alert(document.getElementById('tooltipBox').id);   
				// maxTooltipHt=false;  
		}
		document.getElementById('copays').style.display = "block";
		setOpacity(document.getElementById("arrow"), 98);
		//alert(document.getElementById('copays').innerHTML);
		//var delayed=setTimeout("document.getElementById('copays').style.display='none';",2000);
		//document.getElementById('tooltipBox').innerHTML = null;
		//alert("document.getElementById('tooltipBox').offSetHeight: "+document.getElementById('tooltipBox').offsetHeight);
		document.getElementById('tooltipBox').innerHTML = document.getElementById('tooltipContent'+numericId).innerHTML;
		//alert("document.getElementById('tooltipBox').offSetHeight: "+document.getElementById('tooltipBox').offsetHeight);
		//alert("document.getElementById('toolTip').offSetHeight: "+document.getElementById('toolTip').offsetHeight);
		getPosition('copays',leftX,topY,'arrow',currShow);
}

function showdiv(e,inputId){    
		boxHeight = 0;
		cntHeight = 0;
		if(!inputId)inputId = this.id;
		inputId = inputId + '';
		document.getElementById(inputId).className = 'tooltipHeadSelected';
		var numericId = inputId.replace(/[^0-9]/g,'');
		pausecomp(500);
		ShowChildFunction(inputId,numericId);
		return(false);
}

function pausecomp(millis){
		var date = new Date();
		var curDate = null;
		do { curDate = new Date(); }
		while(curDate-date < millis);
} 

function showTooltip(numId){
			var numericId=numId;
			//	alert("retain"+numericId);
			//alert("showTooltip");
			var x = document.getElementById("tooltipBody"+numericId);
			leftX = findPosX(x);
			topY = findPosY(x);
			document.getElementById('copays').style.display = "block";
			//document.getElementById('tooltipBox').innerHTML = document.getElementById('tooltipContent'+numericId).innerHTML;
			//getPosition('copays',leftX,topY,'arrow',currShow);
}


function findPosX(obj)
  {
         	var curleft = 0;
			if(obj.offsetParent)
				while(1) 
				{
				  curleft += obj.offsetLeft;
				  if(!obj.offsetParent)
					break;
				  obj = obj.offsetParent;
				}
			else if(obj.x)
				curleft += obj.x;
			return curleft;
  }

  function findPosY(obj)
  {
			var curtop = 0;
			if(obj.offsetParent)
				while(1)
				{
				  curtop += obj.offsetTop;
				  if(!obj.offsetParent)
					break;
				  obj = obj.offsetParent;
				}
			else if(obj.y)
				curtop += obj.y;
			return curtop;
  }

function getPosition(divnamePos,leftX,topY,arrowDiv, divCount){

			var screenW,screenH;
			screenW = screen.width;
			screenH = screen.height;
		    var divNumber=divCount;
			var divLeft, divTop;
			divLeft = leftX;
			divTop = topY;					
			var spaceX=screenW - divLeft;
			var spaceY=screenH - divTop;
			var positionId;
           //alert(screenW+"-----"+screenH);
           //alert("display top"+divLeft+"display top"+divTop);   
           getWindowSize();
		   var totalHt=myHeight;
		   var totalWt=myWidth;
		   //alert("pageHt"+totalHt);	  
			  var myWindowWidth = 0, myWindowHeight = 0;
			  if( typeof( window.innerWidth ) == 'number' ) {
				//Non-IE
				myWindowWidth = window.innerWidth;
				myWindowHeight = window.innerHeight;
			  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
				//IE 6+ in 'standards compliant mode'
				myWindowWidth = document.documentElement.clientWidth;
				myWindowHeight = document.documentElement.clientHeight;
			  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				//IE 4 compatible
				myWindowWidth = document.body.clientWidth;
				myWindowHeight = document.body.clientHeight;
			  }
			//alert( 'Width = ' + myWidth );
			//alert( 'Height = ' + myHeight );
			screenW=myWindowWidth;
			screenH=myWindowHeight;	
			//alert(screenH);
		   var scrollHt=document.documentElement.scrollTop; 
		  var scrollBt=document.documentElement.scrollLeft;
		  //alert(scrollBt);
		   var visibleScreen=(scrollHt) + (screenH);
			boxHeight =  document.getElementById("tooltipBox").offsetHeight;
             var boxWidth=document.getElementById("tooltipBox").offsetHeight;			
     		var tooltipY=divTop+boxHeight + 38;
           // alert(tooltipY+"----"+visibleScreen);	
			//alert(tooltipY+"------"+visibleScreen);
			//alert("boxHeight : "+boxHeight);
			if(boxHeight >= 440){				
				cntHeight = 430;
				//alert("if loop boxHeight:"+boxHeight+"cntHeight: "+cntHeight);
				//document.getElementById("cntxtHlpInnrCnt").style.height = cntHeight;
                document.getElementById("cntxtHlpInnrCnt").style.overflow='hidden';
				//document.getElementById('copays').style.height = cntHeight;
                document.getElementById('tooltipBox').style.height='440px';
                document.getElementById('tooltipBox').style.overflow='hidden';
                maxTooltipHt=true;
			}else{
				cntHeight = boxHeight;
				//alert("else loop boxHeight:"+boxHeight+"cntHeight: "+cntHeight);
				//document.getElementById("cntxtHlpInnrCnt").style.height = boxHeight;
				//document.getElementById('copays').style.height = boxHeight;
			}
//ends here	
           var tempDiv1=document.getElementById('tooltipHead'+divNumber);
                 tempDivX1=findPosX(tempDiv1);
				 var tiplength1 = divLeft-tempDivX1;
           if(((divLeft-scrollBt)-tiplength1)> 200 && (screenW - (divLeft-scrollBt))>200 &&boxHeight<440 && (divTop-scrollHt)>(boxHeight+100)){	      
			  //alert("top");
			  var tempDiv=document.getElementById('tooltipHead'+divNumber);
                 tempDivX=findPosX(tempDiv);
				 var tiplength = divLeft-tempDivX;
				 tiplength=tiplength/2;
			  document.getElementById(divnamePos).style.left= (divLeft - 200 - tiplength) + "px";
			 
			 if(document.all){
				 
			 document.getElementById(divnamePos).style.top = (divTop - (cntHeight+25)) + "px";
			  }
			  else{
			 document.getElementById(divnamePos).style.top = (divTop - (cntHeight+25)) + "px";
			  }
			  positionId="top";
			  
		   
		 //  }

		  // if((divLeft<800) && (divTop>750)){
            /* to display top*/
			//alert("display top"+divLeft+"display top"+divTop);
			//document.getElementById(divnamePos).style.left= (divLeft - 250) + "px";
		//	document.getElementById(divnamePos).style.top = (divTop - (cntHeight+80)) + "px";
             
          
			//positionId="top";
              } else{
			     if((screenW - divLeft) > 420 ){
				 //position to the right
			  	// alert("right");
				 document.getElementById(divnamePos).style.left = (divLeft+14) + "px";	
				positionId="right";
			   	 }else{
				 //position to the left
			    // alert("left");
				 
				 var tempDiv=document.getElementById('tooltipHead'+divNumber);
                 tempDivX=findPosX(tempDiv);
				 var tiplength = divLeft-tempDivX;
				// added on 2nd Nov
				 if(((divLeft-scrollBt)-tiplength)<(screenW - (divLeft-scrollBt))){
				  document.getElementById(divnamePos).style.left = (divLeft+10) + "px";
				  positionId="right";
				 }else {
			     /* browser compatibility */
				 //alert(document.getElementById(divnamePos).id);
				 document.getElementById(divnamePos).style.left = ((divLeft-tiplength-415)) + "px";
				  positionId="left";
				 }
				 // end 2 nd Nov
		         }
			
			    if((screenH - divTop) > 500 ){
				//position to the TOP
			   //alert("bottom");
		       if(boxHeight>440){
					  var tempValue=divTop+480;   // 400 for box as we reduces the height
                      // alert(tempValue+"======"+visibleScreen);
                       if(tempValue>visibleScreen){
					  
					      var tempHeight=tempValue-visibleScreen;
				          document.getElementById(divnamePos).style.top = (divTop - (tempHeight-20)) + "px";
					      }else{
		                        var tempHeight=tooltipY-visibleScreen;
				                document.getElementById(divnamePos).style.top = (divTop - 20) + "px";
					           } 
							   
				  }		   
					else{
                           
						if(tooltipY>visibleScreen){
						var tempHeight=tooltipY-visibleScreen;
						document.getElementById(divnamePos).style.top = (divTop- (tempHeight-20)) + "px";
						
						}else {
                           
						document.getElementById(divnamePos).style.top = (divTop - 20) + "px"; 
						
						}
				
			        }

				//document.getElementById(divnamePos).style.top = (divTop - 200) + "px";
				//document.getElementById(arrowDiv).style.top = 200 + "px";
			    }else{
				//position to the Bottom
				//document.getElementById(divnamePos).style.top = '500px';
				//alert("top");
                 if(boxHeight>440){
					  var tempValue=divTop+480;   // 400 for box as we reduces the height
                       //alert(tempValue+"======"+(visibleScreen));
                       if(tempValue>(visibleScreen)){
					      
					      var tempHeight=tempValue-visibleScreen;
					
				          document.getElementById(divnamePos).style.top = (divTop - (tempHeight-20)) + "px";
					      }else{
							
		                        var tempHeight=tooltipY-visibleScreen;
				                document.getElementById(divnamePos).style.top = (divTop - 20) + "px";
					           } 
							   
				  }		   
					else{
                          
						if(tooltipY>visibleScreen){
						var tempHeight=tooltipY-visibleScreen;
					
						document.getElementById(divnamePos).style.top = (divTop- (tempHeight - 10)) + "px";
						 
						}else {
					
						document.getElementById(divnamePos).style.top = (divTop - 20) + "px"; 
						 
						}
				
			        }

				//document.getElementById(divnamePos).style.top = (divTop + 200) + "px";
			    //document.getElementById(arrowDiv).style.top = (divTop-200) + "px";
			   }
         }
		
		if(positionId=="top"){
		//alert("arrtop");
			document.getElementById(arrowDiv).style.left= 190 + "px";
			if(document.all) {
				
				document.getElementById(arrowDiv).style.top = (cntHeight+7) + "px";
				document.getElementById(arrowDiv).style.backgroundImage = 'url(/system/css/arrow.gif)'; 
				
			}
			else {
				
				document.getElementById(arrowDiv).style.top = (cntHeight+7) + "px"; 
				document.getElementById(arrowDiv).style.backgroundImage = 'url(/system/css/arrowff.gif)'; 
								
			}
			 
			document.getElementById('arrow').style.width = '27px';
			document.getElementById('arrow').style.height = '21px';			
			document.getElementById('cntxtHlpBgId').style.height= (cntHeight-10) + "px";
		
		} else if(positionId=="right"){
		//alert("right");
		
		document.getElementById(arrowDiv).style.left= -18+ "px";
		if(boxHeight>440){
					  var tempValue=divTop+440;   // 400 for box as we reduces the height
                     //  alert(tempValue+"======"+visibleScreen);
                       if(tempValue>visibleScreen){
					   //  alert("tooltip out of visible area");
					      var tempHeight=tempValue-visibleScreen;

				          document.getElementById(arrowDiv).style.top = (tempHeight + 15) + "px";
					      }else{
		                        var tempHeight=tooltipY-visibleScreen;
					
				                document.getElementById(arrowDiv).style.top = 15 + "px";
					           } 
							   
				  }		   
					else{

						if(tooltipY>visibleScreen){
						var tempHeight=tooltipY-visibleScreen;
						
                        document.getElementById(arrowDiv).style.top = (tempHeight - 15) + "px";
						
						}else {
							
						document.getElementById(arrowDiv).style.top = 15 + "px"; 
						
						}
				
			        }

		document.getElementById(arrowDiv).style.backgroundImage = "url(/system/css/arrow_lt_1.gif)"; 
		
			document.getElementById('arrow').style.width = '21px';
			document.getElementById('arrow').style.height = '27px';
        document.getElementById('cntxtHlpBgId').style.height= (cntHeight-10) + "px";
		}
		else if(positionId=="left"){
		//alert("left");
		document.getElementById(arrowDiv).style.left= 400+ "px";
		
		if(boxHeight>440){
					  var tempValue=divTop+440;   // 450 for box as we reduces the height
                      // alert(tempValue+"======"+visibleScreen);
                       if(tempValue>visibleScreen){
					     //alert("tooltip out of visible area");
					      var tempHeight=tempValue-visibleScreen;
						  //alert(tempHeight);
				            
						  document.getElementById(arrowDiv).style.top = (tempHeight +15) + "px";
					      }else{
							   
		                        var tempHeight=tooltipY-visibleScreen;
				                document.getElementById(arrowDiv).style.top = 15 + "px";
					           } 
							   
				  }		   
					else{

						if(tooltipY>visibleScreen){
						var tempHeight=tooltipY-visibleScreen;
				
                        document.getElementById(arrowDiv).style.top = (tempHeight - 15) + "px";
						
						}else {
							
						document.getElementById(arrowDiv).style.top = 15 + "px"; 
						
						}
				
			        }
		document.getElementById(arrowDiv).style.backgroundImage = "url(/system/css/arrow_rt_1.gif)";
		
			document.getElementById('arrow').style.width = '21px';
			document.getElementById('arrow').style.height = '27px'; 
		document.getElementById('cntxtHlpBgId').style.height= (cntHeight-10) + "px";
        }
		
		
		
}


function closediv()
{           
	       //pausecomp(500);
            //document.getElementById('tooltipBox').display = "none";
			//document.getElementById('toolTip').display = "none";
			document.getElementById('copays').style.display = "none";
			document.getElementById('tooltipHead'+currShow).className = 'tooltipHead';
             // var delayed=setTimeout('closeChildFunction()',500);  
			
			
}


function closeChildFunction(){
pausecomp(500);
document.getElementById('tooltipHead'+currShow).className = 'tooltipHead';
document.getElementById('copays').style.display = "none";

}

function closeTooltip(closeId)
{           
	      
			//document.getElementById('tooltipBox').display = "none";
			//document.getElementById('toolTip').display = "none";
            //var delayed=setTimeout('closeChildFunction()',500);
			document.getElementById('tooltipHead'+currShow).className = 'tooltipHead';
			document.getElementById('copays').style.display = "none";
	
}


function initTooltip(){

        
		var spans=document.getElementsByTagName('span');
		
		spanCounterOne=1;
        spanCounterTwo=1;
		for(var no=0;no<spans.length;no++){

            if(spans[no].className=='tooltipHead'){

               spans[no].id='tooltipHead'+spanCounterOne;
             spans[no].onmouseover=showdiv;
			  
			  
			  
			  // for ddelayed result

			 /* spans[no].onmouseover= function() {
		delayhide=setTimeout('showdiv('+window.event+','+spans[no]+')',500);
		}*/
			  
			  
			  spans[no].onmouseout =closediv;
              
			   spanCounterOne++;
			}

            if(spans[no].className=='tooltipBody'){
					
               spans[no].id='tooltipBody'+spanCounterTwo;
              // spans[no].onmouseover=showdiv;
               //spans[no].onmouseout=closediv; 
			   spanCounterTwo++
			}

		}

        var divs=document.getElementsByTagName('div');
		var divCounter=1;
		for(var no=0;no<divs.length;no++){

            if(divs[no].className=='tooltipContent'){

               divs[no].id='tooltipContent'+divCounter;
               
			   divCounter++;
			}

		}

              if(document.getElementById('copays')){
        var tooltipContainer=document.getElementById('copays');
		//  tooltipContainer.onmouseover=showdiv;
		//tooltipContainer.onmouseout=closediv;
		tooltipContainer.onmouseover = function() {
		showTooltip(currShow);
		}
		tooltipContainer.onmouseout=closeTooltip;

		 //for delayed result
		/*tooltipContainer.onmouseout = function() {
		delayhide=setTimeout('closeTooltip(' + currShow + ')',8500);
		}*/
		//document.getElementById('tooltipCloseBox').onclick=closediv;
		document.getElementById('tooltipCloseBox').onclick=closediv;
			  }
}

function getWindowSize() {
if( (typeof( window.innerWidth ) == 'number') || ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) ) {
    //Non-IE
    myWidth = document.body.clientWidth;
    myHeight =document.body.clientHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 4 in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  }
  /*else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 6+ compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  */
}



