﻿// JScript File

//IE4 throws javascript errors when java disabled. This method catches 
//those errors and suppresses them.
onerror=handleErr
function handleErr(msg,url,l){
	return true;
}

//IE4 and Netscape4 should not use any of the CSS styles or Javascript.  They are too old for most of the functionality to work properly.
//This function detects for IE4 and Netscape4, IE5+, Netscape 5+, and any other browser (Mozilla, Firefox, Safari, etc).  It sets no styles
//or Javascript for IE4 or less, Netscape4 or less. It sets a special style for IE5, and the default styles for IE6+ and the other browsers.
function detectBrowser() {
    var IE5detected = false;
    var Net5detected = false;
	var stylesheet1; 
	var stylesheet2;
	var jScript;
	
	//for modern browsers
	if (document.getElementById) {
		stylesheet1 = document.getElementById("default_css");
		stylesheet2 = document.getElementById("ie5_css");
		jScript = document.getElementById("standard_js");
	}
	//for older browsers (IE4)
	else if (document.all) {
		stylesheet1 = document.all["default_css"];
		stylesheet2 = document.all["ie5_css"];
		jScript = document.all["standard_js"];
	}
	
	stylesheet1.disabled = true;
	stylesheet2.disabled = true;
	jScript.disabled = true;
    
    //detect IE 5.x+
    var version=0
    if (navigator.appVersion.indexOf("MSIE")!=-1){
        temp=navigator.appVersion.split("MSIE");
        version=parseFloat(temp[1]);
        
        if (version >= 5) {
            IE5detected = true;
        }
    }
    
    //detect Netscape 5.x+
    if (navigator.appName=="Netscape" && parseFloat(navigator.appVersion) >= 5.0) {
        Net5detected = true;
    }
    
    //if either browser detected, enable CSS and Javascript
    if (IE5detected || Net5detected) {
		
		if (IE5detected && version < 6) {
			stylesheet1.disabled = true;
			stylesheet2.disabled = false;
		}
		else {
			stylesheet1.disabled = false;
			stylesheet2.disabled = true;
		}
		
		jScript.disabled = false;
    }
	//IE5 or Netscape5 not detected - could be older browser or different browser
	else {
		//detect IE version 4.x -        
        if (version < 5 && version != 0) {
			stylesheet1.disabled = true;
			stylesheet2.disabled = true;
			jScript.disabled = true;
		}
		//detect Netscape 4.x -
		else if(navigator.appName=="Netscape" && parseFloat(navigator.appVersion) < 5.0) {
			stylesheet1.disabled = true;
			stylesheet2.disabled = true;
			jScript.disabled = true;
		}
		//some other browser - Mozilla, Firefox, etc
		else {
			stylesheet1.disabled = false;
			stylesheet2.disabled = true;
			jScript.disabled = false;
		}
	}
}

// use by the modalpopup(s) to displays the confirmUpload_panel Modal Popup
function showModalPopup(popupObj) {
    $object(popupObj)._show();    
}

function hideModalPopup(hidePopupObj) {
    $object(hidePopupObj)._hide();
}

    // called in when yes button located on the confirmUpload_panel
    //is pressed 
function processFile() { 
    var postBack = new Sys.WebForms.PostBackAction();
    postBack.set_target('btnYes');
    postBack.set_eventArgument('');            
    postBack.performAction();    
}


    // called in when the cancel button located on the confirmUpload_panel 
    //is pressed
function processCancel() {
    var postBack = new Sys.WebForms.PostBackAction();
    postBack.set_target('btnNo');
    postBack.set_eventArgument('');            
    postBack.performAction();  
}


function openPopup(strOpen) {    
   
    var win = null;
    
    win = window.open(strOpen, "Info", "status=1, width=800, height=540, top=50, left=150 scrollbars=yes");
    if (!win.opener) win.opener = self;
    if (window.focus) {
        win.focus()
        return false;
    }
}

function AutoTab(currentField,nextField){
    // Determine if the current field's max length has been reached.
    if (currentField.value.length == currentField.maxLength) {
        document.getElementById("ctl00_ContentPlaceHolder1_" + nextField).focus();
    }
}

function IsNumber(theField) {
   var strlen = theField.value.length;
   var validChars = '0123456789';  // characters allowed
   var c
   var str = theField.value;
	  // Now scan string for illegal characters
   for (i=0; i <= strlen; i++) {
	  c = str.charAt(i);
	  if (validChars.indexOf(c) == -1) {
	    alert("Invalid Entry!  Only numbers are allowed in this field...!!!");
        document.getElementById(theField.id).focus();
        document.getElementById(theField.id).select();
		return false;
	  }
   }  // end scanning loop   
   return true;
}