

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function openMasterplan()
{
	window.open("masterplan.html","mp","width=780,height=600");	
}
function openMasterplanprint()
{
	window.open("masterplan-print.html","mp","width=700,height=600,scrollbars=yes");	
}

function popImage(img, caption)
{	
	caption = escape(caption);
	openIT('pop_gl.htm?img='+img+"&caption="+caption,800,550);
	
}
function popImageV2(img, caption,bottomcaption)
{
	caption = escape(caption);
	openIT('pop_gl.htm?img='+img+"&caption="+caption+"&bottomcaption="+bottomcaption,800,550);
}

function popImageDownLoad(img, caption)
{
	caption = escape(caption);
	openIT('pop_gl1.htm?img='+img+"&caption="+caption,800,550);
	//window.open("pop_gl1.htm?img='+img+"&caption="+caption", '',"width=800,height=550,scrollbars=yes,resizable=yes,left=100,top=50");
}

function openIT(u,W,H, sc) {
		var x = (screen.width - W) / 2;
		var y = (screen.height - H) / 2;
		
		//window.open(u, '',"width="+W+",height="+H+",scrollbars="+(sc ? "yes" : "no")+",resizable=Yes, left="+x+",top="+y);
		window.open(u, '',"width="+W+",height="+H+",scrollbars=yes,resizable=Yes, left="+x+",top="+y);
}

function closepopup(){
	document.getElementById('divSurvey').style.display='none';
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function showTab(x,allTabsCount){
for(var i=1;i<(allTabsCount+1);i++)
{	    
var div = document.getElementById('Tab'+i);
if(div){
	
	if(i==x)
	{
		div.style.display='block';
		document.getElementById("c"+i).className="tabsheaderon";}
	else{
		div.style.display='none';
		document.getElementById("c"+i).className="tabsheader";}
	}
	}
}

function ShowSubKey(x,n) {
	var p = document.getElementById("Key"+x);
	if (p.style.display=='none'){
		for(var i=1;i<=n;i++){
			document.getElementById("Key"+i).style.display="none";
	}
	p.style.display='';}
	else{
		p.style.display='none';}
}

/************************/
function SubmitLogin(btn) {
	 // process only the Enter key 
	if (event.keyCode == 13) {
		 // cancel the default submit 
		 event.returnValue=false; 
		 event.cancel = true; 
		 // submit the form by programmatically clicking the specified button 
		 document.getElementById(btn).click();
	} 
}
function CheckLogin(username, password){
	if (Trim(document.getElementById(username).value)=="" || Trim(document.getElementById(password).value)=="")
	 {
		 alert("Please enter your Username and your Password");
		 return false;
	}
	else
	{
	   return true;
	}
}

//change password
function CheckPassword(){
    if (document.Form1.txtPassword.value=="" || document.Form1.txtNewPassword.value=="" || document.Form1.txtConfirmPassword.value=="")
	{
		alert("The following fields are required:\n - Old Password \n - New Password \n - Confirm New Password");
	    return false;
	  }
	else{
		if (document.Form1.txtNewPassword.value!=document.Form1.txtConfirmPassword.value){
			alert("New Password and Confirm New Password do not match");
			return false;
			}
		else{
			return true;
		}
	}
}
function CheckQuestionForm(){
	var msg="";
	if (MM_findObj("txtSubject").value=="")
		msg+=" - Subject is required\n";
	if (MM_findObj("lstTopics").selectedIndex==0)
		msg+=" - Topic is required\n";	
	if (MM_findObj("txtQuestion").value=="" || MM_findObj("txtQuestion").value=="<Enter Question Here>")
		msg+=" - Question is required\n";	
	if (msg!="")
	    {alert(msg);
		return false;
		}
    else
		return true;
	}

function emptytext(txt,msg){
	if (txt.value==msg)
		txt.value='';
}
function filltext(txt,msg){
	if (txt.value=='')
		txt.value=msg;
}



 //TRIM Functions
function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function
function SubmitLogin()
		 {
        // process only the Enter key
        if (event.keyCode == 13)
        {
            // cancel the default submit
            event.returnValue=false;
            event.cancel = true;
            // submit the form by programmatically clicking the specified button
            document.getElementById("ibtnLogin").click();
        }
    }
    
function kd(e)
{
    var intKey = (window.Event) ? e.which : e.keyCode;
    if (intKey == 13) { //enter key
		// cancel the default submit
		document.getElementById("ibtnLogin").click();
		e.Handled = true;
		 event.returnValue=false;
            event.cancel = true;
    }
}