var getLocation = location.href;
var colorIt = "";

// JavaScript Document
function whichBrs() {
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1) return 'Opera';
	if (agt.indexOf("staroffice") != -1) return 'Star Office';
	if (agt.indexOf("webtv") != -1) return 'WebTV';
	if (agt.indexOf("beonex") != -1) return 'Beonex';
	if (agt.indexOf("chimera") != -1) return 'Chimera';
	if (agt.indexOf("netpositive") != -1) return 'NetPositive';
	if (agt.indexOf("phoenix") != -1) return 'Phoenix';
	if (agt.indexOf("firefox") != -1) return 'Firefox';
	if (agt.indexOf("safari") != -1) return 'Safari';
	if (agt.indexOf("skipstone") != -1) return 'SkipStone';
	if (agt.indexOf("msie") != -1) return 'Internet Explorer';
	if (agt.indexOf("netscape") != -1) return 'Netscape';
	if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
	if (agt.indexOf('\/') != -1) {
	if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
	return navigator.userAgent.substr(0,agt.indexOf('\/'));}
	else return 'Netscape';} else if (agt.indexOf(' ') != -1)
	return navigator.userAgent.substr(0,agt.indexOf(' '));
	else return navigator.userAgent;
}
var browserName = whichBrs(); 
///////////////////////////////////////////////////////////
//DISABLE BROWSER BACK BUTTON
window.history.forward(1);
///////////////////////////////////////////////////////////
var getSH = screen.Height;
var showWHeight = -1;
if(getSH == 600)
	showWHeight = "285";
else if(getSH > 601 && getSH < 899)
	showWHeight = "458";
else
	showWHeight = "590";
///////////////////////////////////////////////////////////
function goLogout(){	
	location.href='top_header.asp?TimeOutUser=1';	
}
///////////////////////////////////////////////////////////
function showError(num,frmN){

	
	var ErrArray=new Array()
	ErrArray[0]="Whitespaces are not allowed";
     ErrArray[1]="Please fill in the field";
     ErrArray[2]="Field must be numeric(digits) only";	 
	
	alert(ErrArray[num]);
	
	if(frmN!= null){
        	frmN.focus();        	
        }
}
///////////////////////////////////////////////////////////
function IEType(typeNum)
{
	if (typeNum == 1)
	{
		//Print
		print()
	}
	else if (typeNum == 2)
	{
		//Reload
		location.reload()
	}
	else if (typeNum == 3)
	{
		//History Back
		history.go(-1)
	}
	
}
///////////////////////////////////////////////////////////
function ShowChoiceSelect(choiceNum)
	{
		var ShowC1 = document.getElementById("ShowChoices1");
		var ShowC2 = document.getElementById("ShowChoices2");
		
		if (choiceNum == 1)
		{
			ShowC1.style.display="none";
			ShowC2.style.display="";
		}
		else if (choiceNum == 2)
		{
			ShowC1.style.display="";
			ShowC2.style.display="none";
		}
	}
///////////////////////////////////////////////////////////
function OnloadRadioBoxClicked()
	{
		var IncVal = document.form2.CurrIncomeNum;
		var ExVal = document.form2.CurrExpenseNum;
		
		var Showdiv1 = document.getElementById("ShowCdtypes1");
		var Showdiv2 = document.getElementById("ShowCdtypes2");
		var Showdiv3 = document.getElementById("ShowCdtypes3");
		var Showdiv4 = document.getElementById("ShowCdtypes4");

		//checks how many radios
		for (var j=0;j<document.forms[0].radioTypes.length;j++)
		{
			//alert(document.forms[0].radioTypes[j].checked);
		}
		
		//alert("inc== "+document.form2.CurrIncomeNum.value+" ex== "+document.form2.CurrExpenseNum.value);
		if (IncVal.value != "" && ExVal.value == 0)
			{
				//show income
				document.forms[0].radioTypes[0].checked = true;
				Showdiv1.style.display="";
				Showdiv3.style.display="";
				Showdiv2.style.display="none";
				Showdiv4.style.display="none";				
			}
			else if (ExVal.value != "" && IncVal.value == 0)
			{
				//show expense				
				document.forms[0].radioTypes[1].checked = true;
				Showdiv2.style.display="";
				Showdiv4.style.display="";
				Showdiv1.style.display="none";
				Showdiv3.style.display="none";
			}
	}	
