﻿// jscript File
function popupCenter(filename,xWindow,yWindow,instruct){
    var myWidth=0, myHeight=0, xOffset, yOffset;
    if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        xOffset = window.screenLeft+(document.documentElement.clientWidth-xWindow)/2;
        yOffset = window.screenTop+(document.documentElement.clientHeight-yWindow)/2;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        xOffset = window.screenLeft+(document.body.clientWidth-xWindow)/2;
        yOffset = window.screenTop+(document.body.clientHeight-yWindow)/2;
    }else if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        xOffset = window.screenX+(window.outerWidth-xWindow)/2;
        yOffset = window.screenY+(window.outerHeight-yWindow)/2;
    }
    window.open(filename,'newwindow','width='+xWindow+',height='+yWindow+',top='+yOffset+',left='+xOffset+instruct);
    return false;
}
function deleteChrs(s){
	var i;
	var sDone = "";
	for (i = 0; i < s.length; i++){
		var c = s.charAt(i);
		if ((c >= "0") && (c <= "9")) sDone += c;
	}
	return sDone;
}
function checkUSPhone(txtPhone){
	if (txtPhone.value!=''){  
		var phone = deleteChrs(txtPhone.value)
		var phonelen = phone.length
		if(phone.substring(0,1)=='1'){phone = phone.substring(1,15); phonelen = phone.length;}
		txtPhone.value = "(" + phone.substring(0,3) + ") " + phone.substring(3,6) + "-" + phone.substring(6,10)
		if(phonelen>10){ txtPhone.value += " x " + phone.substring(10,15); }
	}
	return;
}
