﻿// JScript File
var W3CDOM = (document.createElement && document.getElementsByTagName);
var lastOpenDivId='';
window.onload = init;

var originalClassNameString = "";

function init(){
    // fire " pinball effect " 
    pinballEffect()
}

function pinballEffect()
{
	if (!W3CDOM) return;
	var allElements = document.getElementsByTagName('*');
	var originalBackgrounds=new Array();
	for (var i=0; i<allElements.length; i++)
	{
		if (allElements[i].className.indexOf('pinball-scoop') !=-1)
		{
			allElements[i].onmouseover = mouseGoesOver;
			allElements[i].onmouseout = mouseGoesOut;
			allElements[i].onclick = mouseGoesClick;
		}
	}
}

function mouseGoesOver()
{
	originalClassNameString = this.className;
	this.className += " pinball-on";
	this.style.cursor = "pointer";
	//this.style.cursor = "hand";

}

function mouseGoesOut()
{
	this.className = originalClassNameString;
}

function mouseGoesClick()
{
	var allThisAreasElements = this.getElementsByTagName('*');
	for (var j=0; j<allThisAreasElements.length; j++)
	{
		if (allThisAreasElements[j].className.indexOf('pinball-sinkhole') != -1)
		{
			var url = allThisAreasElements[j].href;
			window.location = url;
		}
	}
}

// check this function in other browsers
function openGalleryWin()
{
var imageWin = window.open('about:blank','imageWin','directories=no,menubar=no,resizable=yes,status=yes,titlebar=no,toolbar=no,top=200,left=200,width=300,height=300')
imageWin.focus()
}

function OpenPopup(url)
{
	window.open(url,'BigPicture','directories=no,menubar=no,resizable=yes,status=yes,titlebar=no,toolbar=no,top=300,left=300,width=300,height=300');
}

function OpenHotelPopup(url)
{
	window.open(url,'HotelpopUp','directories=no,menubar=no,resizable=yes,status=no,titlebar=no,toolbar=no,top=300,left=300,width=606,height=400,scrollbars=no');
}
function OpenReviewPopup(url)
{
	window.open(url,'AddReview','directories=no,menubar=no,resizable=yes,status=yes,titlebar=no,toolbar=no,top=50,left=200,width=790,height=800,scrollbars=yes');
}

