﻿/*********************************************
			Hide/Show, Enable/Disable functions
**********************************************/
function DisableASPButton(button)
{
    button.disabled = true;
}
function EnableASPButton(button)
{
    button.disabled = false;
}
function HideElement(id)
{
    var element = document.getElementById(id);
    if (element != null) element.style.display = "none";
}
function ShowElement(id)
{
    var element = document.getElementById(id);
    if (element != null) element.style.display = "block";
}

/*********************************************
			Collapsible panel
**********************************************/
function CollapsePanel(panelId, collapseBtnId, expandBtnId)
{
    var panel = document.getElementById(panelId);
    if (panel != null)
    {
        panel.style.width = "0px";
    }
    
    ShowElement(expandBtnId)
    HideElement(collapseBtnId);
    
    setCookie("CollapsiblePanelWidth", 0);
}
function ExpandPanel(panelId, collapseBtnId, expandBtnId, width)
{
    var panel = document.getElementById(panelId);
    if (panel != null)
    {
        panel.style.width = width + "px";
    }
    
    ShowElement(collapseBtnId)
    HideElement(expandBtnId);
    
    setCookie("CollapsiblePanelWidth", width);
}
function SetPanelState(panelId, collapseBtnId, expandBtnId)
{
    var panel = document.getElementById(panelId);
    var panelWidth = getCookie("CollapsiblePanelWidth");
    
    if (panelWidth != null)
    {
        if (panelWidth <= 0)
        {
            ShowElement(expandBtnId)
            HideElement(collapseBtnId);
            
            if (panel != null)
            {
                panel.style.width = "0px";
            }
            setCookie("CollapsiblePanelWidth", 0);
        }
        else
        {
            ShowElement(collapseBtnId)
            HideElement(expandBtnId);
            
            if (panel != null)
            {
                panel.style.width = panelWidth + "px";
            }
        }
    }
}

/*********************************************
			Cookie
**********************************************/
function setCookie(name, value, expiredays)
{   
    document.cookie = name + "=" + escape(value) + ";path=/";
}
function getCookie(name)
{
    if (document.cookie.length > 0)
    {
        var start = document.cookie.indexOf(name + "=");
        if (start != -1)
        { 
            start = start + name.length + 1; 
            var end = document.cookie.indexOf(";", start);
            if (end == -1) end = document.cookie.length;
            return unescape(document.cookie.substring(start,end));
        }
    } 
    return null;
}

/**********************************
        Confirm Dialog
***********************************/
function confirmDialog(message) 
{
    if (confirm(message) == true) 
    {
        return true;
    }
    else 
    {
        if (window.event != null) 
        {
            window.event.returnValue = false;
        }
        return false;
    }
}

var callControl;
var popupPanel;

function showPanel(source) {
    if(Page_ClientValidate())
    {
    this.callControl = source;
    this.popupPanel = $find('mdlPopup');
    this.popupPanel.show();
    }
}

function showPanelWithoutValidation(source)
{
    this.callControl = source;
    this.popupPanel = $find('mdlPopup');
    this.popupPanel.show();
}
function On_OK() {
    this.popupPanel.hide();
    __doPostBack(this.callControl.name, '');
}

function On_Cancel() {
    this.popupPanel.hide();
    this.callControl = null;
    this.popupPanel = null;
}

/**********************************
        Panel Visible
**********************************/
/*****************************************************************
Slowlly collapse/expand steps
********************************************************************/
function onClickDiv(div_id) {
    if (document.getElementById(div_id).style.display == 'block') {
        
        hide_div(div_id);
    }
    else {
    
        show_div(div_id);
   }
}

function hide_div(div_id, img_id, img_id_hide) {
    $("#" + div_id).slideUp();
    
    var imgTag = document.getElementById(img_id);
    var imgTag_hide = document.getElementById(img_id_hide);
    imgTag.style.display = 'inline';

    imgTag_hide.style.display = 'none';
}

function show_div(div_id, img_id, img_id_hide) {
    $("#" + div_id).slideDown();
    var imgTag = document.getElementById(img_id);
    var imgTag_hide = document.getElementById(img_id_hide);
    
    imgTag.style.display = 'none';
    
    imgTag_hide.style.display = 'inline';
}


