/* Utility Functions */

function openNewWin(url,winH,winW,resize,scroll,menu,tool,location,status){
	var left = ((screen.width-winW)/2) - 70;
  	var top = (screen.height-winH)/2;
  	var winOptions = "scrollbars=" + scroll + ",menubar=" + menu + ",resizable=" + resize + ",toolbar=" + tool + ",location=" + location + ",status=" + status + ",height=" + winH + ",width=" + winW + ",top=" + top +",left=" + left;
	iobeWindow = window.open(url,'iobeWindow',winOptions);
	var winOptions2 = "width=140,height=" + winH + ",top=" + top + ",left=" + (left+winW+10) + ",resizable=no,toolbar=no,location=no,scrollbars=no,menubar=no";
	iobeLogin = window.open("/tools/iobe_login.html","iobe_login",winOptions2);
	iobeLogin.window.focus();
}

function resetForm(){
	var reset = confirm("Are you sure you want to clear this form?");
	if (reset) document.forms[0].reset();
}

function swapColor(file,navID,bgcolor,colorSwitched){
	colorSwitched = (colorSwitched == 1)? true : false;
	var onColor, offColor;
	if (file == 'l_n') {
		onColor = '#FFFFCC';
		offColor = '#FFFF33';
	} else if (file == 'l_e') {
		onColor = '#F0F0F0';
		offColor = '#0000FF';
	}
	if (colorSwitched){
		eval("document.all['"+navID+"'].style.backgroundColor = '"+bgcolor+"'"); 
		eval("document.all['"+navID+"'].style.cursor = 'hand'");
		
	} else { 
		eval("document.all['"+navID+"'].style.backgroundColor = '"+bgcolor+"'"); 
	}
}

function swapImg(navID,img){
	eval("document.images['"+navID+"'].src = '"+img+"'"); 
	//eval("document.all['"+nav+"'].style.cursor = 'hand'");
}

function convertLowerToUpper(){
	var tempString = "";
	for (i=0;i<this.length;i++){
		if (i==0){ 
			tempString += this.charAt(i).toUpperCase();
		} else {
			tempString += this.charAt(i);
		}
	}
	return tempString;
}

function checkFormat(type,symbol){
	var tempString = "";
	var newString = "";
	var localAreaCode = "718";
	for (i=0;i<this.length;i++){
		var code = this.charCodeAt(i);
		if ((code >= 48) && (code <= 57)){
			newString += this.charAt(i);
		} 
	}
	if (type == 'phone'){
		
		if (newString.length == 7){
			tempString += "("+localAreaCode+") ";
			for (i=0;i<newString.length;i++){
				if (i!=3){
					tempString += newString.charAt(i);
				} else {
					tempString += "-"+newString.charAt(i);
				}
			}
		} else if (newString.length == 10){
			tempString += "(";
			for (i=0;i<newString.length;i++){
				if (i==3){
					tempString += ") " + newString.charAt(i);
				} else if (i==6) {
					tempString += "-"+newString.charAt(i);
				} else {
					tempString += newString.charAt(i);
				}
			}
		}
	} else if (type == 'money'){
		var count = 0;
		var tempString_1 = "";
		var re = /(^0|[^0-9|.])+/;
		var amount = this.replace(re,'');
		//alert(amount);
		for (i=this.length-1;i>=0;i--){
			if (count!=0 && count%3==0){
				tempString_1 += symbol+this.charAt(i);
			} else {
				tempString_1 += this.charAt(i);
			}
			count++;
		}
		for (i=tempString_1.length-1;i>=0;i--){
			tempString += tempString_1.charAt(i);
		}	
	}
	return tempString;
}

function trimString (str) {
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

String.prototype.trim = trimString;
String.prototype.correctCase = convertLowerToUpper;
String.prototype.fixFormat = checkFormat;















