﻿// JScript File
function __doUserLogin(userName, userPassword, userRemember) {
	var theform = document.Form1;
	theform.__LOGINREQ.value = 1;
	theform.__USRLOGIN.value = userName;
	theform.__USRPASSW.value = userPassword;
	theform.__USRPERST.value = userRemember;
	theform.submit();
}

function Is_IE5Up(){var agt=navigator.userAgent.toLowerCase();var is_major=parseInt(navigator.appVersion);var is_ie=((agt.indexOf("msie")!=-1)&&(agt.indexOf("opera")==-1));var is_ie3=(is_ie && (is_major<4));var is_ie4=(is_ie && (is_major==4)&&(agt.indexOf("msie 4")!=-1));return (is_ie && !is_ie3 && !is_ie4);}

function ShowDialog(URl){ShowDialog(URL, 500, 600)}
function ShowDialog(URL, width, height){if(Is_IE5Up()){window.showModalDialog(URL,"","dialogHeight: "+height+"px; dialogWidth: " + height +"px; dialogTop: px; dialogLeft: px;"+"edge: Raised; center: Yes; help: No; resizable: Yes; status: No;");}else{window.open(URL,"Browser","top=" + (screen.height - height) / 2 + ",left=" + (screen.width - width) / 2 + ",location=0,status=0,resizable=1,scrollbars=1,width=" + width + ",height=" + height);}}

function emailitem(URL){emailwindow=window.open("/main/modules/PrintDialog/EmailItem.aspx?URL=" + URL,"emailwindow","width=400,height=300,scrollbars=0,status=0,location=1,resizable=0");}
function printitem(src){printwindow=window.open("/main/modules/PrintDialog/PrintItem.aspx?src=" + src,"emailwindow","width=800,height=600,resizable=1,scrollbars=1,status=0,location=0");}		
function showGalobResults(params){galobwin=window.open("/main/modules/gallop/gallopresults.aspx?" + params,"galobwin","width=500,height=500,scrollbars=1,status=0,location=0,resizable=1");}

function proceed(){return confirm('WARNING: All changes you have done will be lost.\nPress Cancel to Save changes or OK to proceed.');}
function delConfirm(val){return confirm('Are you sure you want to delete this '+val+'?');}
function delListConfirm(){return confirm('Are you sure you want to delete this selected items');}
function saveAndDelConfirm(){return confirm('On save item(s) checked for deletion will be deleted too. Are you sure?');}

function openWindow(URL, width, height, resize, scroll, location){win = window.open(URL,"Browser","top=" + (screen.height - height) / 2 + ",left=" + (screen.width - width) / 2 + ",location=" + location + ",status=0,resizable=" + resize + ",scrollbars= " + scroll + ",width=" + width + ",height=" + height);}
function openWin(URL){openWindow(URL, 800, 500,1,1,1);}
function newWin(URL){win=window.open(URL);return false;}
function copyDropDownToTextBox(dd,tb){tb.value=dd.options[dd.selectedIndex].text}

function selectGridItems(dgCnt, chk, aGridChk){
    var prefix = aGridChk.substring(0,aGridChk.lastIndexOf('_') - 2);
    var suffix = aGridChk.substring(aGridChk.lastIndexOf('_'));
    
    for(i=0; i<dgCnt; i++){
        var chkId = prefix;
        if(i<=9){chkId += "0" + i}else{chkId += i}
        chkId += suffix;
        var dgChk = document.getElementById(chkId);
        dgChk.checked = chk.checked;
    }  
}

function gridItemSelect(dgCnt,chk,aGridChk){
    var prefix = aGridChk.substring(0,aGridChk.lastIndexOf('_') - 2);
    var suffix = aGridChk.substring(aGridChk.lastIndexOf('_'));
    var allChecked = true;
    for(i=0; i<dgCnt; i++){
        var chkId = prefix;
        if(i<=9){chkId += "0" + i}else{chkId += i}
        chkId += suffix;
        var dgChk = document.getElementById(chkId);
        if(!dgChk.checked){
            allChecked = false;
            break;
        } 
    }  
    chk.checked = allChecked;
}

