/********************************************************************************

********************************************************************************/
var win = null;

//Default browsercheck
function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}
bw=new checkBrowser()

/************************************************************************************
foldout
****************************************************************************/
<!--

function ShowHideLaptop(theTable,imgID,imgSrcClosed,imgSrcOpen){
/**
imgClosed +; imgOpen - 
**/
     if (document.getElementById(theTable).style.display == 'none'){
	 	document.getElementById(theTable).style.display = 'block';
		document[imgID].src = imgSrcOpen;
     }else{
	 	document.getElementById(theTable).style.display = 'none';
		document[imgID].src = imgSrcClosed;
	 }
}
/*function showTab(tabId, tabNo)
{
	var tabCollection = document.getElementById(tabId);
	tabCollection.className='numetroTab'+tabNo;
}*/
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

//check num
function isNum(s) {
	var newstring = parseFloat(s).toString();
	if (s.length == newstring.length && newstring != "NaN") {
		return 1;
	}
	else {
		return 0;
	}
}

//----------date funcs-------------------------
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}
//[Date format:mm/dd/yy]
function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		return false
	}
return true
}
//-----------------------------------

//check pic : Uses Right Function
function isPicture(strFileName){
    switch (Right(strFileName,3)){
		case "bmp": {return true;}
		case "BMP": {return true;}
		case "jpg": {return true;}
		case "JPG": {return true;}
		case "gif": {return true;}
		case "GIF": {return true;}
		case "png": {return true;}
		case "PNG": {return true;}
		case "swf": {return true;}
		case "SWF": {return true;}
		default: {return false;}
		}
	switch (Right(strFileName,4)){
		case "jpeg": {return true;}
		case "JPEG": {return true;}
		}
}
//check email
function isEmail(argvalue) {

  if (argvalue.indexOf(" ") != -1)
    return false;
  else if (argvalue.indexOf("@") == -1)
    return false;
  else if (argvalue.indexOf("@") == 0)
    return false;
  else if (argvalue.indexOf("@") == (argvalue.length-1))
    return false;

  // arrayString = argvalue.split("@"); (works only in netscape3 and above.)
  var retSize = customSplit(argvalue, "@", "arrayString");

  if (arrayString[1].indexOf(".") == -1)
    return false;
  else if (arrayString[1].indexOf(".") == 0)
    return false;
  else if (arrayString[1].charAt(arrayString[1].length-1) == ".") {
    return false;
  }

  return true;

}

//check file Extension
function flExt(s_FileName){
    if(s_FileName==""){return "";}
    var s_TempFileExt
    s_TempFileExt = Right(s_FileName,4);
    
    switch (Left(s_TempFileExt, 1)){
		case ".": {return s_TempFileExt;}
		default: {return false;}
		}
    s_TempFileExt = Right(s_FileName,5);
	switch (Left(s_TempFileExt, 1)){
		case ".": {return s_TempFileExt;}
		default: {return false;}
		}
}
//confirm box
function getconfirm(strTitle){
    if (confirm("Are you sure you want to delete "+strTitle+"?")==true)
		return true; 
	else 
	    return false;
}
//open pop up
function OpenPopWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function NewWindow(mypage,myname,w,h,scroll){
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	
	settings =
	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=no'
	win = window.open(mypage,myname,settings)
}

function alertsession(reloadparent){
    alert("Sorry, your login session seems to have expired. Please login.");
    window.close();
    if(reloadparent=="1"){
        if (window.opener && !window.opener.closed) {
            window.opener.location.reload();
        }
    }
}
//-->