//this function is used to display please wait while the page
//is still loading
//ver = navigator.appVersion.substring(0,1)
//if (ver >= 4)
//    {
//    document.write('<DIV ID="cache"><TABLE WIDTH=400 BORDER=0 CELLPADDING=2 CELLSPACING=0><TR><TD ALIGN=center VALIGN=middle><TABLE WIDTH=100% BGCOLOR=#FFFFFF BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD ALIGN=center VALIGN=middle><img src="Images/ani_Waiting.gif" width="32" height="32" alt="" border="0"><FONT FACE="Arial, Verdana" SIZE=4><B><BR>PLEASE WAIT ... <BR><BR></B></FONT></TD> </TR></TABLE></TD> </TR></TABLE></DIV>');
//    var navi = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4);
//    var HIDDEN = (navi) ? 'hide' : 'hidden';
//    var VISIBLE = (navi) ? 'show' : 'visible';
//    var cache = (navi) ? document.cache : document.all.cache.style;
//    largeur = screen.width;
//    cache.left = Math.round(100);
//    cache.visibility = VISIBLE;
//    }
//function cacheOff()
//    {
//    if (ver >= 4)
//    	{
//    	cache.visibility = HIDDEN;
//    	}
//    }
function fixUglyIE() 
{ 
	for (a in document.links) document.links[a].onfocus = document.links[a].blur; 
	} 
		if (document.all) 
	{ 
		document.onmousedown = fixUglyIE; 
} 
//function to open new popu window and set the focus to the window
function popStatic(url, name)
	{
	newWindow = window.open(url, name, 'height=320,width=420,resizable=no,scrollbars=no');
	if (window.focus){newWindow.focus();}
	}
//function to open new popu window and set the focus to the window
function OpenPrint(url)
	{
	var newwindow = '';
	//alert(url);
	
	window.open(url, 'Peoka', 'resizable=yes,scrollbars=yes');
	//if (window.focus){newwindow.focus();}
	}
function openWindow(url,name,options)
	 {
	  window.open(url, name, options)
	 }	

// End -->
//This function count how many check boxes has been checked
//by the user
function anyCheck(form) 
{ 
//alert("error");
	var total = 0; 
	var max = form.ckbox.length; 
	for (var idx = 0; idx < max; idx++) 
		{ 
			if (eval("document.form1.ckbox[" + idx + "].checked") == true) 
			{ 
				total += 1; 
			} 
		}
		alert("error");
		//if (total > 2) 
		//	{
				alert("You have selected " + total + " boxes. You can only select a max of 2 boxes"); 
		//		return (false);
		//	}
} 
//check all the check boxes in the table
function CheckAll(checkAllBox)                         
	{                                                                  
		var frm = document.Form1;                               
		var ChkState=checkAllBox.checked;                   
		for(i=0;i< frm.length;i++)                                 
			{                                                                 
				e=frm.elements[i];                                  
				if(e.type=='checkbox' && e.name.indexOf('Id') != -1)
				e.checked= ChkState ;                        
			}                                                               
	}     
	
function CheckChanged()                                   
	{                                                                   
		var frm = document.Form1;                              
		var boolAllChecked;                                         
		boolAllChecked=true;                                       
		for(i=0;i< frm.length;i++)                                 
			{                                                                 
				e=frm.elements[i];                                        
				if ( e.type=='checkbox' && e.name.indexOf('Id') != -1 )
				if(e.checked== false)                                  
					{                                                             
						boolAllChecked=false;                               
						break;                                                    
					}                                                              
			}                                                                  
		for(i=0;i< frm.length;i++)                                  
			{                                                                  
				e=frm.elements[i];                                         
				if ( e.type=='checkbox' && e.name.indexOf('checkAll') != -1 )
					{                                                            
						if( boolAllChecked==false)                         
						e.checked= false ;                                
						else                                                    
						e.checked= true;                                  
						break;                                                    
					}                                                             
			}                                                              
	}                                                                
//check if the T&C box has been checked
function cbTermCondition()
	{
	if (document.getElementById('Reg_ConfirmReg1_cbTC').checked == false)
		{
			alert('Sorry you have to agree to our terms and condition\n before you can register on this site.');
			return false;
		}
	}

//  End --> 
//this function is used to close DIV or open the DIV object called #####
/*
Fading Image Script 
Dynamic Drive (www.dynamicdrive.com)
*/
function makevisible(cur,which)
	{
		if (which==0)
			cur.filters.alpha.opacity=100
		else
			cur.filters.alpha.opacity=60
	}
