﻿// 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("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, 800, 500,1,1,1);}
function newWin(URL){win=window.open(URL);return false;}
function openPopUp(URL,width, height){openWindow(URL, width, height,0,0,0);}
function copyDropDownToTextBox(dd,tb){tb.value=dd.options[dd.selectedIndex].text}

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 openFTPWin(fieldname,dir){
   url = "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("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 setCalendarEnable(tbName){
}//setCalendarView

/*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("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';          
    }
}