﻿/********************************************************************/
/* eSKuryr                                                          */
/********************************************************************/

var sPocet = 1; // pocet kusu pri zadavani udaju o preprave

function HelpPage(HelpContext)
{
	var target = 'help';
	var newHeight;
	if (HelpContext=='FULL') {target='helpfull'}
     // nastaveni vysky okna	
	 switch (HelpContext) {
        case "SEARCHREL":
                newHeight = 410;
                break;
        case "TRANSLIST":
                newHeight = 455;
                break;
        case "TICKETFORMKURYR":
                newHeight = 660;
                break;
        case "TICKETSHOW":
                newHeight = 270;
                break;
        case "TICKETSAVE":
                newHeight = 260;
                break;
        case "HISTORY":
                newHeight = 260;
                break;
        case "TICKETHISTORY":
                newHeight = 220;
                break;
        case "CHANGEPROFILE":
                newHeight = 500;
                break;
        case "REGISTRATION":
                newHeight = 550;
                break;
        case "ACTIVATION":
                newHeight = 350;
                break;
        case "LOGIN":
                newHeight = 375;
                break;
        case "LOSTPASSWORD":
                newHeight = 330;
                break;
        case "FULL":
                newHeight = 600;
                break;                
        default:
                newHeight = 500;
    }
    	
      window.open("help.aspx?cnt="+HelpContext, target, "height=" + newHeight + ",width=668,left=0,top=0,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes");
    return false;
}

function FAQPage()
{
	window.open("faq.aspx", "faq", "height=650,width=668,left=0,top=0, location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes");
    return false;
}

function StatPage(iCacheStationIndex)
{
    var w = 550;
    var h = 200;
    var left = (window.screen.width - (w + 60)) / 2;
    var top =  (window.screen.height - (h + 80)) / 2;	
	window.open("StationDetail.aspx?s=" + iCacheStationIndex, "StationDetail", "height=" + h+ ",width=" + w + ",left=" + left + ",top=" + top + ", location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes");
    return false;
}

function Print()
{
    try { window.print(); } catch(e) {}
    return false; 
}

function SetFocus(itemName) {
	oItem = document.getElementById(itemName);
	if (oItem) {oItem.focus();}
}

function SetFocusArr(itemNames) {
	for (var i = 0; i < itemNames.length; i++) {
		oItem = document.getElementById(itemNames[i]);
		if (oItem && !oItem.disabled) {oItem.focus(); return;}
	}
}

// clsHelper
function CheckEnterClick(button, event) {
	if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {
		event.returnValue=false;
		event.cancel = true;
		button.click();
		return false;
	} else {
		return true;
	}
}

function WindowKeyPress(e) {
	var keyCode = -1;
	if (window.event) {
		keyCode = window.event.keyCode;
	}
	if (e && keyCode <= 0) {
		keyCode = e.charCode;
		if (keyCode <= 0){
		    keyCode = e.keyCode;
		}
	}
    if (keyCode == 27) {
        window.close();
        return true;
    }
	return;
}

function OpenWindow(url, width, height, target) {
	var left = (window.screen.width - width) / 2;
	var top = (window.screen.height - height) / 2;
	var options = 'width=' + width + ',height=' + height + ',top=' + top + ',left=' + left + ',status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=no';
	window.open(url, target, options);
}

/* otevreni stranky se stanicemi, sStat obsahuje nezev inputu o ktery se jedna*/
function OpenStatWindow(Path, Stat)
{
	var h = window.screen.height - 200;
	var w = 350
    var sStat = "";
    oEl = document.getElementById("ctl00_ctlContentMaster_" + Stat);    
    if (oEl != null) {    
        if (oEl.value.length >0 ){
            sStat =  oEl.value;
        }        
    }    
    var left = (window.screen.width - (w + 60)) / 2;
    var top =  (window.screen.height - (h + 80)) / 2;	
    window.open(Path + sStat, "", "height=" + h + ",width=" + w + ",top=" + top + ",left=" + left + ",location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes");
    return false;
}

