function open_win(url) {
	window.open(url,'Temp','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=50,left=50');
}
function open_win_tpnet(url) {
    var winw = screen.width-10;
    var winh = screen.height-65;
	window.open(url,"Temp","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=0,left=0,width="+winw+",height="+winh);
}
function open_win_config(url, winw) {
    var winl = (screen.width-winw)/2;
    var winh = screen.height-150;
	window.open(url,"Temp","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,top=50,left="+winl+",width="+winw+",height="+winh);
}
function open_win_fixed(url, winw, winh) {
	window.open(url,'Temp','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=50,left=50,width='+winw+',height='+winh);
}
function open_win_float(url, winw, winh) {
    var winl = (screen.width-winw)/2;
    var wint = (screen.height-winh)/2;
	window.open(url,"Temp","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top="+wint+",left="+winl+",width="+winw+",height="+winh);
}
function open_win_full(url) {
	window.open(url,'Temp');
}
function go_win(eID) {
    var hdf = document.getElementById(eID);
	if(!hdf) {
		return;
	}			
    var url = hdf.value;
    window.location = url;
}
function verify_submit() {
    var txt;
    var errors = "";
    txt = document.getElementById('ctl00_csl_text_txtName');
    if (txt.value == null || txt.value == "" || isblank(txt.value)) {
        errors += "Name field is empty\n";
    }
    txt = document.getElementById('ctl00_csl_text_txtEmail');
    if (txt.value == null || txt.value == "" || isblank(txt.value)) {
        errors += "Email field is empty\n";
    } else {
        var t = txt.value;
        if (t.indexOf("@") < 0 || t.indexOf(".") < 0) {
            errors += "Email address is invalid\n";
        }
    }
    txt = document.getElementById('ctl00_csl_text_txtTelNo');
    if (txt.value == null || txt.value == "" || isblank(txt.value)) {
        errors += "Telephone number field is empty\n";
    }
    if (errors != "") {
        errors = "The form could not be submitted for the following reasons:\n\n" + errors;
        alert(errors);
        return;
    }
    document.aspnetForm.submit();
}    
function verify_submit_new_company() {
    var txt;
    var errors = "";
    txt = document.getElementById('ctl00_csl_text_txtCompany');
    if (txt.value == null || txt.value == "" || isblank(txt.value)) {
        errors += "Company field is empty\n";
    }
    txt = document.getElementById('ctl00_csl_text_txtFirstName');
    if (txt.value == null || txt.value == "" || isblank(txt.value)) {
        errors += "User First Name field is empty\n";
    }
    txt = document.getElementById('ctl00_csl_text_txtLastName');
    if (txt.value == null || txt.value == "" || isblank(txt.value)) {
        errors += "User Last Name field is empty\n";
    }
    txt = document.getElementById('ctl00_csl_text_txtLogIn');
    if (txt.value == null || txt.value == "" || isblank(txt.value) || txt.value.length < 2) {
        errors += "LogIn field is empty or invalid\n";
    }
    txt = document.getElementById('ctl00_csl_text_txtPassword');
    if (txt.value == null || txt.value == "" || isblank(txt.value) || txt.value.length < 6) {
        errors += "Password field is empty or invalid\n";
    }
    txt = document.getElementById('ctl00_csl_text_txtEmail');
    if (txt.value == null || txt.value == "" || isblank(txt.value)) {
        errors += "Email field is empty\n";
    } else {
        var t = txt.value;
        if (t.indexOf("@") < 0 || t.indexOf(".") < 0) {
            errors += "Email address is invalid\n";
        }
    }
    txt = document.getElementById('ctl00_csl_text_txtTelNo');
    if (txt.value == null || txt.value == "" || isblank(txt.value)) {
        errors += "Telephone number field is empty\n";
    }
    if (errors != "") {
        errors = "The form could not be submitted for the following reasons:\n\n" + errors;
        alert(errors);
        return;
    }
    document.aspnetForm.submit();
}    
function verify_submit_cb_company() {
    var txt;
    var errors = "";
    txt = document.getElementById('ctl00_csl_text_txtFirstName');
    if (txt.value == null || txt.value == "" || isblank(txt.value)) {
        errors += "User First Name field is empty\n";
    }
    txt = document.getElementById('ctl00_csl_text_txtLastName');
    if (txt.value == null || txt.value == "" || isblank(txt.value)) {
        errors += "User Last Name field is empty\n";
    }
    txt = document.getElementById('ctl00_csl_text_txtEmail');
    if (txt.value == null || txt.value == "" || isblank(txt.value)) {
        errors += "Email field is empty\n";
    } else {
        var t = txt.value;
        if (t.indexOf("@") < 0 || t.indexOf(".") < 0) {
            errors += "Email address is invalid\n";
        }
    }
    txt = document.getElementById('ctl00_csl_text_txtOrganisation');
    if (txt.value == null || txt.value == "" || isblank(txt.value) || txt.value.length < 2) {
        errors += "Organization Name field is empty or invalid\n";
    }
    txt = document.getElementById('ctl00_csl_text_ddlType');
    if (txt.value == null || txt.value == "" || isblank(txt.value) || txt.value.length < 6) {
        errors += "Costing Type field is empty or invalid\n";
    }
    if (errors != "") {
        errors = "The form could not be submitted for the following reasons:\n\n" + errors;
        alert(errors);
        return;
    }
    document.aspnetForm.submit();
}    
function isblank(s) {
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) {
            return false;
        }
    }
    return true;
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