//function to clear textbox once the user click on the box
function clearBox(box) {
		 if(box.value==box.defaultValue) {
	 	 	 box.value = "";
	 	 }
	 }
//function to check to make sure that user
//enters their peoka name and web site links
function checkPeokaForm()
{
	var sTextBox = "You must enter the following information into the relevant box(es).\n";
	var nChecker = true;
	
	if (document.Form1.RegPeokaNames1_txtName.value == '')
	{
		sTextBox += "Enter your username\n";
		nChecker = false;
		document.Form1.RegPeokaNames1_txtName.style.backgroundColor = "#ffccff";
	}
	
	if (document.Form1.RegPeokaNames1_txtLink.value == '')
	{
		sTextBox += "Enter your web site address\n";
		nChecker = false;
		document.Form1.RegPeokaNames1_txtLink.style.backgroundColor = "#ffccff";
	}
	else if (!validWebSiteAddress(document.Form1.RegPeokaNames1_txtLink))
		{
			sTextBox += "Enter a vaild web site address\n";
			nChecker = false;
		document.Form1.RegPeokaNames1_txtLink.style.backgroundColor = "#ffccff";
		}
		
	if (nChecker == false)
		{
			alert(sTextBox);
			return false;
		}
		return true;
}
//validate user name and password for the respective user
//make sure that the user enters their user and password into the
//text boxes
function checkLogin()
{
	var sTextBox = "You must enter the following information into the relevant box(es).\n";
	var nChecker = true;
	
	if (document.Form1.Login1_txtUsername.value == '')
	{
		sTextBox += "Enter your username\n";
		nChecker = false;
		document.Form1.Login1_txtUsername.style.backgroundColor = "#ffccff";
	}
	
	if (document.Form1.Login1_txtPassword.value == '')
	{
		sTextBox += "Enter your password\n";
		nChecker = false;
		document.Form1.Login1_txtPassword.style.backgroundColor = "#ffccff";
	}
	
	if (nChecker == false)
		{
			alert(sTextBox);
			return false;
		}
		return true;
}
// Check if field contains a valid email address
function validEmail(textObj) 
	{
	var str = textObj.value

	var atsign = str.indexOf('@') // get position of @ sign in string
	var dot = str.lastIndexOf('.')

	if ((atsign < 1) ||                    // '@' cannot be in first position
		(dot <= atsign + 1) ||             // Must be at least one valid char btwn '@' and '.'
		(str.charAt(dot - 1) == '.') ||   // Two dots can not appear in consecutive positions
		(dot == (str.length - 1)) ||       // Must be at least one valid char after '.'
		(str.indexOf(' ')  != -1) ||       // No empty spaces permitted
		(str.indexOf(',')  != -1) ||       // No commas permitted
		(str.indexOf('&quot;')  != -1) ||       // No double quotes permitted
		(str.indexOf('\'')  != -1))        // No single quotes permitted
	{  
	return false;
	}
	return true;
	}
	
