﻿// JScript File
// begin absolutely positioned scrollable area object scripts 
function verifyCompatibleBrowser()
{ 
    this.ver=navigator.appVersion ;
    this.dom=document.getElementById?1:0 ;
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
    this.ie4=(document.all && !this.dom)?1:0; 
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
    this.saf=(this.ver.indexOf("Safari")>-1)?1:0;
    this.ns4=(document.layers && !this.dom)?1:0; 
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) ;
    return this ;
}
 
bw=new verifyCompatibleBrowser() ;
 
var speed=1 ;
 
var step = 20;

var count = 20;
 
function ConstructObject(obj,nest)
{ 
    nest=(!nest) ? '':'document.'+nest+'.' ;
    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
    this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight;
    this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight;
    this.scrollWidth=bw.ns4?this.css.document.width:this.el.offsetWidth;
    this.clipWidth=bw.ns4?this.css.clip.width:this.el.offsetWidth;
    this.left=MoveAreaLeft;this.right=MoveAreaRight;
    this.MoveArea=MoveArea; this.x; this.y; 
    this.obj = obj + "Object" ;
    eval(this.obj + "=this") ;
    return this ;
}
 
function MoveArea(x,y)
{ 
    this.x=x;
    this.y=y ;
    this.css.left=this.x+"px";
    this.css.top=this.y+"px";
} 

function MoveAreaRight(move)
{
    var datalist=document.getElementById(datalistproductID);
	if(this.x>objContainer.clipWidth-datalist.offsetWidth)
	{
	    var img=document.getElementById("imgLeft");
	    img.style.display="block";
        this.MoveArea(this.x-step,this.y) ;
        if(count < move) 
        {
            if (count + step > move)
                step=move-count;
            count+=step;
            setTimeout(this.obj+".right("+move+")",speed) ;
        }
        else
        {
            step=20;
            count=20;
        }
	}
	else
	{
	    var img=document.getElementById("imgLeft");
	    img.style.display="none";
	    this.MoveArea(0,this.y) ;
	    step=20;
	    count=20;
	}
} 

function MoveAreaLeft(move)
{ 
	if(this.x<0)
	{ 
	    var img=document.getElementById("imgLeft");
	    img.style.display="block";
        this.MoveArea(this.x+step,this.y) ;
        if(count < -move) 
        {
            if (count+step>-move)
                step=-move-count;
            count+=step;
            setTimeout(this.obj+".left("+move+")",speed) ;
        }
        else
        {
            step=20;
	        count=20;
        }
        if(this.x>=0)
        {
            var img=document.getElementById("imgLeft");
	        img.style.display="none";
        }
	}
	else
	{
	    step=20;
	    count=20;
	}
} 

function PerformHorizontalScroll(speed)
{ 
	if(initialised)
	{ 
		if(speed>0) 
		{ 
		    objScroller.right(speed);
		}
		else 
		{
		    objScroller.left(speed);
		}
	}
}  

var initialised; 
var datalistproductID;
function InitialiseScrollableArea(DLProductID)
{ 
    datalistproductID=DLProductID;
    objContainer=new ConstructObject('dvContainer') ;
    objScroller=new ConstructObject('dvContent','dvContainer') ;
    objScroller.MoveArea(0,0) ;
    objContainer.css.visibility='visible' ;
    initialised=true; 
    var img=document.getElementById("imgLeft");
    img.style.display="none";
} 

var a=1;
var ab="#F4F4F4",bb="#ffffff"

/* HomePageRates.js */
// JScript File

var _animation = null;
var FlagDivStr = null;
var tableStr = null;
var ddlLocRates = null;

function SetRates(ddlLoc_Rates,tblStr,flagDvStr)
{
    ddlLocRates = ddlLoc_Rates;
    var val = ddlLoc_Rates.options[ddlLoc_Rates.selectedIndex].value.split('@');
    var rates = document.getElementById(tblStr);
    FlagDivStr = flagDvStr;
    if (rates == null)
       return;
    tableStr = tblStr;
    RunFlagAnimation();
    
    if (ddlLoc_Rates.selectedIndex >= 0) 
    {
       var num = 5;
       for (var i=0;i<rates.rows[1].cells.length;i++)                //calculate new rate 
       {
           rates.rows[0].cells[i].innerHTML = val[4].replace("99", num);
           rates.rows[1].cells[i].innerHTML = Math.floor((num*100 - parseFloat(val[5].replace(",",".")))/parseFloat(val[1].replace(",","."))) +" min";
           num = 2*num;
       }
    }
}

function RunFlagAnimation()
{
    _animation = new Sys.Preview.UI.Effects.CompositeAnimation();
    _animation.get_animations().add(fadeOut(FlagDivStr));
    _animation.get_animations().add(fadeOut(tableStr));
    _animation.play();
    
    var timer = new Sys.Preview.Timer();
    timer.initialize();
    timer.set_enabled(true);
    timer.set_interval(500);
    timer.add_tick(ProceedFlagAnimation);
    
}

function ProceedFlagAnimation(sender)
{
    if (_animation!=null && !_animation.get_isPlaying())
    {
        sender.set_enabled(false);              // Disable the timer
        var FlagDiv = document.getElementById(FlagDivStr);
        var val = ddlLocRates.options[ddlLocRates.selectedIndex].value.split('@');
        FlagDiv.style.backgroundImage = "url(" + val[0] + ")";
        FlagDiv.innerHTML = ddlLocRates.options[ddlLocRates.selectedIndex].text + "<br/><b>" + val[2] + "</b>";
        _animation = new Sys.Preview.UI.Effects.CompositeAnimation();
        _animation.get_animations().add(fadeIn(FlagDivStr));
        _animation.get_animations().add(fadeIn(tableStr));
        _animation.play();
        
    }
}

function SetRedirect(urlTemplate)
{
    var ddlFlag=document.getElementById("Slct1");
    var name=ddlFlag.options[ddlFlag.selectedIndex].text;
    var val = ddlFlag.options[ddlFlag.selectedIndex].value.split('@');
    Redirect(urlTemplate.replace(/1/,val[3]).replace(/template/,UrlEncode(name)));
}

function ClientCallback(result, context)
  {
      var DropDownListLocations = document.getElementById(context);
      DropDownListLocations.disabled=true;
      if (!DropDownListLocations)
      {
          return;
      }
      DropDownListLocations.length = 0;
      if (!result)
      {
          return;
      }
     
      var rows = result.split('|'); 
      for (var i = 0; i < rows.length-1; ++i)
      {
           var values = rows[i].split('^');
           var option = document.createElement("option");
           option.value = values[0];
           option.innerHTML = values[1];   
           DropDownListLocations.appendChild(option);
      }
      DropDownListLocations.disabled=false;
  }
  
function opentour()
{
    var centerWidth = (window.screen.width - 781) / 2;
    var centerHeight = (window.screen.height - 660) / 2;

    window.open('/virtualtour/movie.html','tour','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=781,height=660,left='+centerWidth+'px,top='+centerHeight+'px;');
}

function getRates(ddlLoc_Rates)
{
        if (ddlLoc_Rates.selectedIndex>0) {
            var value = ddlLoc_Rates.options[ddlLoc_Rates.selectedIndex].value;
            var rates =document.getElementById('tblRates').rows[1].cells;
            for (var i=0;i<rates.length;i++)                
            {
                rates[0].innerHTML = value*(i+1);
            }
        }
}