/* otevreni stranky a vlozeni do stredu*/
function OpenKuryrWindow(Path, w,h, target)
{	
    var left = (window.screen.width - (w + 60)) / 2;
    var top =  (window.screen.height - (h + 80)) / 2;	
    window.open(Path, target, "height=" + h + ",width=" + w + ",top=" + top + ",left=" + left + ",location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes");
    return false;
}

/* otevre nove okno o velikosti w, h na pozici 0,0*/
function OpenSouhrnWindow(Path, w,h,target)
{	    
    window.open(Path, target, "height=" + h + ",width=" + w + ",top=0, left = 0,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes");
    return false;
}

/* pro zkopirovani nazvu stanice z SearchRelDetail do inputu v SearchRel*/
/* sStat je nazev stanice, ktery se ma zkopirovat,  sFromTo obsahuje nazev textboxu, do ktereho se ma zkopirovat*/
function CopyStat(sStat, sFromTo){
    var bOK;
    bOK = false;    
    if 
    (window.parent != null){
        try {            
            oStatTxt = window.parent.opener.document.getElementById("ctl00_ctlContentMaster_" + sFromTo);
            if (oStatTxt != null){
                oStatTxt.value = sStat;                    
                bOK = true;
            }
        }
        catch(e) {
            /* vyjimku zabije*/
        }
    }
    if (bOK){
        WClose();            
    }
    else{
        alert("Cílové okno již není k dispozici.\nBylo již pravděpodobně zavřeno.")            
    }   
}

/* zavreni pop-okna*/
function WClose(){
    if (window.parent != null){
        window.parent.close();
    }
    else{
        window.close();
    }
}

function DetailLoad(){
    try {        
        window.focus();
        document.onkeypress = WindowKeyPress;        
    } 
    catch(e) { }   
}

/* pri zadani uzaju o preprave nastavi viditelnost velicin podle vybraneho kodu */
function ChangeCode(){    
        // kody
        var oEl;
        oEl = document.getElementById("ctl00_ctlContentMaster_Codes");
        var bDisplay = false;
        // projde seznam kodu, u kterych se da zadat pocet kusu
        for(i=0;i<asCheckCount.length;i++){
                if (oEl.value == asCheckCount[i]){
                // pokud je nejaky z nich vybran tak se nastavi bDisplay na true
                    bDisplay = true;
                }
        }
        oEl = document.getElementById("ctl00_ctlContentMaster_txtPocet");    
        if (oEl != null && oEl.disabled == false) {
            sPocet =  oEl.value;                       
        }
        if (bDisplay){
            // textbox je aktivni
            eval("document.getElementById('ctl00_ctlContentMaster_txtPocet').disabled = false;"); 
            eval("document.getElementById('ctl00_ctlContentMaster_txtPocet').value = '" + sPocet + "';");             
        }
        else{
            // textbox je neaktivni
            eval("document.getElementById('ctl00_ctlContentMaster_txtPocet').disabled = true;");                                   
            eval("document.getElementById('ctl00_ctlContentMaster_txtPocet').value = '1';");             
        }
        // dobirka
        oEl = document.getElementById("ctl00_ctlContentMaster_Codes");
        bDisplay = false;
        // projde seznam kodu s dobirkou
        for(i=0;i<asCheckDobirka.length;i++){
                if (oEl.value == asCheckDobirka[i]){
                // pokud je nejaky z nich vybran tak se nastavi bDisplay na true
                    bDisplay = true;
                }
        }        
        if (bDisplay){
            // dobirka je videt
                eval("document.getElementById('ctl00_ctlContentMaster_iddobirka').className = 'yesdisplay';");
        }
        else{
            // dobirka neni videt
            eval("document.getElementById('ctl00_ctlContentMaster_iddobirka').className = 'nodisplay';");            
        }
        // projde seznam kodu "zive" pri kterych musi byt zadano tel. cislo a pokud je tento kod vybran, tak zobrazi hvezdicku u labelu k telefonu
        oElPhone = document.getElementById("reqphone");
        if (oElPhone != null){
            oElPhone.style.visibility = 'hidden';
            for(i=0; i<asCheckPhone.length; i++){
                if (oEl.value == asCheckPhone[i]){
                    oElPhone.style.visibility = 'visible';
                }
            }
        }
}
