﻿var background;
var popUp;
var currentPicture = 0;
var screenHeight;
$(function(){
    background = $("#background");
    popUp = $("#pop-up");
    
    if (document.documentElement.clientHeight > document.body.clientHeight)
    {
        screenHeight = document.documentElement.clientHeight;
    }
    else
    {
        screenHeight = document.body.clientHeight + 20;
    }
    
    // Lighting the current link
    $("a").each(function()
    {
        if (document.URL.indexOf($(this).attr("href")) != -1)
        {
            $(this).addClass("red");
        }
    });
});

id = function(o)
{
	return document.getElementById(o);
}

px = function (x)
{
	return ''.concat(Math.round(x), 'px');
}

function Contains(Father, Child)
{
	// We climb through Child parents till we find Father
 	while(Child && (Father!=Child) && (Child!=null))
		Child = Child.parentNode;
	return Father == Child;
}

// JScript File
function DefaultButton(button)
{
    if(event.which || event.keyCode)
    {
        if ((event.which == 13) || (event.keyCode == 13)) 
        {
            id(button).click();
            return false;
        }
    }
    else 
    {
        return true;
    }
}

function ShowBackground()
{
    //background.css("height", $("html").height());
    background.css("height", screenHeight);
    background.show().css('opacity',0).fadeTo("slow", 0.60);
}

function HideBackground()
{
    background.fadeOut("slow");
}

function ShowPopUp(text)
{
    var width  = popUp.width();
    var height = popUp.height();
    //var left   = ($("html").width()  - width)/2;
    //var top    = ($("html").height() - height * 2)/2;
    var left   = (screen.width  - width)/2;
    var top    = (screenHeight - height)/2;
    
    popUp.find("div").html(text);
    popUp.fadeIn("slow");
    
    popUp.css("left", left);
    popUp.css("top", top);
}

function HidePopUp()
{
    if (popUp.css("display")=="block")
    {
        popUp.fadeOut("slow");
    }
}

$.fn.print = function() 
{
    top.printRef=window.open('','Print',
      'width=1,height=1'
       +',menubar=0'
       +',toolbar=0'
       +',status=0'
       +',scrollbars=0'
       +',resizable=0');
       
    top.printRef.document.writeln(
      '<html><head><title>Printing...</title></head>'
       +'<body bgcolor=white onLoad="window.print(); self.close();">'
       +this.html()
       +'</body></html>');
     top.printRef.document.close();
}

function ShowPopUpInfo(id)
{
    $(".PopUpInfo").hide();
    $("#"+id).show();
}

function HidePopUpInfo()
{
    $(".PopUpInfo").hide();
}


function SelectSaleCategory(SaleCategoryID)
{ 

    var catg, Lang, url, saleId;
    url = location;
    var url = url.toString() 
    //alert(location); //== alert(location.href);
    //alert(location.pathname);
    catg = url.indexOf("catg");
    Lang = url.indexOf("Lang");
    page = url.indexOf("page");
    saleId = url.indexOf("SaleID");
    if (saleId != -1)
    {
        url = url.substring(0, saleId -1);
    }
    if (catg != -1)
    {
       url = url.substring(0, catg - 1);
    }
    if ((Lang != -1) || (page!= -1))
    {
       window.location = url + "&catg=" + SaleCategoryID;
    } 
    else
    {
       window.location = url + "?catg=" + SaleCategoryID;
    }    
    
}


function marking(Page)
{
    alert(document.getElementById("Num"+Page));
    alert(document.getElementById("Num"+(Page + 1)));
    document.getElementById("Num"+Page).style.color = '#2A2B64';
    document.getElementById("Num"+Page).style.fontWeight = 'bold';
    document.getElementById("Num"+Page).style.fontSize = '14px';
}

function ChangePictureHotelsAndSites(Id)           
{
    document.getElementById("PictureCity").src = document.getElementById("PictureCity" + Id).src;
}

function NextPicture()
{
  newCurrent = currentPicture + 1;
  if (document.getElementById("PictureCity" + newCurrent) != null)
  {
    document.getElementById("PictureCity").src = document.getElementById("PictureCity" + newCurrent).src;
    currentPicture = currentPicture + 1;
  }  
}

function PrevPicture()
{
  newCurrent = currentPicture - 1;
  if (document.getElementById("PictureCity" + newCurrent) != null)
  {
    document.getElementById("PictureCity").src = document.getElementById("PictureCity" + newCurrent).src;
    currentPicture = currentPicture - 1;
  }  
}

function ClosePopUp(NumberOfGrid)
{
  document.getElementById("Grid" + NumberOfGrid).style.display = "none";
}

function ExecuteShow(id, CityName)
{
   __doPostBack("HotelID", id);  
}
function ExecuteHide()
{
   document.getElementById("PopUpPicture").style.display = "none";
}

//  function Exe(id)
//  {
//     window.open('BannerGen.aspx?id_QueryString='+id,'mywindow','width=400,height=200,left=0,top=100,screenX=0,screenY=100')         
//  }
//  
function ClickerBanner(Link)
{
   window.open(Link);
   //__doPostBack("BannerID",BannerID + "-" + TypeBannerID) ;
   //Page.GetPostBackClientEvent();
}

function ClickerDefaultPage()
{
   window.location = "default.aspx";
}
  
//  onmousedown="ClickerBanner(<%=id%>, <%=TypeBanner%>);"
//  onmousedown="ClickerBanner(<%=id%>, <%=TypeBanner%>);">