// JavaScript Document

function _newWindow(url,name,fwidth,fheight,status,directories,location,toolbar,menubar,scrollbars,resizable,vLeft,vTop,fCloseSelf,fResizeParent) {
    // setting the new window size dependng on whats passed
    switch (fwidth){
        case "max":
            fwidth = screen.width;
        break
        case "half":
            fwidth = screen.width/2;
        break
        default:
            fwidth = Number(fwidth);
            /*if(document.sPlatform.indexOf("Mac") == -1){
                fwidth += 10;// add window width for pcs
            }/**/
    }
    switch (fheight){
        case "max":
            fheight = screen.height-15;//adjust for browser chrome
            /*if(document.sPlatformType.indexOf("Mac") == -1){
                fheight -= 45;// take off extra for pcs
            }/**/
        break
        case "half":
            fheight = screen.height/2;
        break
        default:
            fheight = Number(fheight);
            /*if(document.sPlatformType.indexOf("Mac") == -1){
                fheight += 15;// add extra for pcs
            }/**/
    }
    // set the position 
    if(vLeft == "center"){vLeft = (screen.width/2) - (fwidth/2);}
    if(vTop == "center"){vTop = (screen.height/2)  - (fheight/2);}
    //alert("Top="+vTop+" Left="+vLeft);
    //
    options = ((fwidth!="")?"width="+fwidth:"")+((fheight!="")?",height="+fheight:"")+",status="+((status=="1")?"yes":"no")+",directories="+((directories=="1")?"yes":"no")+",location="+((location=="1")?"yes":"no")+",toolbar="+((toolbar=="1")?"yes":"no")+",menubar="+((menubar=="1")?"yes":"no")+",scrollbars="+((scrollbars=="1")?"yes":"no")+",resizable="+((resizable=="1")?"yes":"no")+",left="+vLeft+",top="+vTop ;
    var sWinObject = name.replace(" ","_");
    eval(sWinObject+"=window.open('"+url+"','"+sWinObject+"','"+options+"')");
    if (fCloseSelf == true){this.close();}
    
    if(fResizeParent == true){
        self.moveTo(0,0);
        window.resizeTo(screen.width,screen.height);
    };
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function openWindow(url){
	window.open( url, "dialog", "height=600,width=650,toolbar=no,menubar=no,resizeable=yes,status=yes" );
}

var curOS ;
if (navigator.appVersion.indexOf("Win")!=-1) curOS="Windows";
else if (navigator.appVersion.indexOf("Mac")!=-1) curOS="MacOS";
else if (navigator.appVersion.indexOf("X11")!=-1) curOS="UNIX";
else if (navigator.appVersion.indexOf("Linux")!=-1) curOS="Linux";
else curOS="unknown";

if (window.ActiveXObject) window.ie = window[window.XMLHttpRequest ? 'ie7' : 'ie6'] = true ;
else if (document.childNodes && !document.all && !navigator.taintEnabled) window.khtml = true ;
else if (document.getBoxObjectFor != null) window.gecko = true ;
if (window.ie6) try {document.execCommand("BackgroundImageCache", false, true);} catch (e){} ;



// Disable a form's submit/cancel button and submit the form. Before submitting, 
// we'll execute a callback function, if applicable...
var disableAndSubmit = function(submitID, cancelID, formID, callback){

	var oldSubmitHref, oldCancelHref ;
	if ($(submitID)) {
		if ($(submitID).get('tag') == 'input') {
			$(submitID).setProperty('disabled', true) ;
		} else if ($(submitID).get('tag') == 'a') {
			oldSubmitHref = $(submitID).getProperty('href') ;
			$(submitID).setProperty('href','javascript:void(0)') ;
		} 
		$(submitID).setStyle('opacity', .5) ;
	}
	if ($(cancelID)) {
		if ($(cancelID).get('tag') == 'input') {
			$(cancelID).setProperty('disabled', true) ;
		} else if ($(cancelID).get('tag') == 'a') {
			oldCancelHref = $(cancelID).getProperty('href') ;
			$(cancelID).setProperty('href','javascript:void(0)') ;
		} 
		$(cancelID).setStyle('opacity', .5) ;
	}

	var callback_retval = true ;
	if (typeof(callback) == 'function') {
		callback_retval = callback(formID) ;
	}

	if (callback_retval == true) {
		return true ; 
	} else {
		if ($(submitID)) {
			if ($(submitID).get('tag') == 'input') {
				$(submitID).setProperty('disabled', false) ;
			} else if ($(submitID).get('tag') == 'a') {
				$(submitID).setProperty('href',oldSubmitHref) ;
			} 
			$(submitID).setStyle('opacity', 1) ;
		}
		if ($(cancelID)) {
			if ($(cancelID).get('tag') == 'input') {
				$(cancelID).setProperty('disabled', false) ;
			} else if ($(cancelID).get('tag') == 'a') {
				$(cancelID).setProperty('href',oldCancelHref) ;
			} 
			$(cancelID).setStyle('opacity', 1) ;
		}
		return false ;
	}
} ;

var confirmAction = function(el_name, el_action, el_url) {
	var delete_it = confirm("Do you really want to " + el_action + " item: " + el_name + "?") ;
	if (delete_it) location.href = el_url ;
} ;
