function resizeWindowTo(w,h){
	var l/*eft*/, t/*op*/;
	l = (window.screen.availWidth  - w)/2
	t = (window.screen.availHeight - h)/2
	setWindowTo(w,h,l,t);
	try{
		window.focus();
	}catch(ex){};
}
function setWindowTo(v_width,v_height,v_left,v_top){
	v_left = Math.max(v_left,0);
	if( v_width			 < window.screen.availWidth && 
		v_left + v_width > window.screen.availWidth   ) v_left = window.screen.availWidth - v_width ;

	v_top = Math.max(v_top,0);
	if( v_width			 < window.screen.availWidth && 
		v_top  + v_height > window.screen.availHeight ) v_top  = window.screen.availWidth - v_height ;

	window.moveTo(v_left,v_top);
	window.resizeTo(v_width,v_height);
}

var _w = new Object();
function invokeWindow(strWinName, URL, strAttr){

	//	the following code assures the window is closed, so when it will open, it will float.

	if(null != _w[strWinName]){
		if(_w[strWinName].closed){
			delete _w[strWinName];
		}else{
			try{
				_w[strWinName].close();
				delete _w[strWinName];
			}catch(ex){}
		}
	}

	//	the following code checks if width/height are defined, to centralize window.
	if (null == strAttr) stAttr = '';	
	var arrAttr = String(strAttr).replace(/\s/g,'').split(",");
	var width = false, height = false, top = false, left = false; 
	try{
		var i, arr;
		for (i=0; i<arrAttr.length; i++){
			arr = arrAttr[i].split("=");
			switch(arr[0].toUpperCase()){
				case ("WIDTH" ): width  = parseInt(arr[1]); break;
				case ("HEIGHT"): height = parseInt(arr[1]); break;
				case ("TOP"   ): top    = parseInt(arr[1]); break;
				case ("LEFT"  ): left   = parseInt(arr[1]); break;
			}
		}
	}catch(ex){}

	strAttr = arrAttr.join(",");
	if(false != width && left == false){
		left = (screen.availWidth - width)/2;
		strAttr += ",LEFT="+ left;
	}
	if(false != height && top == false){
		top = (screen.availHeight-height)/2;
		strAttr += ",TOP=" + top;
	}

	// invoking the wiondow
	strWinName = strWinName.split(".")[0];
	_w[strWinName] = window.open(URL, strWinName, strAttr)
	if (null == _w[strWinName]) {
		alert('Could not open a popup window. Are you using a popup blocker?\nPlease enable popups for this site.');
	} else {
		_w[strWinName].focus();
	}

	//return _w[strWinName];
}
function linkRollOver(e){
	if (null == e || null == e.childNodes || 2 > e.childNodes.length || "IMG" != e.childNodes[1].tagName) return;
	e.childNodes[1].src = e.childNodes[1].src.replace("_out.","_over.");
}
function linkRollOut(e){
	if (null == e || null == e.childNodes || 2 > e.childNodes.length || "IMG" != e.childNodes[1].tagName) return;
	e.childNodes[1].src = e.childNodes[1].src.replace("_over.","_out.");
}
function loginClicked(){
	var txtUserName = document.getElementById('txtUserName');
	if(txtUserName.value.length == 0) {
		alert('Please enter your email as your username.');
		txtUserName.focus();
		return;
	}
	__doPostBack('_ctl0$ucLogin$lnkSubmitLogin','');
}
function Textarea_maxLength(t, m){
	if (null == t || null == t.value || m > t.value.length) return true;
	var k = window.event.keyCode ;
	if (k == 8 || k == 46 || k == 0 || k == 9) return true;
	if(event.type == "onchange" || event.type == "onpaste"){
		if (t.value.length >= m){
			t.value = t.value.substr(0,m-1);	
			event.returnValue = false;
		}
	}
	return false;
}