function openFTPwin(fieldname,dir){
   url = "/main/Utils/FTP/FTP.aspx?";
   if(dir!="") url += "dir=" + dir + "&";
   url += "type=I&fieldname="+fieldname;
   f = window.open(url,"browse","location=1,status=0,resizable=1,scrollbars=1,width=700,height=400");
}
function openFTP(fieldname){openFTPwin(fieldname,"");}
function Browse(datafolder, fieldname){openFTPwin(fieldname,datafolder);}

function openColorPicker(fieldname){cp = window.open("/main/Utils/ColorPicker.htm?fieldname="+fieldname,"colorpicker","location=0,status=0,resizable=0,scrollbars=0,width=460,height=280");}
function openHtmlEditor(fieldname){h = window.open("/main/Utils/HtmlEditor.aspx?fieldname="+fieldname,"browse","location=1,status=0,resizable=1,scrollbars=1,width=700,height=400");}

function imagePopUp(img){
	url = img
	nameW = 'feature'
	height = 400
	width = 600
	if (navigator.appVersion.indexOf('4') != -1){
		// Vars for centering the new window on Version 4 Browsers
		xTop = screen.width/2 - (width/2);
		yTop = screen.height/2 - (height/2);
		myWindow = window.open(url, nameW, 'height='+height+',width='+width+',scrollbars=0,resizable=1,menubar=0,toolbar=0,status=0,location=0,directories=0,left=' + xTop + ',top=' + yTop + '');
		myWindow.document.title = "Image Preview - SpiderCMS 1.7 FTP"
	}else{
		myWindow = window.open(url, nameW, 'height='+height+',width='+width+',scrollbars=0,resizable=1,menubar=0,toolbar=0,status=0,location=0,directories=0,left=150,top=200');
		myWindow.document.title = "Image Preview - SpiderCMS 1.7 FTP"
	}//browser check
}//imagePopUp

/*function setEnabled(cb){
    for(i=0; i<document.forms[0].elements.length; i++){
        item = document.forms[0].elements[i];
        //alert(item.id + " = " + item.type)
        if(item.type == 'text' || item.type == 'textarea' || item.type == 'radio' || item.type == 'select-one' ){
            //item.disabled = cb.checked;
            item.style.disabled = cb.checked;
        }
        
    }
}*/



function DatePicker(fieldname1, fieldname2){
	 openWindow("/main/Utils/Calendar/CalendarPopUp.aspx?fieldname1=" + fieldname1 + "&fieldname2=" + fieldname2,  210, 170,0,0,0)
	return false
}//DatePicker

function hideSelects(){
    var arrElements = document.getElementsByTagName('select'); 
    for (var i=0; i < arrElements.length; i++){
        arrElements[i].style.visibility = 'hidden';          
    }
}
function showSelects(){
    var arrElements = document.getElementsByTagName('select'); 
    for (var i=0; i < arrElements.length; i++){
        arrElements[i].style.visibility = 'visible';          
    }
}

/* Custom Scripts For Cyprus Airways Website */
function GenReport(cIdPrefix){
	var iWidth = 750;
	var iHeight = 550;
	var URL;
	var theform;
	if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
		theform = document.forms["aspnetForm"];
	}
	else {
		theform = document.aspnetForm;
	}
	URL = "/Main/ModulesCustom/UserReport.aspx?" 
	URL +=  "country=" + eval('theform.'+cIdPrefix+'_ddlC.value')
			+ "&dep=" + eval('theform.'+cIdPrefix+'_ddlDep.value')
			+ "&dest=" + eval('theform.'+cIdPrefix+'_ddlDest.value') 
			+ "&mail=" + eval('theform.'+cIdPrefix+'_ddlMail.value') 
			+ "&noc=" + eval('theform.'+cIdPrefix+'_cbNotC.checked')
	windowopener = window.open(URL,"windowopener","menubar=0,location=0,status=0,top=5,left=5,width=" + iWidth + ",height=" + iHeight + ",resizable=1,scrollbars=1");	
}
/* End Custom Scripts For Cyprus Airways Website */