function collapse_All(btnId) {
    hide_div('divStep1','imgStep1','imgStep1_hide');
    hide_div('divStep2','imgStep2', 'imgStep2_hide');
    hide_div('divStep3', 'imgStep3', 'imgStep3_hide');
    hide_div('divStep4', 'imgStep4', 'imgStep4_hide');
    hide_div('divStep5', 'imgStep5', 'imgStep5_hide');
    hide_div('divStep6', 'imgStep6', 'imgStep6_hide');
    hide_div('divStep7', 'imgStep7', 'imgStep7_hide');
    }


    function expand_All(btnId) {
        show_div('divStep1', 'imgStep1', 'imgStep1_hide');
        show_div('divStep2', 'imgStep2', 'imgStep2_hide');
        show_div('divStep3', 'imgStep3', 'imgStep3_hide');
        show_div('divStep4', 'imgStep4', 'imgStep4_hide');
        show_div('divStep5', 'imgStep5', 'imgStep5_hide');
        show_div('divStep6', 'imgStep6', 'imgStep6_hide');
        show_div('divStep7', 'imgStep7', 'imgStep7_hide');   
}

/***********************************************************
Left Expand/Collapse
*************************************************************/



function left_toggle_div(menuDivId) {
    
    
  
    if (document.getElementById(menuDivId).style.display == 'none')
        {
       
            $("#" + menuDivId).animate({ width: "show" }, "slow");
            setCookie("CollapsibleLeftMenu", 1);
            // alert(getCookie("CollapsibleLeftMenu"));
            //alert("show");
        }
    else{ 
    
            $("#" + menuDivId).animate({ width: "hide" }, "slow");
             setCookie("CollapsibleLeftMenu", 0);
              //alert(getCookie("CollapsibleLeftMenu"));
            //alert("hide");
        }
    
    
    
 //$("#" + menuDivId).slideToggle(700);
}


function load_page_div_down(){

    var MenuState = getCookie("CollapsibleMenuItem");
    if (MenuState == 'Ukrain' || MenuState == 'null')
    {
        $('#Ukrain').slideDown("slow");
        
    }else if(MenuState == 'OtherCountries')
    {
        $('#OtherCountries').slideDown("slow");
        
    }else if(MenuState=='Child')
    {
        $('#Child').slideDown("slow");
        
    }else if(MenuState=='Teach')
    {
        $('#Teach').slideDown("slow");
        
    }else if(MenuState=='Cars')
    {
        $('#Cars').slideDown("slow");
    } else if (MenuState == 'divHotTravel') 
    {
        $('#divHotTravel').slideDown("slow");
    }
    
    var menuImgHome = new Image();
    menuImgHome.src = "../App_Themes/images/TopMenu/Home.png";
     var menuImgHomeSelect = new Image();
    menuImgHome.src = "../App_Themes/images/TopBunner/SelectHome.png";
     var menuImgAgency = new Image();
    menuImgHome.src = "../App_Themes/images/TopBunner/Agency.png";
     var menuImgAgencySelect = new Image();
    menuImgHome.src = "../App_Themes/images/TopBunner/SelectAgency.png";
    var topBunner = new Image();
    topBunner.src = "../App_Themes/images/TopBunner/bunner.png";


     var divPict = document.getElementById('divShowLargePict');
   
   
    $(divPict).animate({ opacity: '0' }, 300);
   var systemDiv = document.getElementById('systemDiv');
    $(systemDiv).animate({ opacity: '0' }, 300);
    
    
}

function top_down_div(){
    var MenuState = getCookie("CollapsibleMenuItem");
   //alert(MenuState);
    if(MenuState == 0 || MenuState==null){
    //alert(getCookie("CollapsibleMenuItem"));
        $('#divForeign').slideDown("slow");
        $('#divUkrain').slideDown("slow");
        setCookie("CollapsibleMenuItem", 1);
        
    }else if(MenuState == 1 ){
    //alert(getCookie("CollapsibleMenuItem"));
        $('#divForeign').slideUp("slow");
        $('#divUkrain').slideUp("slow");
    setCookie("CollapsibleMenuItem", 0);
    
}
}

function top_up_div(divId){

var item = document.getElementById('pane');

if(item.style.display == 'none'){
    $('#pane2').animate({ opacity: "show" }, "slow");
    $('#pane').animate({ height: "show" }, "slow");
    
}else {
    $('#pane').animate({ height: "hide" }, "slow");
    $('#pane2').animate({ opacity: "hide" }, "slow");
    
}
}


// Get the width of the outermost container div.
var getWidth = $('#container').width();