//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function sortTbl(o)
{
    var sortUrl         = document.getElementById("ctl00_ContentPlaceHolder1_ModeControl_ucPagingList_sortUrl").value;
    var radio           = document.getElementsByName("ctl00$ContentPlaceHolder1$ModeControl$sort");  
    
    for(var j=0; j<radio.length; j++)
    {
        if(radio[j].checked)    url2(sortUrl+"&SortBy="+radio[j].value+"&SortDir=ASC");
    }
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function url2(url)		{	window.location.href	    = url;		}
function open2(url)		{	window.open(url,"newwin");				}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function visible(o)     {if(o) o.style.visibility 	    = "visible";}
function hidden(o)      {if(o) o.style.visibility	    = "hidden";	}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function disabled(o)    {if(o) o.disabled		 	    = true;	    }
function enabled(o)     {if(o) o.disabled		 	    = false;    }
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function isNone(o)      {if(o){if(o.style.display=="none")	return true; else	return false;} }
function none(o)        {if(o) o.style.display		    = "none";	}
function block(o)       {if(o) o.style.display		    = "block";	}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function blocknone(o)
{	
	try
	{
		if(o)
		{
			if(o.style.display && o.style.display=="block")
			{
					none(o);
			}	
			else	block(o);
		}
	}
	catch(e){ws("blocknone() "+e.description)}
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function imageOff(o){o.src		= o.src.replace(/_on\./gi,"_off.");}
function imageOn(o) {o.src		= o.src.replace(/_off\./gi,"_on.");}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function imageOnOff(o)
{
	try
	{
		if(o && o.src)
		{
			if(o.src.indexOf("_on.")>0)
			{
					imageOff(o);
			}	
			else	imageOn(o);
		}
	}
	catch(e){ws("imageOnOff() "+e.description)}
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function classOff(o){o.className	= o.className.replace(/_on/gi,"_off");}
function classOn(o) {o.className	= o.className.replace(/_off/gi,"_on");}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function CInt(vle, dflt)
{
    var str		= trim(vle);
    var strd	= trim(dflt);
    
	var intg	= parseInt(str,10);
	var intd	= parseInt(strd,10);
	
		intd	= (isNaN(intd)?0:intd);
    
	return (isNaN(intg)?intd:intg);
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function CStr(vle, dflt)
{
       dflt += "";
    if(dflt=="undefined") dflt = "";
    if(dflt=="null")      dflt = "";

       vle += "";
    if(vle=="undefined") return dflt;
    if(vle=="null")      return dflt;
    
    return vle;
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function trim(vle)
{
        var trm = CStr(vle);
    return  trm.replace(/(^\s*)|(\s*$)/g, "");
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function dbg(O)
{
	if(typeof(O)=="string"||typeof(O)=="number"){alert(O);return;}
	
	var arr	=	[];
	
	for(var o in O)
	{
		if(typeof(O[o])=="string"||typeof(O[o])=="number")
		{
				arr.push(o+"='"+O[o]+"' ");
		}
		else	arr.push(o);
	}
	arr.sort();
	alert(arr.join("; "));
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function OpenGeneralPopup(folderid,docid){
    var url = CLVAR.GENERAL_POPUP_URL + (folderid!=null?"&FolderID="+folderid:"") + (docid!=null?"&DocID="+docid:"") 
    window.open(url,'popUp','width=390,height=480,menubar=no,toolbar=no,resizable=yes,status=yes,top=100,left=100')
}

function OpenOrderGeneralPopup(folderid,showCarsConditions){
    var url = CLVAR.GENERAL_POPUP_URL + (folderid!=null?"&FolderID="+folderid:"") + (showCarsConditions?"&Cars=Yes":"") 
    window.open(url,'orderPopUp','width=390,height=480,menubar=no,toolbar=no,resizable=yes,status=yes,top=100,left=100')
}
function OpenHotelPicturesPopup(key,productID,folderID){
    var url = CLVAR.HOTEL_PICTURES_POPUP_URL + "&key=" + key
    if(!isnull(productID)) url = url  + "&productID=" + productID
    if(!isnull(folderID)) url = url  + "&FolderID=" + folderID
    window.open(url,'popUp','width=510,height=480,menubar=no,toolbar=no,resizable=yes,status=yes,top=100,left=100')
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function ElementDimensions(obj){
	
      this.objOffLeft=0;
      
      this.objOffTop=0;
      
      this.objOffWidth=0;
      
      this.objOffHeight=0;

      this.objOffWidth=obj.offsetWidth;

      this.objOffHeight=obj.offsetHeight;

      this.objOffLeft=obj.offsetLeft;

      this.objOffTop=obj.offsetTop;

      var objPar=obj.offsetParent;

      while(objPar){

            obj=objPar;

            this.objOffLeft+=obj.offsetLeft;

            this.objOffTop+=obj.offsetTop;

            objPar=obj.offsetParent;

      }


}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
var openedHotelDiv = null;
function showMore(id,srcID)
{
	var div					= window.document.getElementById(id);
	var src					= window.document.getElementById(srcID);
	
	    src         = new ElementDimensions(src)
	
	if(div) 
	{
		if(openedHotelDiv != null) hideMore(openedHotelDiv)
		
		div.style.display	= "";
		div.style.left = src.objOffLeft + src.objOffWidth - div.offsetWidth
		div.style.top = src.objOffTop + src.objOffHeight
		openedHotelDiv = div
	}
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function hideMore(o)
{
		o.style.display		= "none";
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
// mailing list - start
function JoinToMailingList(email){

    
    var sURL = CLVAR.XMLHTTP_PATH  + "HotelsJoinMailingList.aspx?lang=" + CLVAR.LANG + "&email=" + email
    
    if ( window.XMLHttpRequest ) {
	   pingAJAX = new XMLHttpRequest();
    } else {
	   pingAJAX = new ActiveXObject("MSXML2.XMLHTTP");
    }
    
    pingAJAX.onreadystatechange = MailingListCallback;    
    
    pingAJAX.open( "POST", sURL, true );
    
    pingAJAX.send(null);
}

function MailingListCallback(){
    if ( pingAJAX.readyState == 4) {
		try{
		    var xml = pingAJAX.responseXML
		    //alert(pingAJAX.responseText)
		    //alert(xml.xml)
		    var m = xml.documentElement.getElementsByTagName("MailingList");
		    
		    
		    if (m && m.length > 0) {
		       alert(m[0].getAttributeNode("msg").nodeValue);
		       
		    }
		    else{
		        alert("MailingListCallback : There was a problem retrieving the XML data:\n" + pingAJAX.statusText)
		    }

		}
		catch(e){
		    alert("MailingListCallback : Error : " + e.description );
		}
	}
}
// mailing list - end

function swapDisplay2(obj,id){
		if(document.getElementById(id).style.display=='none')
			{
				document.getElementById(id).style.display='';
				obj.className='order_on';
			}
		else
			{
				document.getElementById(id).style.display='none';
				obj.className='order_off';
			}
	}


var NewsletterFieldCleared = false;
function clearNewsletterField(obj){
    if(NewsletterFieldCleared){
        return;
    }
    
    obj.value="";
    NewsletterFieldCleared = true;
}

function openDestinationsDiv(id)
{

    if (lastOpenDivId != '')
        closeDestinationsDiv(lastOpenDivId);
    document.getElementById(id).style.display='block';
    lastOpenDivId=id;

}
function closeDestinationsDiv(id)
{
    document.getElementById(id).style.display='none';
}

function openCarsDiv(id)
{
    if (lastOpenDivId != '')
        closeCarsDiv(lastOpenDivId);
    document.getElementById(id).style.display='block';
    lastOpenDivId=id;
}
function closeCarsDiv(id)
{
    document.getElementById(id).style.display='none';
}

function ShowTourRoomsRows(rooms)
{

    for(var i = 1 ; i <= rooms; i++)
    {
        var el = document.getElementById(toursClientID+"_divRoomSet" + i);
        if(el) el.className = "toureAccomodationSelect";
    }
    for(var j = (rooms*1 + 1) ; j <= 5; j++)
    {
        var el = document.getElementById(toursClientID+"_divRoomSet" + j);
        if(el) el.className = "undis";
    }
}


function BookNowFromDestination(hotelname,ev,area)
{

    var se = document.getElementById("destSE")
    document.getElementById(seInnerHotelsClientID + "_selHotelName").value=hotelname
    
    try{
        if(!isnull(area)){
            document.getElementById(seInnerHotelsClientID + "_selArea").value=area
        }
    }
    catch(e)
    {
    
    }
    se.style.display='block'
    //alert(document.body.scrollTop)
    
    try{
        calendardiff = event.x - 450
	    se.style.left = event.x - 450;
	    se.style.top =  event.y+document.body.scrollTop-150;
	}
	catch(e){
	    calendardiff = ev.clientX - 450
	    se.style.left = ev.clientX - 450;
	    se.style.top =  ev.pageY - 150//+document.body.scrollTop-150;
//	    //var s = ""
//	    //for(var x in ev){
//	    //    s += x + ":"+ ev[x] + "\n"
//	    //}
//	    //alert(s)
	}
}
function CancelBookNowFromDestination()
{
    var se = document.getElementById("destSE")
    se.style.display='none'
}
function openDiv(id)
{
    var div=document.getElementById(id);
    if(div)
        div.style.display='block';
}

function hideDiv(id)
{

    var divObj=document.getElementById(id);
    if(divObj)
    {
        //alert('found');
        divObj.style.display="none";
        }
        else
        {
        alert('not found');
        }
    
}





function ShowRoomsRowsCU(rooms){
    for(var i = 1 ; i <= rooms; i++)
    {
        var el = document.getElementById(cuClientID + "_trRoom" + i);
        if(el) el.className = "dis";
    }
    for(var j = (rooms*1 + 1) ; j <= 5; j++)
    {
        var el = document.getElementById(cuClientID + "_trRoom" + j);
        if(el) el.className = "undis";
    }
}

function ShowChildAgesCU(childs,room){
    for(var i = 1 ; i <= childs; i++)
    {
        var el = document.getElementById(cuClientID + "_tdChildAge" + room + "" + i);
        if(el) el.className = "vis";
    }
    for(var j = (childs*1 + 1) ; j <= 4; j++)
    {
        var el = document.getElementById(cuClientID + "_tdChildAge" + room + "" + j);
        if(el) el.className = "unvis";
    }
    var maxChild = 0;
    for(var ch=1;ch<=4;ch++)
    {
        var el = document.getElementById(cuClientID + "_selNumberOfChilds" + ch);
        if(el)
        {
            if(el.value>maxChild)
                maxChild = el.value;
        }
    }
    for(var k = 1 ; k <= maxChild; k++)
    {
        var el=document.getElementById("tdChildtitle"+k);
        if(el) el.className = "vis";
    }
    for(var l= maxChild*1+1; l<=4;l++)
    {
        var el=document.getElementById("tdChildtitle"+l);
        if(el) el.className = "unvis";
    }
        
}
function OpenReviewCalendar()
{

    isReview=true;
    objname = txtVisitDateId;
    ShowCalendar(objname,null,null,null,false);
    
}
function ShowWebImage(url)
{
    window.open(url,'reviewImg');
}

function DrawHotelsSE()
{
    var sURL = CLVAR.XMLHTTP_PATH  + "SearchEngineHotels.aspx";
    
    //try{window.clipboardData.setData("Text",sURL);}catch(e){};
    
    
    if ( window.XMLHttpRequest ) 
    {
	   HotelsSE_AJAX = new XMLHttpRequest();
    }
    else 
    {
	   HotelsSE_AJAX = new ActiveXObject("MSXML2.XMLHTTP");
    }
    
    HotelsSE_AJAX.onreadystatechange = HotelsSECallback;  
    
    HotelsSE_AJAX.open( "GET", sURL, true );
    
    HotelsSE_AJAX.send(null);

}

function HotelsSECallback()
{

    if ( HotelsSE_AJAX.readyState == 4) 
    {

        try{
            var content = HotelsSE_AJAX.responseText

            var contentArr = content.split("~~~")

            content = contentArr[1]
            //try{window.clipboardData.setData("Text",content);}catch(e){};
            //alert(content);
            var obj = document.getElementById("divHotelsSE")
            if(obj);
            if(content!=''){
                obj.style.display='inline'
                obj.innerHTML = content;
            }

        }
        catch(e){
            alert('Err:' + e.description)
        }
    }
}
