	// JavaScript Document	
	//------------------------------------
	function ConfirmLogout()
	{
		return confirm("Are you sure that you want to logout?");
	}
	
	function ConfirmDelete(itemType)
	{
		return confirm("Are you sure that you want to delete this " + itemType + "?");
	}
	
	function DeleteFromList(itemType, controlName, value)
	{
		var confirmed = ConfirmDelete(itemType);
		if(confirmed)
		{
			SetValue(controlName, value);
			SubmitForm();
		}
	}
	
	function IsDuplicateValue(firstControlName, secondControlName)
	{
		if(GetValue(firstControlName) == GetValue(secondControlName))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	
	function _IsValidEmail(str)
	{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true
	}
	
	function IsValidEmail(targetName)
	{
		var chkemail = /^([a-zA-Z0-9_\.\-])+(\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4}))+$/;		
		var value = GetValue(targetName);
		//alert(value);
		/*if(value.match(chkemail) == null && value != 0){				
			 return false;
		}*/
		if(!chkemail.test(value))
		{
			 return false;
		}
	return true
	}
	
	function ValidateEmail(ctlName)
	{
		if(!IsValidEmail(ctlName))
		{
			alert("Invalid e-mail address! Please re-enter.\t");
			SetFocus(ctlName);
			return false;
		}
		else
		{
			return true;
		}
	}
	
	function ConfirmPassword(ctlPasswordName, ctlConfirmName)
	{
		if(!IsDuplicateValue(ctlPasswordName, ctlConfirmName))
		{
			alert("Please confirm your password again.");
			SetFocus(ctlConfirmName);
			return false;
		}
		else
		{
			return true;
		}
	}
	
	function OpenWindow(pagePath)
	{
		wd = parseInt(screen.width/2);
		ht = parseInt(screen.height/2);
		l = parseInt((screen.width - wd)/2);
		t = parseInt((screen.height - ht)/2);
		win = window.open(pagePath,'','width=' + wd + ',height=' + ht + ',scrollbars=yes,resizable=yes');
		win.moveTo(l,t);
		return false;
	}
	
	function OpenDefaultWindow(pagePath)
	{
		win = window.open(pagePath,'','scrollbars=yes,resizable=yes');
		return false;
	}
	
	var popUpWin=0;
	
	function popUpPrinitWindow(URLStr)	
	{
		var width = parseInt(screen.width/2);
		var height = parseInt(screen.height-200);
		var left = parseInt((screen.width - width)/2);
		var top = 40;
		
		if(popUpWin)	
		{	
			if(!popUpWin.closed) popUpWin.close();	
		}
		popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
		popUpWin.focus();
	}
	
	function openPrintWindow(contentId)
	{
		var URLStr = "PrintPage.php?contentId=" + contentId;
		popUpPrinitWindow(URLStr);
	}	
	
	function GoUrl(url)
	{
		document.location = url + "?r=" + Math.random(1);
	}
	function GoTo(url)
	{
		document.location = url;
	}
	function GoBack()
	{
		history.back();
	}
	
	function SubmitForm()
	{
		ln = document.forms.length;
		document.forms[ln-1].submit();
	}
	
	function ResetForm()
	{
		myForm = document.forms[0];
		totalControls = myForm.elements.length;
		for(i = 0; i < totalControls; i++)
		{
			if((myForm.elements[i].type == "text") || (myForm.elements[i].type == "password") || (myForm.elements[i].type == "select-one")|| (myForm.elements[i].type == "textarea"))
			{
				myForm.elements[i].value = "";
			}
		}
	}
	
	function VrfySearch()
	{
		var TxtValue = document.FrmSiteSearch.TxtSiteSearch.value;
		if(TxtValue == "" || TxtValue == " ")
		{
			alert("You should enter at least one keyword. \t");		
			SetFocus('TxtSiteSearch');
			return false;	
		}
	}
	
	function AuthenticationNeeded()
	{
		alert("You must login to read this massage.");
		return false;
	}
		
	function PrintThisPage()
	{
		window.print();
		window.close();
	}
	
	function AddToFavorites()
	{	
		title = document.title;
		url = window.location.href;
	
		if (window.sidebar)
		{
			// firefox
			window.sidebar.addPanel(title, url, "");
		}
		else if(window.opera && window.print)
		{ 
			// opera
			var elem = document.createElement('a');
			elem.setAttribute('href',url);
			elem.setAttribute('title',title);
			elem.setAttribute('rel','sidebar');
			elem.click();
		} 
		else if(document.all)
		{
			// ie
			window.external.AddFavorite(url, title);
		}
	}