// When you click a link with the "shiftleft" class,
// slide the "shifter" div to the left by an amount
// equal to the width of one pane.
$('a.shiftleft').click(function() {
    $('#shifter').animate({ left: -getWidth }, 500);
    return false;
});
// Slide the whole works back into its original position
// when you click the "shiftright" link.
$('a.shiftright').click(function() {
    $('#shifter').animate({ left: 0 }, 500);
    return false;
});



// Get the width of the outermost container div.
var getWidth = $('#container').width();

// Set a global variable to keep track of how far
// the "shifter" should be moved.
var setWidth = 0;

// Subtract the pane width from the amount by which
// the "shifter" has already been moved.
// Don't forget to give back the changed setWidth variable!
$('a.shiftleft').click(function() {
    setWidth = setWidth - getWidth;
    $('#shifter').animate({ left: setWidth }, 500);
    return false;
});
// Same thing in reverse.
$('a.shiftright').click(function() {
    setWidth = setWidth + getWidth;
    $('#shifter').animate({ left: setWidth }, 500);
    return false;
});

   
function opacity(){
   

              $("#pane").animate({ opacity: "hide" }, "slow");
   
          }
   
    function delayer()  
    {
        
        window.location="/Default.aspx";
    }
    
    function warningRedirect()
    {
        window.location="/Content/ErrorPages/Warning.aspx";
    }
    
    function agencyRedirect()
    {
        window.location="/Content/Agents.aspx";
    }
   
/********************************************************************
*******************Photo Gallery*************************************
*********************************************************************/
$(document).ready(function(){

	$("h2").append('<em></em>')

	$(".thumbs a").click(function(){
	
		var largePath = $(this).attr("href");
		var largeAlt = $(this).attr("title");
		$("#largeImg").stop().fadeTo(300, 0, function() {  //fade image out
    		$('#largeImg').attr('src',largePath);  //give new image a src attribute
    		
		}).fadeTo("slow", 1);
		
		
		$("h2 em").html(" (" + largeAlt + ")"); return false;
	});
	
});

$(document).ready(function(){

	$("h2").append('<em></em>')

	$(".thumbs a").mouseover(function(){
	
		var largePath = $(this).attr("href");
		var largeAlt = $(this).attr("title");
		
		$(this).animate({ opacity: '0.3' }, 300);
		//$(this).fadeTo("slow", 1); 
		
		
		
		
		$("h2 em").html(" (" + largeAlt + ")"); return false;
	});
	
});

$(document).ready(function(){

	$("h2").append('<em></em>')

	$(".thumbs a").mouseout(function(){
	
		var largePath = $(this).attr("href");
		var largeAlt = $(this).attr("title");
		
		$(this).animate({ opacity: '1' }, 300);
		
		
		
		
		
		$("h2 em").html(" (" + largeAlt + ")"); return false;
	});
	
});


$(document).ready(function(){  

    $(".thumb a").click(function(){
     alert("weq");
    var largePath = $(this).attr("href");
		var largeAlt = $(this).attr("title");
			var imgHref = $(this).attr('href');  //get the src of the thumbnail
    		$(".thumb a").removeClass("selected");  //remove .selected class from all other links
    		$(this).addClass("selected");  //add .selected class to current link
			$(".big").stop();
		$(".big").stop().fadeTo(700, 0, function() {  //fade image out
    		$('.big').attr('src',imgHref);  //give new image a src attribute
    		
		}).fadeTo("slow", 1);  //fade the image in
	},function(){    //for onmouseout not used here
	});
	
	
});


function top_down_div(id){
    var MenuState = getCookie("CollapsibleMenuItem");



        $('#divHotTravel').slideUp("slow");
        $('#Ukrain').slideUp("slow");
        $('#OtherCountries').slideUp("slow");
        $('#Child').slideUp("slow");
        $('#Teach').slideUp("slow");
        $('#Cars').slideUp("slow");
        $('#Administration').slideUp("slow");
        $('#' + id).slideDown("slow");
    setCookie("CollapsibleMenuItem", id);
    

}

/*$(document).ready(function(){  

    $("#UkrainMain").click(function(){
     alert("weq");
    var MenuState = getCookie("CollapsibleMenuItem");
   //alert(MenuState);
    if(MenuState == 0 || MenuState==null){
    //alert(getCookie("CollapsibleMenuItem"));
       
        $('#Ukrain').slideDown("slow");
        setCookie("CollapsibleMenuItem", 1);
        
    }else if(MenuState == 1 ){
    //alert(getCookie("CollapsibleMenuItem"));
     
        $('#Ukrain').slideUp("slow");
    setCookie("CollapsibleMenuItem", 0);
		
	},function(){    //for onmouseout not used here
	});
	
	
});*/