function CheckEmailContact()
{
	var sTextBox = "You must enter the following information into the relevant box(es).\n";
	var nChecker = true;
	
	if (document.Form1.Email1_txtName.value == '')
	{
		sTextBox += "Enter your full name\n";
		nChecker = false;
		document.Form1.Email1_txtName.style.backgroundColor = "#ffccff";
	}
	if (!validEmail(document.Form1.Email1_txtEmail)) 
	{
		sTextBox += "Enter a valid email address\n";
		nChecker = false;
		document.Form1.Email1_txtEmail.style.backgroundColor = "#ffccff";
	}
	if (document.Form1.Email1_txtAddress.value == '') 
	{
		sTextBox += "Enter your contact address\n";
		nChecker = false;
		document.Form1.Email1_txtAddress.style.backgroundColor = "#ffccff";
	}
	
	if (nChecker == false)
		{
			alert(sTextBox);
			return false;
		}
		return true;

}
//validate web site address
// Check if field contains a valid email address
function validWebSiteAddress(textObj) 
{
	var str = textObj.value //.Trim();
	var dot = str.lastIndexOf('.')
	//alert('Test');
	var sErr = null;
	var sErr1 = null;
	//if (textObj.value == '') sErr = 'NoK';
	if (str.indexOf('http:') == -1) sErr = 'NoK';
	//if (textObj.value.indexOf('http:')!= 0)  sErr = 'NoK'
	if (str.indexOf('.') == -1)  sErr = 'NoK';
	if (str.indexOf('&quot;') != -1)  sErr = 'NoK';
	if (str.indexOf(',') != -1)  sErr = 'NoK';
	if (str.charAt(dot - 1) == '.')  sErr = 'NoK';
	
	if (sErr != null)
		{  
	//alert(sErr + ' ==  ' + sErr1)
			return false;
		}
	else
		{
			return true;
		}
}
//Check to make sure that user enter both the company name
//and the company's web site address
function CheckComp()
{
	var sTextBox = "You must enter the following information into the relevant box(es).\n";
	var nChecker = true;
	
	if (document.Form1.RegCompany1_txtName.value == '')
	{
		sTextBox += "Enter your Company's name\n";
		nChecker = false;
		document.Form1.RegCompany1_txtName.style.backgroundColor = "#ffccff";
	}
	if (document.Form1.RegCompany1_txtAddress.value == '')  
	{
		sTextBox += "Enter your first line address\n";
		nChecker = false;
		document.Form1.RegCompany1_txtAddress.style.backgroundColor = "#ffccff";
	}
	if (document.Form1.RegCompany1_txtAddress2.value == '')  
	{
		sTextBox += "Enter your second line address\n";
		nChecker = false;
		document.Form1.RegCompany1_txtAddress2.style.backgroundColor = "#ffccff";
	}
	
	if (document.Form1.RegCompany1_ddCountry.options[document.Form1.RegCompany1_ddCountry.options.selectedIndex].value == "Select One")
	{
		sTextBox += "Please select your country\n";
		nChecker = false;
		document.Form1.RegCompany1_ddCountry.style.backgroundColor = "#ffccff";
	}
	
	if (document.Form1.RegCompany1_txtContactEmail.value == '')  
	{
		sTextBox += "Enter your Contact email address\n";
		nChecker = false;
		document.Form1.RegCompany1_txtContactEmail.style.backgroundColor = "#ffccff";
	}
	else if (!validEmail(document.Form1.RegCompany1_txtContactEmail))
	{
		sTextBox += "Enter a valid Contact email address\n";
		nChecker = false;
		document.Form1.RegCompany1_txtContactEmail.style.backgroundColor = "#ffccff";
	}
	
	if (document.Form1.RegCompany1_txtContsctName.value == '')
	{
		sTextBox += "Enter your Contact name\n";
		nChecker = false;
		document.Form1.RegCompany1_txtContsctName.style.backgroundColor = "#ffccff";
	}
	
	if (document.Form1.RegCompany1_txtWebSite.value == '')
		{
			sTextBox += "Enter your website address\n";
			nChecker = false;
			document.Form1.RegCompany1_txtWebSite.style.backgroundColor = "#ffccff";
		}
	else if (!validWebSiteAddress(document.Form1.RegCompany1_txtWebSite))
		{
			sTextBox += "Enter a valid web site address\n";
			nChecker = false;
			document.Form1.RegCompany1_txtWebSite.style.backgroundColor = "#ffccff";
		}
	
	if (nChecker == false)
		{
			alert(sTextBox);
			return false;
		}
		return true;
		
}
//validate user name and password for the respective user
//make sure that the user enters their user and password into the
//text boxes
function checkRegForm()
{
	var sTextBox = "You must enter the following information into the relevant box(es).\n";
	var nChecker = true;
	
	if (document.Form1.CreateAdminUser1_txtFName.value == '')
	{
		sTextBox += "Enter your first name\n";
		nChecker = false;
		document.Form1.CreateAdminUser1_txtFName.style.backgroundColor = "#ffccff";
	}
	
	if (document.Form1.CreateAdminUser1_txtSName.value == '')
	{
		sTextBox += "Enter your surname\n";
		nChecker = false;
		document.Form1.CreateAdminUser1_txtSName.style.backgroundColor = "#ffccff";
	}
	
	if (document.Form1.CreateAdminUser1_txtAddress1.value == '')
	{
		sTextBox += "Enter the first line of your address\n";
		nChecker = false;
		document.Form1.CreateAdminUser1_txtAddress1.style.backgroundColor = "#ffccff";
	}
	
	if (document.Form1.CreateAdminUser1_txtEmail.value == '')
	{
		sTextBox += "Enter your email address\n";
		nChecker = false;
		document.Form1.CreateAdminUser1_txtEmail.style.backgroundColor = "#ffccff";
	}
	
	if (!validEmail(document.Form1.CreateAdminUser1_txtEmail)) 
	{
		sTextBox += "Enter a valid email address\n";
		nChecker = false;
		document.Form1.CreateAdminUser1_txtEmail.style.backgroundColor = "#ffccff";
	}
	
	if (document.Form1.CreateAdminUser1_txtMobile.value == '')
	{
		sTextBox += "Enter your mobile number\n";
		nChecker = false;
		document.Form1.CreateAdminUser1_txtMobile.style.backgroundColor = "#ffccff";
	}
		
	if (document.Form1.CreateAdminUser1_txtPassword.value == '')
	{
		sTextBox += "Enter your password\n";
		nChecker = false;
		document.Form1.CreateAdminUser1_txtPassword.style.backgroundColor = "#ffccff";
	}
	
	if (document.Form1.CreateAdminUser1_txtConfPwd.value == '')
	{
		sTextBox += "Enter your Confirmation password\n";
		nChecker = false;
		document.Form1.CreateAdminUser1_txtConfPwd.style.backgroundColor = "#ffccff";
	}
	
	//if (document.Form1.CreateAdminUser1_txtAnswer.value == '')
	//{
	//	sTextBox += "Enter an answer to the password question\n";
	//	nChecker = false;
	//	document.Form1.CreateAdminUser1_txtAnswer.style.backgroundColor = "#ffccff";
	//}
	
	if (nChecker == false)
		{
			alert(sTextBox);
			return false;
		}
		return true;
}
//validate user name and password for the respective user
//make sure that the user enters their user and password into the
//text boxes
function checkLoginProblem()
{
	var sTextBox = "You must enter the following information into the relevant box(es).\n";
	var nChecker = true;
	
	if (document.Form1.Log_Problem1_txtEmail.value == '')
	{
		sTextBox += "Enter your email address\n";
		nChecker = false;
		document.Form1.Log_Problem1_txtEmail.style.backgroundColor = "#ffccff";
	}
	
	if (document.Form1.Log_Problem1_txtQuestion.value == '')
	{
		sTextBox += "Enter your password question\n";
		nChecker = false;
		document.Form1.Log_Problem1_txtQuestion.style.backgroundColor = "#ffccff";
	}
	
	if (document.Form1.Log_Problem1_txtAnswer.value == '')
	{
		sTextBox += "Enter an answer to the password question\n";
		nChecker = false;
		document.Form1.Log_Problem1_txtAnswer.style.backgroundColor = "#ffccff";
	}
	if (nChecker == false)
		{
			alert(sTextBox);
			return false;
		}
		return true;
}
//check to make sure the email address entered has a @ sign in it
function GetUsername()
	{
		var sEmail = document.Form1.CreateAdminUser1_txtEmail.value;
		//alert(sEmail.indexOf("@"));
		if (sEmail.indexOf("@") > 1)
			{
			//alert(sEmail.indexOf("@"))
				sEmail = sEmail.substring(0, sEmail.indexOf("@"));
				document.Form1.CreateAdminUser1_txtEmplNum.value = sEmail;
			}
		else
			{
				alert('Please! enter a valid email address');
				//document.Form1.CreateAdminUser1_txtEmail.focus;
			}

	}
//highlight row on mouse over and change the colour back to the original color
//once the user has move the mouse away.
 var lastColorUsed;
 function prettyDG_changeBackColor(row, highlight)
	{
		if (highlight)
			{
				lastColorUsed = row.style.backgroundColor;
				row.style.backgroundColor = '#ffccff';
			}
		else
			row.style.backgroundColor = lastColorUsed;
	}
//  End -->
//convert text to upper case
function ConertToUpperCase(UpperCase)
{
	//alert(UpperCase.value);
	UpperCase.value = UpperCase.value.toUpperCase();
}
//Confirm message box to delete item from a data grid
function confirm_delete()
{
  if (confirm("Are you sure you want to delete this product?") == true)
    return true;
  else
    return false;
}
//The method below describes the way to specify a default button to submit when 
//the user hits the enter key in a textbox. 
//This code was download from 
//http://www.bloggingdeveloper.com/post/Default-Button-in-ASPNET-11.aspx
function clickButton(e, buttonid)
{
      var evt = e ? e : window.event;
      var bt = document.getElementById(buttonid);
      
      if (bt)
      { 
          if (evt.keyCode == 13)
          { 
               bt.click(); 
               return false; 
          } 
     } 
}
