//
// Change image on mouse over.
//

function turnOn(imageName) {
  if (document.images) {
    document[imageName].src = eval(imageName + "_on.src");
  }
}

function turnOff(imageName) {
  if (document.images) {
    document[imageName].src = eval(imageName + "_off.src");
  }
}



function login(pstrContinueUrl){
	if(pstrContinueUrl=="" || pstrContinueUrl == null)
		pstrContinueUrl="stg_default.jsp";
		
		
	comsOpenPopupSize("/stg_login.jsp?LoginContinueURL="+pstrContinueUrl+"", "login", 300, 200, "N", "Y", "N", "N", "N");	

}
function validEmail(email) {
	invalidChars = "/:,;";

	for (x=0; x<invalidChars.length; x++){
		badChar = invalidChars.charAt(x);
		if (email.indexOf(badChar, 0) > -1) {
			return false;
		}	
	}
	
	atPos = email.indexOf("@",1)
	if (atPos==-1) {
		return false;
	}
	if (email.indexOf("@", atPos+1)>-1) {
		return false;
	}
	
	periodPos = email.indexOf(".", atPos)
	if (periodPos == -1) {
		return false;
	}
	if (periodPos+3 > email.length) {
		return false;
	}
	
	return true;
}

function comsOpenPopupSize(pstrURL, pstrWindowName, pintWidth, pintHeight, pstrResize, pstrScroll, pstrMenuBar, pstrToolBar, pstrLocation) {
	var pobjWindow, pintTop, pintLeft, pstrNNResize="", pstrNNScroll="";
	
	pintTop = (screen.availHeight/2-(pintHeight/2));
	pintLeft = (screen.availWidth/2-(pintWidth/2));

	if (pintWidth>screen.availWidth*0.95) {
		pintWidth=screen.availWidth*0.95;
	}
	if (pintHeight>screen.availHeight*0.95) {
		pintHeight=screen.availHeight*0.95;
	}

	if (pstrResize == 'yes'){
		pstrNNResize = 'resizable';
	}
	else {
		pstrNNResize = '';
	}

	if (pstrScroll == 'yes'){
		pstrNNScroll = 'scrollable';
	}
	else {
		pstrNNScroll = '';
	}
	
	if (navigator.appName == 'Microsoft Internet Explorer') {
		pobjWindow = window.open(pstrURL, pstrWindowName, "directories=yes, location="+pstrLocation+", menubar="+pstrMenuBar+", resizable="+ pstrResize +", scrollbars="+ pstrScroll +", status=yes, toolbar="+pstrToolBar+", height="+pintHeight+", width="+pintWidth+",top="+pintTop+",left="+pintLeft);
	}	
	else {
		pobjWindow = window.open(pstrURL,pstrWindowName,pstrNNResize+","+pstrNNScroll+",height="+pintHeight+", width="+pintWidth);
	}
	pobjWindow.focus();
}





function getItem(pstrId){
	return document.getElementById(pstrId);
}


function hideItem(pstrId, pblnClearValue){
//	alert("Hiding: "  + pstrId);
	document.getElementById(pstrId).style.display="none";

}

function showItem(pstrId){
//	alert("Showing: "  + pstrId);
	document.getElementById(pstrId).style.display="";
}

function setItem(pstrId,pstrValue){
//	alert("Showing: "  + pstrId);
	document.getElementById(pstrId).innerHTML=pstrValue;
} 

function setAndShowItem(pstrId,pstrValue){
//	alert(pstrId + " = " + pstrValue);
	setItem(pstrId,pstrValue); 
	showItem(pstrId);
}


function setFocus(){
 var flag=false;
 for(z=0;z<document.forms.length;z++){
  var form = document.forms[z];
  var elements = form.elements;
  for (var i=0;i<elements.length;i++){
    var element = elements[i];
    if((element.type == 'textarea' || element.type == 'text') &&
      !element.readOnly &&
      !element.disabled){ 
      element.focus();
	  flag=true;
     break;
    }
  }
  if(flag)break;
 }
}

function setFocusForm(pobjForm){
 var flag=false;
  var form =pobjForm
  var elements = form.elements;
  for (var i=0;i<elements.length;i++){
    var element = elements[i];
    if((element.type == 'textarea' || element.type == 'text') &&
      !element.readOnly &&
      !element.disabled){ 
      element.focus();
	  flag=true;
     break;
    }
  }

}