///////////////////////////////////////////////////////////
function DisplayValueFields(getValue){
	if(getValue == "income"){
		document.getElementById("ShowCdtypes1").style.display = document.getElementById("ShowCdtypes2").style.display = "block";
		document.getElementById("ShowCdtypes3").style.display = document.getElementById("ShowCdtypes4").style.display = "none";
		CurrExpenseNum = 0;
		CurrExpenseDesc = "none";
	}
	else if(getValue == "expense"){
		document.getElementById("ShowCdtypes3").style.display = document.getElementById("ShowCdtypes4").style.display = "block";
		document.getElementById("ShowCdtypes1").style.display = document.getElementById("ShowCdtypes2").style.display = "none";		
		CurrIncomeNum = 0;
		CurrIncomeDesc = "none";
	}
}
///////////////////////////////////////////////////////////
//using this at user_search page (RADIO BUTTONS)
function RadioBoxClicked(RadioName,FieldName)
{
	bValidOrder = true;

	var Showdiv1 = document.getElementById("ShowCdtypes1");
	var Showdiv2 = document.getElementById("ShowCdtypes2");
	var Showdiv3 = document.getElementById("ShowCdtypes3");
	var Showdiv4 = document.getElementById("ShowCdtypes4");	
	
	//checks if any checked
	if (RadioName.checked=true){
		if (RadioName == "income"){
			RadioName.checked=true;
			Showdiv1.style.display=Showdiv3.style.display="";
			Showdiv2.style.display=Showdiv4.style.display="none";
			//alert("You must enter a value for the Income field.");
			if(document.form2.CurrExpenseNum.value != ""){
				//alert("You can only fill in Income or Expense. Field has been clearned. Please re-enter again.");
				document.form2.CurrExpenseNum.value = 0;
				document.form2.CurrExpenseDesc.value = "none";
				FieldName.focus();
				return false;
			}			
			FieldName.focus();
		}
		else
		{
			RadioName.checked=true;
			Showdiv2.style.display=Showdiv4.style.display="";
			Showdiv1.style.display=Showdiv3.style.display="none";
			if(document.form2.CurrIncomeNum.value != ""){
				//alert("You can only fill in Income or Expense. Field has been clearned. Please re-enter again.");
				document.form2.CurrIncomeNum.value = 0;
				document.form2.CurrIncomeDesc.value = "none";
				FieldName.focus();
				return false;
			}	
			FieldName.focus();
		}		
	}
	else
	{
		RadioName.checked=false;
		//alert("not clicked");
	}
}
///////////////////////////////////////////////////////////
function checkInvalidChars(checkValue,formName)
{
	
	//alert(checkValue);
	var invalidChars = "'&#$\/%^|,;^~(){}><[]?*!";
	
	for (i=0; i < invalidChars.length; i++)
	    {	
		badChar = invalidChars.charAt(i);
		//alert(badChar);
		if (checkValue.indexOf(badChar,0) > -1)
		{			
			alert("Invalid charecter: "+badChar);
			return false;
		}
	    }
	    
	    return true;
	/*re = /[^a-zA-Z_0-9]/;
	badChar = re.test(checkValue);
	if (badChar) 
	{
		//alert("Invalid Chars --."+badChar);
		showError(53,formName);
		return false;
	}
	return true;*/
}
///////////////////////////////////////////////////////////
function CheckEmpty(msgNum,formName)
{    
	if(formName.value.split(" ").join("") == "")
	{        	
        	return false;
	}
	
	if (formName.value == "")
	{
	 	return false;
	}
	
	return true;      
}
///////////////////////////////////////////////////////////      
function isWhitespace(msgNum,formName)
{   
   if(formName.value.split(" ").join("") == "")
	{
        	showError(msgNum,formName);
        	return false;
	}
    return true;

}