function changeImage(elem)
{
    var p = document.getElementById('pGallery');
    if (p != null)
    {
        var a = p.getElementsByTagName('a'); 
    }
    
    for (var i = 0; i < a.length; i++)
    {
        if (elem == a[i])
        {
            _img = i;
            break;
        }
    }
    
    
   var largePath = $(elem).attr("href");
		var largeAlt = $(elem).attr("title");
		$("#largeImg").stop().fadeTo(300, 0, function() {  //fade image out
    		$('#largeImg').attr('src',largePath);  //give new image a src attribute
    		
		}).fadeTo("slow", 1);
		
}

function overImage(elem)
{
//alert("asdad");
    $(elem).animate({ opacity: '0.3' }, 300);
}

function outImage(elem)
{
//alert("asasdsaddad");
    $(elem).animate({ opacity: '1' }, 300);
}

 function pause(ms)  
 {  
 var date = new Date();  
 var curDate = null;  
 do { curDate = new Date(); }  
 while(curDate-date < ms);  
 }
 
 function showBigPict(){
 
_img = 0;
 
var divPict = document.getElementById('divShowLargePict');
    divPict.style.display = "block";
     // alert(divPict.style.display);
    var imgPict = document.getElementById('imgShowLargePict');
    var oldPict = document.getElementById('largeImg');
    var xzDiv = document.getElementById('xzDiv');
    xzDiv.style.display = 'block';
    $(xzDiv).animate({ opacity: '1' }, 100);
    $(xzDiv).animate({ width: '520' }, 1000);
    
    //imgPict.src = oldPict.src;
    //$(divPict).animate({ opacity: '0' }, -1);
    $(divPict).animate({ opacity: '0.5' },700);
    
    //$(imgPict).animate({ width: '500' }, 1000);
    //$(imgPict).animate({ height: '384' }, 1000);
  // $(imgPict).slideDown();
  //$(imgPict).animate({ opacity: '0' }, 1);
  $(xzDiv).animate({ height: '414' }, 1000).stop().fadeTo(1, 1, function(){
  // $(imgPict).fadeTo(300, 0, function() {  //fade image out
    		  //give new image a src attribute
    		$(imgPict).attr('src',oldPict.src);
    		$(imgPict).animate({ opacity: '1' }, 300);
    		
    		
		});//.fadeTo("slow", 1);});
		
 }
 
 
 function enterTheSite()
 {
    var divPict = document.getElementById('divShowLargePict');
    divPict.style.display = "block";
    //$(systemDiv).animate({ opacity: '0' }, 10);
    var systemDiv = document.getElementById('systemDiv');
    systemDiv.style.display = 'block';
   
    //$(systemDiv).animate({ width: '520' }, 1000);
    
    $(divPict).animate({ opacity: '0.5' },700).fadeTo(0.5, 0.5, function(){
     $(systemDiv).animate({ opacity: '1' }, 100);
   // $(systemDiv).animate({ opacity: '1' }, 100).stop()
    		
    		
		});
 }
 
 function showVeryBigPict(){
 


var divPict = document.getElementById('divShowLargePict');
    divPict.style.display = "block";
     // alert(divPict.style.display);
    var imgPict = document.getElementById('imgShowLargePict');
    var oldPict = document.getElementById('veryLargeImg');
    var xzDiv = document.getElementById('xzDiv');
    xzDiv.style.display = 'block';
    $(xzDiv).animate({ opacity: '1' }, 100);
    $(xzDiv).animate({ width: '520' }, 1000);
    
    //imgPict.src = oldPict.src;
    //$(divPict).animate({ opacity: '0' }, -1);
    $(divPict).animate({ opacity: '0.5' },700);
    
    //$(imgPict).animate({ width: '500' }, 1000);
    //$(imgPict).animate({ height: '384' }, 1000);
  // $(imgPict).slideDown();
  //$(imgPict).animate({ opacity: '0' }, 1);
  $(xzDiv).animate({ height: '414' }, 1000).stop().fadeTo(1, 1, function(){
  // $(imgPict).fadeTo(300, 0, function() {  //fade image out
    		  //give new image a src attribute
    		$(imgPict).attr('src',oldPict.href);
    		$(imgPict).animate({ opacity: '1' }, 300);
    		
    		
		});//.fadeTo("slow", 1);});
		
 }
 
 function hideAuth()
 {
    var divPict = document.getElementById('divShowLargePict');
    $(divPict).animate({ opacity: '0' }, 300);
    var systemDiv = document.getElementById('systemDiv');
    $(systemDiv).animate({ opacity: '0' }, 300);
    divPict.style.display = 'none';
    systemDiv.style.display = 'none';
 }
 
 function hideLargePict()
 {
    var divPict = document.getElementById('divShowLargePict');
    var imgPict = document.getElementById('imgShowLargePict');
    var xzDiv = document.getElementById('xzDiv');
    $(divPict).animate({ opacity: '0' }, 300);
    $(xzDiv).animate({ opacity: '0' }, 100);
   $(imgPict).animate({ opacity: '0' }, 300);
   
   
   $(xzDiv).animate({ opacity: '0' }, 300).stop().fadeTo(0, 10, function(){
  
    		
    		$(imgPict).animate({ opacity: '0' }, 300);
		divPict.style.display = 'none';
		
		});
		
		xzDiv.style.display = 'none';
		xzDiv.style.height = '0px';
		xzDiv.style.width = '0px';
		
 }
 //var isNextFlag = false;
 //var isPrevFlag = false;
 var _img = 0;
 function changeGalleryImage()
 {
    _img++;
    var imgPict = document.getElementById("imgShowLargePict");
    var p = document.getElementById("pGallery");
    if (p)
    {
        var a = p.getElementsByTagName("a");
        if (_img == a.length)
            _img = 0;
        $(imgPict).stop().fadeTo(700, 0, function() 
        {  //fade image out
            $(imgPict).attr('src',a[_img].href);  //give new image a src attribute
        }).fadeTo("slow", 1);  //fade the image in
    }
 }
 
 //var isStart = true;
 function prevGalleryImage()
 {
    _img--;
    var imgPict = document.getElementById("imgShowLargePict");
    var p = document.getElementById("pGallery");
    if (p)
    {
        var a = p.getElementsByTagName("a");
        if (_img < 0)
            _img = a.length - 1;
        $(imgPict).stop().fadeTo(700, 0, function() 
        {  //fade image out
            $(imgPict).attr('src',a[_img].href);  //give new image a src attribute
        }).fadeTo("slow", 1);  //fade the image in
    }
    /*var imgPict = document.getElementById('imgShowLargePict');
    var p = document.getElementById('pGallery');
    if (p != null){
    var a = p.getElementsByTagName('a');
    if (isStart)
    {
        if (_img == 1)
        {
            _img = _img - 2;
        }else
        {
            _img = _img - 1;
        }
        if (_img < 0)
            _img = a.length - 1;
    }
    isStart = false;
    if (isNextFlag)
    {
        if(_img > 1)
        {
            _img = _img - 2;
        }else
        {
            _img = a.length;
        }
        isNextFlag = false;
    }
    
    if(_img != 0)
    {
    for (var i = a.length; i >= 1 ; i--)
    {
        if (i == _img)
        {
            $(imgPict).stop().fadeTo(700, 0, function() {  //fade image out
    		$(imgPict).attr('src',a[i].href);  //give new image a src attribute
    		
		}).fadeTo("slow", 1);  //fade the image in
	        
            
            break;
        }
    }
    
       }else{
       
       $(imgPict).stop().fadeTo(700, 0, function() {  //fade image out
    		$(imgPict).attr('src',a[0].href);  //give new image a src attribute
    		
		}).fadeTo("slow", 1);  //fade the image in
            
     _img = a.length;
    }
    
    }
    _img--;
    isPrevFlag = true;*/
 }
 
function leftEnter(id)
{
    var  el = document.getElementById(id);
    el.style.display = "block";
    $(el).animate({ width: '100' }, 300);
}
 
 function autoredirect()
 {
 
   
    setTimeout('delayer();',5000);
 }
 
 function redirectToStartPage()
 {
    
 }
 
 function pageLoad()
 {
    load_page_div_down();
 }
 
 function contactRedirect()
 {
    window.location="/Content/Contacts.aspx";
 }
 
 function touristRedirect()
 {
     window.location="/Content/Tourist.aspx";
 }
 
 function aboutUsRedirect()
 {
     window.location="/Content/AboutUs.aspx";
 }
 
