function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function BlockSign() {
	// 33 - 47 ! " # $ % & ' ( ) * + , - . /
	// 58 - 64 : ; < = > ? @
	// 91 - 96 [ \ ] ^ _ `
	// 123 - 126 { | } ~
	if ((event.keyCode>32&&event.keyCode<48)||(event.keyCode>57&&event.keyCode<65)||(event.keyCode>90&&event.keyCode<97)||(event.keyCode>122 && event.keyCode<127))
		event.returnValue = false
}

function BlockQuote() {
	// 34 "
	// 39 '
	if (event.keyCode==34||event.keyCode==39)
		event.returnValue = false
}

function BlockNum() {
	// 48 - 57 0 1 2 3 4 5 6 7 8 9
	if (event.keyCode>=48 && event.keyCode<=57)
		event.returnValue = false;
}

function NumOnly() {
	if (event.keyCode>='0'.charCodeAt()&&event.keyCode <= '9'.charCodeAt())
		event.returnValue = true;
	else
		event.returnValue = false;
}

function ExecuteURL(url){
	document.frmMain.action = url;
	document.frmMain.submit();
}

function winOpenAdj(url, widthb, heightb, toolb, menub, scrollb, resizeb, statusb){
	var h = heightb;
	var w = widthb;
	var t = toolb
	var m = menub
	var sc = scrollb
	var r = resizeb
	var st= statusb
	
	
		
	var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	var settings = 'height=' + h + ',width=' + w + ',top=' + (TopPosition-50) + ',left=' + LeftPosition + ',toolbar=' + t + ', menubar=' + m + ', scrollbars=' + sc + ', resizable=' + r + ', status=' + st + ''
			
	var rtnVal = window.open(url, '', settings)

}

function winOpen(url){
	var h = 700;
	var w = 800;
	
	var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	var settings = 'height=' + h + ',width=' + w + ',top=' + (TopPosition-50) + ',left=' + LeftPosition + ',toolbar=no, menubar=no, scrollbars=yes, resizable=yes, status=no'
	
	var rtnVal = window.open(url, '', settings)
}

function winOpenMini(url){
	var h = 400;
	var w = 400;
			
	var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	var settings = 'height=' + h + ',width=' + w + ',top=' + (TopPosition-50) + ',left=' + LeftPosition + ',toolbar=no, menubar=no, scrollbars=yes, resizable=yes, status=no'
			
	var rtnVal = window.open(url, 'MINI', settings)
}

function winOpenModal(url){
	var iWdDlg = 780
	var iHtDlg = 710
	
	var sFeatures = "dialogWidth:" + iWdDlg + "px; dialogheight:" + iHtDlg + "px; status:no; unadorned:yes; help:no"
		
	oChildWin = window.showModalDialog(url, window, sFeatures);
}

function ConfirmExectue(url,alertmsg){
	if(confirm(alertmsg)){
		ExecuteURL(url);
	}
}


function move(fbox, tbox) {
var arrFbox = new Array();
var arrTbox = new Array();
var arrLookup = new Array();
var i;

index = fbox.selectedIndex;
if (index == -1) return false;

for (i = 0; i < tbox.options.length; i++) {
arrLookup[tbox.options[i].text] = tbox.options[i].value;
arrTbox[i] = tbox.options[i].text;
}
var fLength = 0;
var tLength = arrTbox.length;
for(i = 0; i < fbox.options.length; i++) {
arrLookup[fbox.options[i].text] = fbox.options[i].value;
if (fbox.options[i].selected && fbox.options[i].value != "") {
arrTbox[tLength] = fbox.options[i].text;
tLength++;
}
else {
arrFbox[fLength] = fbox.options[i].text;
fLength++;
   }
}
arrFbox.sort();
//arrTbox.sort();
fbox.length = 0;
tbox.length = 0;
var c;
for(c = 0; c < arrFbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrFbox[c]];
no.text = arrFbox[c];
fbox[c] = no;
}
for(c = 0; c < arrTbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrTbox[c]];
no.text = arrTbox[c];
tbox[c] = no;
   }
}

function PopupPic(sPicURL) { 
	window.open("popfitpic.asp?"+sPicURL, "", "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yesHEIGHT=200,WIDTH=200");
}

function autoResize(id){
    var newheight;
    var newwidth;

    if(document.getElementById){
        newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;
        newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth;
    }

    document.getElementById(id).height= (newheight)+ "px";
    document.getElementById(id).width= (newwidth) + "px";
}

function getReftoDivMod( divID, oDoc ) { 
	if(!oDoc ) { oDoc = document; } 
	if( document.layers ) { 
	if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else { 
	for( var x = 0, y;!y && x < oDoc.layers.length; x++ ) { 
	y = getReftoDivNest(divID,oDoc.layers[x].document); } 
	return y; } } 
	if( document.getElementById ) { return oDoc.getElementById(divID); } 
	if( document.all ) { return oDoc.all[divID]; } 
	return document[divID]; 
} 

function openPerfectpopup(oW,oTitle,oContent) { 
	var x = window.open('','windowName','width=500,height=400,resizable=1'); 
	if(!x ) { return true; } 
	x.document.open(); 
	x.document.write('<html><head><title>'+oTitle+'<\/title><\/head><body>'+ 
	(document.layers?('<layer left="0" top="0" width="'+oW+'" id="myID">') 
	:('<div style="position:absolute;left:0px;top:0px;display:table;width:'+oW+'px;" '+ 
	'id="myID">'))+ 
	oContent+(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>'); 
	x.document.close(); 
	var oH = getReftoDivMod( 'myID', x.document ); if(!oH ) { return false; } 
	var oH = oH.clip? oH.clip.height : oH.offsetHeight; if(!oH ) { return false; } 
	x.resizeto( oW + 200, oH + 200 ); 
	var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body; 
	if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; } 
	else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; } 
	else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; } 
	if( window.opera &&!document.childNodes ) { myW += 16; } 
	x.resizeto( oW + ( ( oW + 200 ) - myW ), oH + ( (oH + 200 ) - myH ) ); 
	if( x.focus ) { x.focus(); } 
	return false; 
} 