///////////////////////////////////////
function checkSelect(msg,frmName)
{ 
	//alert(frmName);
	if(frmName.selectedIndex==0)
	{
		showError(msg,frmName);	
		return false;
	}
	else
		return true;
       
}
///////////////////////////////////////
function checkSelect2(msg,frmName)
{ 
	
	//alert(frmName.value);
	if(frmName.value == -1)
	{
		showError(msg,frmName);	
		return false;
	}
	else
		return true;
       
}
 ///////////////////////////////////////////////////////////    
 function checkLength(msgNum,formName,controlLength)
{
	if(formName.value.length!=controlLength)
	{         
		showError(msgNum,formName);
		formName.focus();
		return false;
	}
}
 ///////////////////////////////////////////////////////////    
function TimeRange(min,max,formName,msgNum)
{
	if((formName.value<min)||(formName.value>max))
	{  
		showError(msgNum,formName);
		return false;
	}
}
///////////////////////////////////////////////////////////   
function nums(msgNum,formName)
 { 
	  if (isNaN(formName.value) )//|| parseInt(formName.value) < 1
      	  {
		return false;
	  }
	 // check to make sure the current value is greater then zero (positive integer)
	/*if( parseInt(formName.value) < 1 )
  	{  
	   	
		showError(msgNum,formName);    	
		formName.focus();
		return false;
  	}*/
	return true;
}	
///////////////////////////////////////////////////////////   
function validateDecimal(msgNum,formName)
{
	if (formName.value.indexOf(".") == -1)
	{
		return false;
	}
	return true;
}	
///////////////////////////////////////////////////////////   
// check to make sure the current value is greater then zero (positive integer)
function Poznums(msgNum,formName)
{
  if( parseInt(formName.value) < 1 )
  {  
   	
	showError(msgNum,formName);    	
	formName.focus();
	return false;
  }
  return true;
}
///////////////////////////////////////////////////////////   
function CheckBoxed(msgNum,formName)
{
	if (formName.checked==false)
	{
		
		showError(msgNum,formName);    	
		formName.focus();
		return false;
	}
}
///////////////////////////////////////////////////////////
function checkStrLenWithRange(upper,lower,msg,formName){
	
	if(formName.value.length>upper||formName.value.length<lower){		
		
		showError(msg,formName);
		formName.focus();
		return false;
	}
	return true;
}
///////////////////////////////////////////////////////////
function checkEmail(msgNum,formName)
{
	if(formName.value.indexOf("@")==-1 || formName.value.indexOf(".")==-1){
		
		//showError(37,document.form1.email);
		showError(msgNum,formName);
		return false;
	}
	return true;
}
///////////////////////////////////////////////////////////
function CheckSpecified(msgNum,formName)
{ 
   
	if(formName.value.indexOf(" ")==-1)
	{
		if (formName.value == ""){
						
			showError(msgNum,formName);
			formName.focus()
			return ;
		}
	}
	else
	{               
		
		showError(0,formName);	
		formName.focus();
		return;
	}
}
///////////////////////////////////////////////////////////    
function checkEquals(formName,formName2,msgNum){
	
	if(formName.value != formName2.value){
		
		showError(msgNum,formName2);		
		return false;
	}
	return true;
}

///////////////////////////////////////////////////////////
//DO NOT DELETe - for menu tree
img1=new Image()
img1.src="/images/fold.gif"
img2=new Image()
img2.src="/images/open.gif"
ns6_index=0

