﻿// JScript File
menu_status = new Array();
function showHide(theid){
    if (document.getElementById) {
        var switch_id = document.getElementById(theid);
        if(menu_status[theid] != 'show') {
           switch_id.className = 'show';
           menu_status[theid] = 'show';
        }else{
           switch_id.className = 'hide';
           menu_status[theid] = 'hide';
        }
    }
}
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("EmailUrlLink.aspx?URL=" + URL,"emailwindow","width=500,height=350,scrollbars=1,status=0,location=0,resizable=1");
}
function printitem(src){window.print()}		
function showGallopResults(params){
    galobwin=window.open("ShowGallopResults.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, 790, 500,1,1,0);}
function newWin(URL){win=window.open(URL);return false;}
function openPopUp(URL,width, height){openWindow(URL, width, height,0,1,0);}
function copyDropDownToTextBox(dd,tb){tb.value=dd.options[dd.selectedIndex].text}
function openModuleAdd(tabId){openWindow('/main/admin/AddModule.aspx?tabId=' + tabId, 780, 140, 1, 1, 0)}
function openPageSettings(tabId){openWindow('/main/admin/PageSettings.aspx?p=' + tabId, 700, 400, 1, 1, 0)}

function openImageWin(pic,width,height,txt, txtStyle) {
    link = open("", "mphW", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,left=100,top=100,width="+width+",height="+height);
    link.document.open();
    link.document.writeln("<html>");
    link.document.writeln("<head>");
    link.document.writeln("<title>Picture</title>");
    link.document.writeln("</head>");
    link.document.writeln("<body topmargin=\"0\" leftmargin=\"0\">");
    link.document.writeln("<img id=\"picture\" name=\"picture\" src=\"" + pic + "\">");
    if(txt!=""){
        link.document.writeln("<p style=\""+txtStyle + "\">" + txt + "</p>");
    }
    link.document.writeln("</body>");
    link.document.writeln("</html>");
    link.document.close();
    link.focus();
}

// Set the horizontal and vertical position for the popup
PositionX = 100;
PositionY = 100;
// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)
defaultWidth  = 500;
defaultHeight = 500;
// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows
var AutoClose = true;
// Do not edit below this line...
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style type="text/css">body{margin:0px;background-color:#000}</style>');
writeln('<script type="text/javascript">');
writeln('var isNN,isIE;');
writeln('if(parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');
writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');
writeln('if (isIE){');
writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');
writeln('if (isNN){');       
writeln('window.innerWidth=document.images["popimage"].width;');
writeln('window.innerHeight=document.images["popimage"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');
writeln('</script>');
if (!AutoClose) writeln('</head><body scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img alt="'+imageTitle+'" name="popimage" src='+imageURL+' style="display:block"></body></html>');
close();		
}}


function SetLeftColHeight(){
    l = document.getElementById("left")
    l.style.height = document.body.offsetHeight+ "px"
}

function requiredField(tb, div, msg){
    errMsg = document.getElementById(div);
    if(tb.value==""){
        errMsg.innerHTML=msg;
        return false;
    }else{
        errMsg.innerHTML="";
        return true;
    }
}

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 chkListSelect(cnt,chkPrefix,val){
    for(i=0; i<cnt; i++){
        var chk = document.getElementById(chkPrefix + "_" + i);
        chk.checked = val
    }
}


function chkAll(cnt,chkPrefix,chk){
    for(i=0; i<cnt; i++){
        var lChk = document.getElementById(chkPrefix + "_" + i);
        if(lChk.id != chk.id && !lChk.checked){
            chk.checked = false;
            return
        }
    }
    chk.checked=true;
}


function openFTPWin(fieldname,dir){
   url = "Utils/FTP/FTP.aspx?";
   if(dir!="") url += "dir=" + dir + "&";
   url += "type=I&fieldname="+fieldname;
   f = window.open(url,"browse","location=0,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("Utils/ColorPicker.htm?fieldname="+fieldname,"colorpicker","location=0,status=0,resizable=0,scrollbars=0,width=460,height=280");}
function openHtmlEditor(fieldname){h = window.open("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 setCalendarView(calName){
    var cal = document.getElementById(calName)
    
    if(cal.style.visibility=='visible'){
        cal.style.visibility='hidden';
    }else{
        cal.style.visibility='visible';
    }
}//setCalendarView


function DatePicker(fieldname1, fieldname2){
	 openWindow("Utils/Calendar/CalendarPopUp.aspx?fieldname1=" + fieldname1 + "&fieldname2=" + fieldname2,  210, 170,0,0,0)
	return false
}//DatePicker

function openW(URL){
    var link = open("","Amathus_Hotel");
    link.document.writeln("<img src=" + URL + " src_cetemp=" + URL + " src_cetemp=" + URL + " />");
    link.document.close();
    link.focus();
}

function swapImage(imgId, newImgSrc){
    var img = document.getElementById(imgId)
    img.src = newImgSrc;
}

function swapImage(imgId, newImgSrc, divId, legend){
    var img = document.getElementById(imgId)
    img.src = newImgSrc;
    
    var div = document.getElementById(divId)
    div.innerHTML = legend
}


function createPagePopUp(pageTitle,pageBody){
    var NN='scrollbars=yes,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
    var IE='scrollbars=yes,width=350,height=200,left='+PositionX+',top='+PositionY;

    if (isNN){win=window.open('about:blank','',NN);}
    if (isIE){win=window.open('about:blank','',IE);}
    with (win.document){
        writeln("<html><head><title>" + pageTitle + "</title></head><body>");
        writeln(pageBody);
        writeln("</body></html>");
    }
}

function showHideDiv(divId){
    var div = document.getElementById(divId)
    if(div.style.display=='block'){
        div.style.display='none'
        return 0;
    }else{
        div.style.display='block';
        return 1;
    }
}


function getCurrentDate(){
    var date=new Date();

    var dd = (date.getDate() < 10) ? '0' + date.getDate() : date.getDate();
    var mm = (date.getMonth() < 9) ? '0' + (date.getMonth()+1) : (date.getMonth()+1);
    var yy = (date.getYear() < 1000) ? date.getYear() + 1900 : date.getYear();
   
    var d=new Array("Sunday","Monday","Tuesday","Wednesday", "Thursday","Friday","Saturday");
    return d[date.getDay()]+", "+dd+"/"+mm+"/"+yy
}
  
function getDateTime(){
    var date=new Date();

    var dd = (date.getDate() < 10) ? '0' + date.getDate() : date.getDate();
    var mm = (date.getMonth() < 9) ? '0' + (date.getMonth()+1) : (date.getMonth()+1);
    var yy = (date.getYear() < 1000) ? date.getYear() + 1900 : date.getYear();
    var hours = date.getHours();
    var minutes = (date.getMinutes() < 10) ? '0' + date.getMinutes() : date.getMinutes();
    var seconds = (date.getSeconds()< 10) ? '0' + date.getSeconds() : date.getSeconds();
    
    var d=new Array('Κυριακή','Δευτέρα','Τρίτη','Τετάρτη','Πέμπτη','Παρασκευή', 'Σάββατο');
    
    document.getElementById("dt").innerHTML = d[date.getDay()]+", "+dd+"/"+mm+"/"+yy+" "+hours+":"+minutes+":"+seconds
    setTimeout("getDateTime()",1000)
}


function checkRadio(radio){
	var x = document.forms[0].getElementsByTagName('input');
	for (var i=0;i<x.length;i++)
		if (x[i].type == 'radio') x[i].checked = false;
	radio.checked = true;
}