﻿// JScript File



//var x= document.getElementById('ctl00_MSO_ContentDiv');
var x= document.getElementById('tblBackgroundImage'); 
var y= document.getElementById('tblBackgroundImage-shadow');
var blendImg = document.getElementById('blendImage');
//alert('testing from home js');
//x.style.backgroundColor='#e7e7e7';
//document.getElementById('hshome').style.height = '450px';

//x.style.backgroundColor='#e7e7e7';
var duration = 2;
if(!document.all)
{
	//alert('in Firefox');
	y.style.display='block';
	//x.style.display='none';
	x.style.position='relative';
	blendImg.style.position='relative';
	blendImg.style.top='0px';
	blendImg.style.marginTop ='50px';
	x.style.zIndex=0;


}
else
{
    var kk;
	//y.style.display='block';
	//x.style.display='none';
	/*blendImg.style.top='200px';*/
	blendImg.style.marginTop ='50px';
	blendImg.style.display='none';
	

	
	/*blendImg.style.top='98px';*/
	//x.style.zIndex=0;
		//alert(' in IE');
}

function homeimage()
{
	
    switchImage();

}
//Please do not edit below
ads=[]; ct=0;
var firstimageLoad;
firstimageLoad=false;
var isie = false;
function switchImage()
{
	//alert('call first image');
    var n=(ct+1)%src.length;

//------------------------------------------------------------------
if (document.all)
	{
	
	    if (ads[n] && (ads[n].complete || ads[n].complete==null))
	    {
	        if(firstimageLoad ==false)
	        {
		        document.getElementById('hs_image_loading').style.display='none';
		        
	        }
	        //else
	        //{
	        //	document.getElementById('hshomebg').style.backgroundColor='transparent';
	        //}
	
	        //document["bigImage1"].src = ads[ct=n].src;
	        if (document.all)
	        {
	            x.style.filter="blendTrans(duration=2)";
	            x.filters.blendTrans(duration=5).Apply();
	            isie=true;
	        }
	       else
	        {
		        
		        //alert('hi before ');
				x.style.opacity=1;
				x.style.MozOpacity = 1;
				x.style.KhtmlOpacity = 1; 
	
		        if((n+1) < src.length)
		        {
		           	
		        	y.style.background = "url("+src[n+1]+") no-repeat 0 50px";
		
		        }
		        else
		        {
		        	y.style.background = "url("+src[0]+") no-repeat 0 50px";
	
		        }
	   	       
	   	        
	        }
	
	        if (document.all)
	        {
	            x.style.background = "url("+ads[ct=n].src+") no-repeat 0 50px";
	            x.filters.blendTrans.Play();
	        }
	        else
	        {
	 		     //shiftOpacity('tblBackgroundImage',2000);
	   	         //alert('hi after');
	 		     
	 		     //x.style.opacity=1;
	   	        // x.style.MozOpacity = 1; 
			     // x.style.KhtmlOpacity = 1; 
			     //x.style.filter = "alpha(opacity=1")"; 
	   	        opacity('tblBackgroundImage', 100,0, 1000);
	   	        x.style.background = "url("+ads[ct=n].src+") no-repeat 0 50px";
	   	        //ct = n;
	            // setTimeout("fnWait()",6000);
	            // return;
	
	        }
	        firstimageLoad = true;
	
	    }
	   }
	 else
	  {
	  if (ads[n] && (ads[n].complete || ads[n].complete==null))
	    {
	        if(firstimageLoad ==false)
	        {
		        document.getElementById('hs_image_loading').style.display='none';
		        x.style.background = "url("+ads[ct=n].src+") no-repeat 0 50px"; 
		       // y.style.background = "url("+ads[ct=n].src+") no-repeat 0 50px"; 
		       document.getElementById('blendImage').src = ads[ct=n].src;
	        }
		           
	   	   blendimage('tblBackgroundImage','blendImage',ads[ct=n].src,2000)     

	   	   //opacityFF('tblBackgroundImage', 100,0, 1000,n);
	        firstimageLoad = true;
	    }
	  }
 //----------------------------------------------------------------
  
    //var n= (ct+1)%src.length;
    if(isie)
    {
	    ads[n=(ct+1)%src.length] = new Image;
	    ads[n].src = src[n];
	    setTimeout("switchImage()",duration*1000);
    }
    else
    {
        //alert(ads[n]);
        if(ads[n] == null)
        {
	       ads[n=(ct+1)%src.length] = new Image;
	       ads[n].src = src[n];
	       setTimeout("switchImage()",duration*3000);
        }
        else
        {
         	ads[n].src = src[n];
        	setTimeout("switchImage()",duration*3000);
        }
    }
   
}
function fnWait()
{
   var i;
}
function shiftOpacity(id, millisec) { 
    //if an element is invisible, make it visible, else make it ivisible 
   //if(document.getElementById(id).style.opacity == 0) { 
    //opacity('tblBackgroundImage',0,100,1000);
        opacity(id, 100, 0, millisec); 
   //} 
    
   /* else { 
        opacity(id, 100, 0, millisec); 
    }*/ 
}
function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
    //alert('testing in opacity');
    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 
function changeOpac(opacity, id) { 
    
    var object = document.getElementById(id).style; 
    //alert(document.getElementById(id));
    //return;
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

function opacityFF(id, opacStart, opacEnd, millisec,firstindex) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
    //alert('testing in opacity');
    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpacFF(" + i + ",'" + id + "',"+firstindex+")",(timer * speed)); 
            timer++; 
        } 
        
        while(x.style.opacity!=0){}
        
        if(x.style.opacity==0)
    {
    	x.style.background=y.style.background;
    	x.style.opacity=1;
    	if((firstindex+1) < src.length)
		        {
		           	
		        	y.style.background = "url("+src[firstindex+1]+") no-repeat 0 50px";
		
		        }
		        else
		        {
		        	y.style.background = "url("+src[0]+") no-repeat 0 50px";
	
		        }
    
    }

        
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpacFF(" + i + ",'" + id + "',"+firstindex+")",(timer * speed)); 
            timer++; 
        } 
    } 
} 

function changeOpacFF(opacity, id,secondindex) { 
    
    var object = document.getElementById(id).style; 
    //alert(document.getElementById(id));
    //return;
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
  /*  if(x.style.opacity==0)
    {
    	x.style.background=y.style.background;
    	x.style.opacity=1;
    	if((secondindex+1) < src.length)
		        {
		           	
		        	y.style.background = "url("+src[secondindex+1]+") no-repeat 0 50px";
		
		        }
		        else
		        {
		        	y.style.background = "url("+src[0]+") no-repeat 0 50px";
	
		        }
    
    }*/
} 
function blendimage(divid, imageid, imagefile, millisec) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
    //alert('testing ' + imagefile);
    //set the current image as background 
    //document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
    document.getElementById(divid).style.background ="url(" + document.getElementById(imageid).src + ") no-repeat 0 50px"; 
     
    //make image transparent 
    changeOpac(0, imageid); 
     
    //make new image 
    //document.getElementById(imageid).src = imagefile; 
    document.getElementById(imageid).src =imagefile ; 
	//alert(document.getElementById(imageid).src);
    //fade in image 
    for(i = 0; i <= 100; i++) { 
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed)); 
        timer++; 
    } 
} 
//var xx=document.getElementById('homestaytopbar');
//alert(xx)
//xx.style.background="url(http://mhril-hsp:40894/HomeStaySiteImages/Homepage/mh_homepage-top-banner.png)";
//alert(xx.style.background);