function change(e)
{
	
	if(!document.all&&!document.getElementById)
	{return}

	if (!document.all&&document.getElementById)
	{ns6_index=1}

	var source=document.getElementById&&!document.all? e.target:event.srcElement
	//alert(""+event.srcElement);	
	if (source.className=="folding")
	{
		var source2=document.getElementById&&!document.all? source.parentNode.childNodes:source.parentElement.all
		if (source2[2+ns6_index].style.display=="none")
		{
			//to close select (-)
			source2[0].src="/images/open.gif"
			source2[2+ns6_index].style.display=''
		}
		else
		{
			//to opens select (+)
			source2[0].src="/images/fold.gif"
			source2[2+ns6_index].style.display="none"
		}
	}
}
document.onclick=change
///////////////////////////////////////////////////////////
//PUT IN INPUT FIELD = onfocus="displayInputFocus(this.name);" onblur="displayInputRemove(this.name);"
//changes color of input text field ONLY
function displayInputFocus(FieldName)
{
	var displaybg=FieldName;
	var displaybg=document.getElementById(displaybg);
	displaybg.style.border="1px solid #F80002";
	//displaybg.style.backgroundColor="#E8E8E0";
}
///////////////////////////////////////////////////////////
function displayInputRemove(FieldName)
{
	var displaybg=FieldName;
	var displaybg=document.getElementById(displaybg);
	displaybg.style.border="1px solid #434343";
	//displaybg.style.backgroundColor="#EADEC3";
}
///////////////////////////////////////////////////////////
function TopMenuColour(getID,getNum){
	if(getNum == 0)
		document.getElementById(getID).style.color="#F5CB00";
	else
		document.getElementById(getID).style.color="#FFFFFF";
}
///////////////////////////////////////////////////////////
function ConfirmAlert(getURL)
{
	//alert("ssad=== "+getURL)	
	input_box=confirm("Are you sure you want to delete?\nOK = Yes\nCancel = No");
	if (input_box==true){ 
		// Output when OK is clicked
		location.href = getURL;
	}
	else{
		// Output when Cancel is clicked
		//alert ("You clicked cancel");
		return false;
	}
}
///////////////////////////////////////////////////////////
function GoToURL(theURL){
	location.href=theURL;
}
///////////////////////////////////////////////////////////
function FadeIt(getNum,getID) {	
	var nodeObj = document.getElementById(getID)	
	if(browserName == "Internet Explorer"){
		nodeObj.style.filter = "progid:DXImageTransform.Microsoft.Fade(duration=0.5)"
    nodeObj.filters[0].Apply();     	
    nodeObj.filters[0].Play();
  }
  else{
  	if(getNum == 1)
  		nodeObj.className = "MenuOn";
  	else
  		nodeObj.className = "MenuOff";
  }
  
  ColoriT();
  
}
///////////////////////////////////////////////////////////
function ColoriT(){

	if(getLocation.indexOf("about") != -1)
		colorIt = "menu1";		
	else if(getLocation.indexOf("journalism") != -1)
		colorIt = "menu2";
	else if(getLocation.indexOf("photo") != -1)
		colorIt = "menu3";
	else if(getLocation.indexOf("speaker") != -1)
		colorIt = "menu4";
	else if(getLocation.indexOf("design") != -1)
		colorIt = "menu5";
	else
		colorIt = "";

	if(colorIt != "")
		document.getElementById(colorIt).className = "MenuOn";
}
//////////////////////////////////////////////////////////////////////////////////
function right(e) {
var msg = "Sorry, you don't have permission to right-click.";
if (navigator.appName == 'Netscape' && e.which == 3) {
	alert(msg);
	return false;
}
if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
	alert(msg);
	return false;
}
else return true;
}

function rightClickTrap() 
{
if(document.images){
  for(i=0;i<document.images.length;i++){
    document.images[i].onmousedown = right;
    document.images[i].onmouseup = right;
    }
  }
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////