var WinId = new Array();
CurrentWin = 0;


function trim(sString){
while (sString.substring(0,1) == ' '){
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' '){
sString = sString.substring(0,sString.length-1);
}
return sString;
}

//--------------------------------------------------------------------



function ShowWaiting(){
				
	   	var divName="divShowWaiting" ;
	   	var divDetailPane = document.getElementById(divName);

			if (divDetailPane.style.display == 'none'){
				divDetailPane.style.display='block';
			}
			else{
            	divDetailPane.style.display = 'none';
        	}
			

}

//--------------------------------------------------------------









function FormSubmit(){

pw = document.frm.txt_PassWord.value;
cpw = document.frm.txt_ConfPassWord.value;
un = document.frm.txt_UserName.value;
name = document.frm.txt_FirstName.value;



if (checkNull(name) == false){
    alert("Please enter your First Name");
	document.frm.txt_FirstName.focus();
	return false;
}else if (checkNull(un) == false){
    alert("Please enter a Username");
	document.frm.txt_UserName.focus();
	return false;
}else if(checkNull(pw) == false){
    alert("Please enter a Password");
	document.frm.txt_PassWord.focus();
	return false;	
}else if(checkNull(cpw) == false){	
    alert("You did not fill the Confirm Password");
	document.frm.txt_ConfPassWord.focus();
	return false;		
}else if (Accept() == false) {
	alert("To open an account you must agree to the Terms and Conditions and Privacy Policy by placing a tick in the box.");
	document.frm.checkbox_Accept.focus();
	return false;
}else if (alphanumeric(pw) == false){
	alert("Your Password is not Alpha Numeric OR It may Empty.\n You need to fill the Password. \n Do not copy and paste the password \n It has to be 8 charaters long and can contain only Numbers and Letters");
	document.frm.txt_PassWord.focus();
	return false;
}else if (alphanumeric(cpw) == false){
	alert("Your Password Confirmation is not Alpha Numeric OR Empty. Password can contain only Numbers and Letters");
	document.frm.txt_ConfPassWord.focus();
	return false;
//}else if (alphanumeric(un) == false){//This is thw e place
}else if (echeck(un) == false){
	alert("Your Username is not a Valid Email Address OR Empty.");
	document.frm.txt_UserName.focus();
	return false;
}else if (CountPass() == false){
	alert("Your Password must be 8 characters");
	document.frm.txt_PassWord.focus();
	return false;
}else if (CheckPass() == false) {
	alert("Your Password and confirm password did not match / Password is Empty");
	document.frm.txt_PassWord.focus();
	return false;
}else{
	document.frm.submit();
    return true;
}
	

}//FormSubmit





//----------------------------------------------------------------

function CheckPass(){
var pass;
var confpass;

pass = document.frm.txt_PassWord.value;
confpass = document.frm.txt_ConfPassWord.value;
if (pass == confpass){
return true;
}else{
return false;
}


}

//----------------------------------------------------------------
//----------------------------------------------------------------


function CheckPass2(selectedRow){
var pass;
var confpass;


pass=eval("document.frm.txt_Password" + selectedRow + ".value;");
confpass=eval("document.frm.txt_ConfirmPassword" + selectedRow + ".value;");

if (pass == confpass){
return true;
}else{
return false;
}


}






function CountPass2(selectedRow){
var pass;
var confpass;

pass=eval("document.frm.txt_Password" + selectedRow + ".value.length;");
confpass=eval("document.frm.txt_ConfirmPassword" + selectedRow + ".value.length;");


if ( (pass < 8) || (pass > 8) ){
return false;
}else{
return true;
}


}

//------------------------------------------------------------
//----------------------------------------------------------------





//----------------------------------------------------------------


function alphanumeric(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	{
			 return false;
		  }
		}
 return true;
}

//--------------------------------------------------------------------



function Accept(){

if (document.frm.checkbox_Accept.checked == true){
return true;
}else{
return false;
}
}


//----------------------------------------------------------------

function CountPass(){
var pass;
var confpass;

pass = document.frm.txt_PassWord.value.length;
confpass = document.frm.txt_ConfPassWord.value.length;


if ( (pass < 8) || (pass > 8) ){
return false;
}else{
return true;
}


}

//------------------------------------------------------------

function checkNull(fvalue){
	if (fvalue == ''){
		return false;
	}else{
		return true;
	}
}


//------------------------------------------------------------

function openCalPopup1 (install,loopid,SelName,SelDate) {
	var Chaeck;
	openWin1("../Common/calendar/calendar.php?loopid="+loopid+"&strActionX=newx&form=window.opener.document.frm&install="+install+"&SelDate="+SelDate, "", 185, 180, false, true, 350, 550);	

}

//------------------------------------------------------------



function openWin1(where,name,w,h,scroll,fullsc,t,l) {
	var sc;
	

	if (scroll) sc="yes"; else sc="0";
	if (navigator.appName.indexOf("Netscape") != -1 ) {
		
		return WinId[CurrentWin++]=window.open( where,name,"LEFT="+l+",TOP="+t+",WIDTH="+w+",HEIGHT="+h+",STATUS=NO,TOOLBAR=0,SCROLLBARS="+sc+",RESIZABLE=NO");
	}
	else {
		
		return WinId[CurrentWin++]=window.open(	where,name,"LEFT="+l+",TOP="+t+",WIDTH="+w+",HEIGHT="+h+",STATUS=NO,TOOLBAR=0,SCROLLBARS="+sc+",RESIZABLE=NO");
	}
}


//-------------------------------------------------------

function showProviceStateUS(){
	
	var RefElement1 = document.getElementById("CountryIdHidden");
	
	var RefElement2 = document.getElementById("USAIdShow");
	var RefElement5 = document.getElementById("CanadaIdShow");
	var RefElement3 = document.getElementById("cId");
	
	RefElement1.value = 225;

        RefElement3.style.display='none';	
		RefElement5.style.display='none';	
	    RefElement2.style.display='block';			
		
}



//-------------------------------------------------------
function showProviceState(){

	var RefElement = document.getElementById("cId");//This is the country drop down
	var RefIndex;
	RefIndex = RefElement.selectedIndex;
	
	var RefElement1 = document.getElementById("OtherRow");
	var RefElement2 = document.getElementById("CanadaStateProvinceRow");
	var RefElement3 = document.getElementById("USStateProvinceRow");
	
	
	if (RefIndex == 225){//This is USA
	
		RefElement2.style.display='none';	
		RefElement1.style.display='none';	
	    RefElement3.style.display='block';			
		
	}else if (RefIndex == 37){//This is CANADA
	
		RefElement3.style.display='none';	
		RefElement1.style.display='none';	
	    RefElement2.style.display='block';			
		
	}else{//This is Other
	
		RefElement3.style.display='none';	
		RefElement2.style.display='none';	
	    RefElement1.style.display='block';		
	}
	
	
	
	
	
	
	
}






//-------------------------------------------------------


function showProviceStateCanada(){

	var RefElement1 = document.getElementById("CountryIdHidden");
	var RefElement2 = document.getElementById("CanadaIdShow");
	var RefElement3 = document.getElementById("cId");
	

	var RefElement5 = document.getElementById("USAIdShow");
	RefElement1.value=35;

		RefElement2.style.display='block';	
		RefElement3.style.display='none';	
		RefElement5.style.display='none';	
		

	
}


//-------------------------------------------------------

function showProviceStateOther(){

	var RefElement2 = document.getElementById("CanadaIdShow");
	var RefElement5 = document.getElementById("USAIdShow");
	var RefElement3 = document.getElementById("cId");
	

		RefElement2.style.display='none';	
		RefElement5.style.display='none';	
		RefElement3.style.display='block';	
	
}

//-------------------------------------------------------


/**
 * Email validation script. 
 */

function echeck(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 showForm_old(RowName,Icon,Row){

frm.hiddenSelectedRow.value = Row;//when we do the saving we need to know the selected row index. Here the index is assigning to a 
//hidden variable
	
	
var ElementRow0,ElementRow1,ElementRow2,ElementRow3,ElementRow4;

ElementRow0=document.getElementById("frm_0");
ElementRow1=document.getElementById("frm_1");
ElementRow2=document.getElementById("frm_2");
ElementRow3=document.getElementById("frm_3");
ElementRow4=document.getElementById("frm_4");

CurRow0=document.getElementById("cur_row0");
CurRow1=document.getElementById("cur_row1");
CurRow2=document.getElementById("cur_row2");
CurRow3=document.getElementById("cur_row3");
CurRow4=document.getElementById("cur_row4");


if (RowName == "frm_0"){
ElementRow0.style.display="";
ElementRow1.style.display="none";
ElementRow2.style.display="none";
ElementRow3.style.display="none";
ElementRow4.style.display="none";

CurRow0.style.background="#CCFFCC";
CurRow1.style.background="#FBE3AE";
CurRow2.style.background="#FBE3AE";
CurRow3.style.background="#FBE3AE";
CurRow4.style.background="#FBE3AE";



}


if (RowName == "frm_1"){
ElementRow0.style.display="none";
ElementRow1.style.display="";
ElementRow2.style.display="none";
ElementRow3.style.display="none";
ElementRow4.style.display="none";

CurRow0.style.background="#FBE3AE";
CurRow1.style.background="#CCFFCC";
CurRow2.style.background="#FBE3AE";
CurRow3.style.background="#FBE3AE";
CurRow4.style.background="#FBE3AE";

}

if (RowName == "frm_2"){
ElementRow0.style.display="none";
ElementRow1.style.display="none";
ElementRow2.style.display="";
ElementRow3.style.display="none";
ElementRow4.style.display="none";


CurRow0.style.background="#FBE3AE";
CurRow1.style.background="#FBE3AE";
CurRow2.style.background="#CCFFCC";
CurRow3.style.background="#FBE3AE";
CurRow4.style.background="#FBE3AE";

}

if (RowName == "frm_3"){
ElementRow0.style.display="none";
ElementRow1.style.display="none";
ElementRow2.style.display="none";
ElementRow3.style.display="";
ElementRow4.style.display="none";

CurRow0.style.background="#FBE3AE";
CurRow1.style.background="#FBE3AE";
CurRow2.style.background="#FBE3AE";
CurRow3.style.background="#CCFFCC";
CurRow4.style.background="#FBE3AE";


}

if (RowName == "frm_4"){
ElementRow0.style.display="none";
ElementRow1.style.display="none";
ElementRow2.style.display="none";
ElementRow3.style.display="none";
ElementRow4.style.display="";

CurRow0.style.background="#FBE3AE";
CurRow1.style.background="#FBE3AE";
CurRow2.style.background="#FBE3AE";
CurRow3.style.background="#FBE3AE";
CurRow4.style.background="#CCFFCC";

}

}

//----------------------------------------------------------------------------




function showForm(RowName,Icon,Row){

frm.hiddenSelectedRow.value = Row;//when we do the saving we need to know the selected row index. Here the index is assigning to a 
//hidden variable
	
	
var ElementRow0,ElementRow1,ElementRow2,ElementRow3,ElementRow4;
/*
ElementRow0=document.getElementById("frm_0");
ElementRow1=document.getElementById("frm_1");
ElementRow2=document.getElementById("frm_2");
ElementRow3=document.getElementById("frm_3");
ElementRow4=document.getElementById("frm_4");
*/

CurRow0=document.getElementById("cur_row0");
CurRow1=document.getElementById("cur_row1");
CurRow2=document.getElementById("cur_row2");
CurRow3=document.getElementById("cur_row3");
CurRow4=document.getElementById("cur_row4");


if (RowName == "frm_0"){
/*
ElementRow0.style.display="";
ElementRow1.style.display="none";
ElementRow2.style.display="none";
ElementRow3.style.display="none";
ElementRow4.style.display="none";
*/
CurRow0.style.background="#CCFFCC";
CurRow1.style.background="#FBE3AE";
CurRow2.style.background="#FBE3AE";
CurRow3.style.background="#FBE3AE";
CurRow4.style.background="#FBE3AE";



}


if (RowName == "frm_1"){
/*
ElementRow0.style.display="none";
ElementRow1.style.display="";
ElementRow2.style.display="none";
ElementRow3.style.display="none";
ElementRow4.style.display="none";
*/
CurRow0.style.background="#FBE3AE";
CurRow1.style.background="#CCFFCC";
CurRow2.style.background="#FBE3AE";
CurRow3.style.background="#FBE3AE";
CurRow4.style.background="#FBE3AE";

}

if (RowName == "frm_2"){
/*
ElementRow0.style.display="none";
ElementRow1.style.display="none";
ElementRow2.style.display="";
ElementRow3.style.display="none";
ElementRow4.style.display="none";
*/

CurRow0.style.background="#FBE3AE";
CurRow1.style.background="#FBE3AE";
CurRow2.style.background="#CCFFCC";
CurRow3.style.background="#FBE3AE";
CurRow4.style.background="#FBE3AE";

}

if (RowName == "frm_3"){
	/*
ElementRow0.style.display="none";
ElementRow1.style.display="none";
ElementRow2.style.display="none";
ElementRow3.style.display="";
ElementRow4.style.display="none";
*/
CurRow0.style.background="#FBE3AE";
CurRow1.style.background="#FBE3AE";
CurRow2.style.background="#FBE3AE";
CurRow3.style.background="#CCFFCC";
CurRow4.style.background="#FBE3AE";


}

if (RowName == "frm_4"){
	/*
ElementRow0.style.display="none";
ElementRow1.style.display="none";
ElementRow2.style.display="none";
ElementRow3.style.display="none";
ElementRow4.style.display="";
*/
CurRow0.style.background="#FBE3AE";
CurRow1.style.background="#FBE3AE";
CurRow2.style.background="#FBE3AE";
CurRow3.style.background="#FBE3AE";
CurRow4.style.background="#CCFFCC";

}

}














//-------------------------------------------------------

function submitUserForm_old(){
	
selectedRow = frm.hiddenSelectedRow.value

pw=eval("document.frm.txt_Password" + selectedRow + ".value;");//txt_FirstName
cpw=eval("document.frm.txt_ConfirmPassword" + selectedRow + ".value;");//txt_LastName
un=eval("document.frm.txt_UserName" + selectedRow + ".value;");//txt_UserName
name=eval("document.frm.txt_FirstName" + selectedRow + ".value;");//txt_Password



if (checkNull(name) == false){
    alert("You did not fill the First Name");
	eval("document.frm.txt_FirstName" + selectedRow + ".focus();");
	return false;
}else if (checkNull(un) == false){
    alert("You did not fill the Username");
	eval("document.frm.txt_UserName" + selectedRow + ".focus();");
	return false;
}else if(checkNull(pw) == false){
    alert("You did not fill the Password");
	eval("document.frm.txt_Password" + selectedRow + ".focus();");
	return false;	
}else if(checkNull(cpw) == false){	
    alert("You did not fill the Confirm Password");
	eval("document.frm.txt_ConfirmPassword" + selectedRow + ".focus();");	
	return false;		
}else if (alphanumeric(pw) == false){
	alert("Your Password is not Alpha Numeric OR It may Empty.\n You need to fill the Password. \n Do not copy and paste the password \n It has to be 8 charaters long and can contain only Numbers and Letters");
	eval("document.frm.txt_Password" + selectedRow + ".focus();");	
	return false;
}else if (alphanumeric(cpw) == false){
	alert("Your Password Confirmation is not Alpha Numeric OR Empty. Password can contain only Numbers and Letters");
	eval("document.frm.txt_ConfirmPassword" + selectedRow + ".focus();");
	return false;
}else if (echeck(un) == false){
	alert("Your Username is not a Valid Email Address OR Empty.");
	eval("document.frm.txt_UserName" + selectedRow + ".focus();");	
	return false;
}else if (CountPass2(selectedRow) == false){
	alert("Your Password has to be 8 characters long");
	eval("document.frm.txt_Password" + selectedRow + ".focus();");	
	return false;
}else if (CheckPass2(selectedRow) == false) {
	alert("Your Password and confirm password did not match / Password is Empty");
	eval("document.frm.txt_Password" + selectedRow + ".focus();");		
	return false;
}else{
	document.frm.submit();
    return true;
}



}

//----------------------------------------------------


function validateAdminForm(row){
	
selectedRow = row;
displayRow=selectedRow+1;

pw=eval("document.frm.txt_Password" + selectedRow + ".value;");//txt_FirstName
cpw=eval("document.frm.txt_ConfirmPassword" + selectedRow + ".value;");//txt_LastName
un=eval("document.frm.txt_UserName" + selectedRow + ".value;");//txt_UserName
name=eval("document.frm.txt_FirstName" + selectedRow + ".value;");//txt_Password



if (checkNull(name) == false){
    alert("You did not fill the First Name in Row " + displayRow);
	eval("document.frm.txt_FirstName" + selectedRow + ".focus();");
	return false;
}else if (checkNull(un) == false){
    alert("You did not fill the Username in Row " + displayRow);
	eval("document.frm.txt_UserName" + selectedRow + ".focus();");
	return false;
}else if(checkNull(pw) == false){
    alert("You did not fill the Password in Row " + displayRow);
	eval("document.frm.txt_Password" + selectedRow + ".focus();");
	return false;	
}else if(checkNull(cpw) == false){	
    alert("You did not fill the Confirm Password in Row " + displayRow);
	eval("document.frm.txt_ConfirmPassword" + selectedRow + ".focus();");	
	return false;		
}else if (alphanumeric(pw) == false){
	alert("Your Password is not Alpha Numeric OR It may Empty in Row " + displayRow  + "\n You need to fill the Password. \n Do not copy and paste the password \n It has to be 8 charaters long and can contain only Numbers and Letters");
	eval("document.frm.txt_Password" + selectedRow + ".focus();");	
	return false;
}else if (alphanumeric(cpw) == false){
	alert("Your Password Confirmation is not Alpha Numeric OR Empty in Row " + displayRow  + ".\n Password can contain only Numbers and Letters");
	eval("document.frm.txt_ConfirmPassword" + selectedRow + ".focus();");
	return false;
}else if (echeck(un) == false){
	alert("Your Username is not a Valid Email Address OR Empty in Row " + displayRow);
	eval("document.frm.txt_UserName" + selectedRow + ".focus();");	
	return false;
}else if (CountPass2(selectedRow) == false){
	alert("Your Password and Confirm Password have to be 8 characters long in Row " + displayRow);
	eval("document.frm.txt_Password" + selectedRow + ".focus();");	
	return false;
}else if (CheckPass2(selectedRow) == false) {
	alert("Your Password and confirm password did not match / Password is Empty in Row " + displayRow);
	eval("document.frm.txt_Password" + selectedRow + ".focus();");		
	return false;
}else{
    return true;
}



}

//----------------------------------------------------





function submitUserForm(accFree){
//checkNull == true means there is a value in that field
//checkNull == false means there is no value in that field

if (accFree == "FREE")
{
var	freeAccEdit = 0;
}
else
{
freeAccEdit = 4;	
}
checkValidate=true;

for (selectedRow=0;selectedRow<=freeAccEdit;selectedRow++){
	

hidden_user_id=eval("document.frm.SysUserId" + selectedRow + ".value;");//SysUserId

pw=eval("document.frm.txt_Password" + selectedRow + ".value;");//txt_password
cpw=eval("document.frm.txt_ConfirmPassword" + selectedRow + ".value;");//txt_confirm_pass
un=eval("document.frm.txt_UserName" + selectedRow + ".value;");//txt_UserName
name=eval("document.frm.txt_FirstName" + selectedRow + ".value;");//txt_firstaname
lname=eval("document.frm.txt_LastName" + selectedRow + ".value;");//txt_lastname

pw=trim(pw);
cpw=trim(cpw);
un=trim(un);
name=trim(name);
lname=trim(lname);

register=eval("document.frm.checkbox_Register" + selectedRow + ".checked;");//check Register
edit=eval("document.frm.checkbox_Edit" + selectedRow + ".checked;");//check Edit
value=eval("document.frm.checkbox_Value" + selectedRow + ".checked;");//check Value
admin=eval("document.frm.checkbox_Admin" + selectedRow + ".checked;");//check Admin

if (hidden_user_id == ''){//This is an insert row - checked correct
			
			if ( (checkNull(pw) == false) && (checkNull(cpw) == false) && (checkNull(un) == false) && (checkNull(name) == false) && (checkNull(lname) == false) && (!register) && (!edit) && (!value) && (!admin) ){
			//we can neglect this row and No need to insert this row
			}else{
					//check this row for required fields and if all are satisfied then return true else false
					if (validateAdminForm(selectedRow)){
					}else{
						checkValidate=false;
					}
				
			}
	
}else{//This is an update row
	
	        if ( (checkNull(pw) == false) && (checkNull(cpw) == false) && (checkNull(un) == false) && (checkNull(name) == false) ){
			}else if ( (checkNull(pw) == true) || (checkNull(cpw) == true) || (checkNull(un) == true) || (checkNull(name) == true) ){

			            if (validateAdminForm(selectedRow)){
					    }else{
							checkValidate=false;
					    }
			
		    }
	
}


}


if (checkValidate){
	document.frm.submit();
    return true;
}else{
	return false;
}



}



//---------------------------------------------------

function confirmUserDelete(uId){
	answer = confirm("Do you really want to delete this user?");
	if (answer){
		frm.hiddenUserDeleteAction.value="DELETE_USER";
		frm.hiddenUserDeleteId.value=uId;
		frm.submit();
		return(true);
	}


}


//--------------------------------------------------
//check whether a input is a number (including decimal places)
function checknumberFrom(){
var x=document.frm.txt_ValueFrom.value
x=trim(x)
var anum=/(^\d+$)|(^\d+\.\d+$)/
if (anum.test(x))
testresult=true
else{
//alert("Please input a valid number!")
testresult=false
}
return (testresult)
}



function checknumberTo(){
var x=document.frm.txt_ValueTo.value
x=trim(x)
var anum=/(^\d+$)|(^\d+\.\d+$)/
if (anum.test(x))
testresult=true
else{
//alert("Please input a valid number!")
testresult=false
}
return (testresult)
}



//---------------------------------------------------0ld

function setSearchHiddenActions(buttonAction){

	fromVal = frm.txt_ValueFrom.value;
	ToVal = frm.txt_ValueTo.value;
	
	fromVal = trim(fromVal);
	ToVal = trim(ToVal);
		
    message = "";
   
	if ( (fromVal=='') && (ToVal == '') ){
		frmSubmit=true;
	}else if ( (fromVal=='') && (ToVal != '') ){
		frmSubmit=false;
		message=message + "You need to fill the From Value\n";
		if (checknumberTo() == false){
			message=message + "To Value is not a Number\n";
		}
		
	}else if ( (fromVal!='') && (ToVal == '') ){
		frmSubmit=false;
		message=message + "You need to fill the To Value\n";
		if (checknumberFrom() == false){
			message=message + "From Value is not a Number\n";
		}		
		
		
		
	}else if ( (fromVal!='') && (ToVal != '') ){
	    if ( checknumberFrom() && checknumberTo() && (fromVal <= ToVal) ){
	        frmSubmit=true;
		}else{
			message=message + "From Value should be less than the To Value\n From and To values has to be numbers";
			frmSubmit=false;
		}
	}
	
	
	
	
	
	
	
	if(buttonAction == 'searchall'){
	frm.hiddenSearchField.value="SEARCH_ALL";
	}else if(buttonAction == 'searchoptions'){
	frm.hiddenSearchField.value="SEARCH_OPTIONS";
	}
	
	
	
 	if (frmSubmit){
		frm.submit();
	}else{
		alert(message);
	}
	
	
	
}



//---------------------------------------------------

//---------------------------------------------------chela new funtion to pass parameters through the url for search options
function setSearchHiddenActions_new(buttonAction){

	fromVal = frm.txt_ValueFrom.value;
	ToVal = frm.txt_ValueTo.value;
	
	fromVal = trim(fromVal);
	ToVal = trim(ToVal);
		
    message = "";
   
	if ( (fromVal=='') && (ToVal == '') ){
		frmSubmit=true;
	}else if ( (fromVal=='') && (ToVal != '') ){
		frmSubmit=false;
		message=message + "You need to fill the From Value\n";
		if (checknumberTo() == false){
			message=message + "To Value is not a Number\n";
		}
		
	}else if ( (fromVal!='') && (ToVal == '') ){
		frmSubmit=false;
		message=message + "You need to fill the To Value\n";
		if (checknumberFrom() == false){
			message=message + "From Value is not a Number\n";
		}		
		
		
		
	}else if ( (fromVal!='') && (ToVal != '') ){
	    if ( checknumberFrom() && checknumberTo() && (fromVal <= ToVal) ){
	        frmSubmit=true;
		}else{
			message=message + "From Value should be less than the To Value\n From and To values has to be numbers";
			frmSubmit=false;
		}
	}
	
	
	
	
	
	
	/*
	if(buttonAction == 'searchall'){
	frm.hiddenSearchField.value="SEARCH_ALL";
	}else if(buttonAction == 'searchoptions'){
	frm.hiddenSearchField.value="SEARCH_OPTIONS";
	}
	*/
	
	
 	if (frmSubmit){
		//chela new code 
	txt_Description = frm.txt_Description.value;
	cmb_Location = frm.cmb_Location.value;
	cmb_User = frm.cmb_User.value;
	
	window.location.href = 'Data.php?hiddenSearchField=' + 'SEARCH_OPTIONS' + '&txt_ValueFrom=' + fromVal + '&txt_ValueTo=' + ToVal + '&txt_Description=' + txt_Description + '&cmb_Location=' + cmb_Location + '&cmb_User=' + cmb_User;
	//chela new code 
		
		
	    //frm.submit();
	}else{
		alert(message);
	}
	
	
	
}

//---------------------------------------------------

function setSearchAllHiddenActions(buttonAction,fromedit){
	
    if(buttonAction == 'searchall'){
	frm.hiddenSearchField.value="SEARCH_ALL";
	}else if(buttonAction == 'searchoptions'){
	frm.hiddenSearchField.value="SEARCH_OPTIONS";
	}

    frm.submit();

}

//---------------------------------------------------

function nextPage(buttonAction,from,to){
	frm.hiddenSearchField.value = buttonAction;
	frm.From.value=from;
	frm.To.value=to;
	frm.submit();
}



//---------------------------------------------------

function setItemViewHiddenAction(itemId){
	frm.hiddenViewItem.value=itemId;
	frm.hiddenItemSearch.value="VIEW_ITEM";
	frm.submit();
}

//---------------------------------------------------


function showImage(image,w,h) {
  document.getElementById("displayImage").src = image.src;
  document.getElementById("displayImage").width = w;
	document.getElementById("displayImage").height = h;
}

//---------------------------------------------------

function showImageEnlarge(image,id,w,h,PID) {
	/*alert("dsfgdfg"+w);
	alert("dsfdfgdfgdf"+h);*/
	
    document.getElementById("displayImage").src = image.src;
	document.getElementById("displayImage").width = w;
	document.getElementById("displayImage").height = h;
	document.getElementById("hiddenFieldPICID").value = PID;
	//alert("THis is the PIC ID" + PID);

		
	frm.hiddenFieldPD.value =  id;
}


//--------------------------------------------------


function submitEditPage(buttonAction) { 
 window.location.hash="aShow";
  ShowWaiting();
  //setTimeout('',8000);
 
 var user_value="";
	user_value = document.frm.txt_Value.value;
	user_value = trim(user_value);
	
	if (user_value != ''){
	    if (checknumberValue() == false){
			alert("Your value field is not a whole dollar amount.\n Please enter whole dollar amounts only.");
			return false;
		}else{
			 frm.hiddenFieldDoEdit.value=buttonAction;
             frm.submit();
			 return true;
		}
	}else{
		 frm.hiddenFieldDoEdit.value=buttonAction;
		 
         frm.submit();
		 return true;
	}
 
}

//---------------------------------------------------


function confirmDelete(buttonAction) {
	answer = confirm("Are you sure you want to delete this item?");
	if (answer){
		frm.hiddenFieldDoEdit.value=buttonAction;
        frm.submit();
		return(true);
	}else{
		return(false);
	}
	

 
}



//---------------------------------------------------


function submitImageDelete(buttonAction,pictureId) {
 //frm.hiddenFieldDoEdit.value=buttonAction;
 //frm.hiddenFieldImage.value=pictureId;
 //frm.submit();
 
 
 
 answer = confirm("Are you sure you want to delete this image?\n This Photo is recorded in the system for \"Registration Time and Date Certificate\" and will not be able to access the photo again ");
	if (answer){
		 frm.hiddenFieldDoEdit.value=buttonAction;
         frm.hiddenFieldImage.value=pictureId;
         frm.submit();
		return(true);
	}else{
		return(false);
	}
 
 
 
 
 
 
 
}

//---------------------------------------------------

function clearSearchForm() {
		
	
	var RefElement1 = document.getElementById("search_title_td1");
	var RefElement2 = document.getElementById("search_title_td2");
    var RefElement3 = document.getElementById("nextBut");
	var ErrorNoResult = document.getElementById("EMWTINR");
	
	
	if (RefElement1 != null){
	RefElement1.style.display='none';	
	}
	if (RefElement2 != null){
	RefElement2.style.display='none';
	}
	if (RefElement3 != null){
	RefElement3.style.display='none';
	}
	if (ErrorNoResult != null) {
		ErrorNoResult.style.display = 'none'
	}
		
	
	frm.txt_Description.value="";
	frm.txt_ValueFrom.value="";
	frm.txt_ValueTo.value="";
	
	frm.cmb_Location.selectedIndex = 0;
	frm.cmb_User.selectedIndex = 0;
	
	
}

//---------------------------------------------------


function itemViewButtonAction(buttonAction) {
 frm.hiddenFieldEditTheItem.value=buttonAction; 
 frm.submit();
}


//-----------------------------------------------------


//--------------------------------------------------- chela new code


function itemViewButtonAction_new(buttonAction,fromEdit) {
	document.frm.hiddenFieldFromEdit.value=fromEdit;
 frm.hiddenFieldEditTheItem.value=buttonAction; 
 frm.submit();
}


//----------------------------------------------------- chela new code

//---------------------------------------------------

function upgrade(buttonAction) {
 frm.hiddenAction.value=""; 
 frm.hiddenFieldUpgrade.value=buttonAction; 
 frm.submit();
}

//------------------------------------------------------

function FormSubmitUpgrade(){
	document.frm.PG.value="ADMIN"; 
	document.frm.hiddenFieldUpgradeAccount.value = "";
    document.frm.submit();
	
}

//------------------------------------------------------

function GoBackFullRegAccFrozenFree(){
	
	document.frm.hiddenFieldUpgradeCreditCardDetails.value = "";
	document.frm.GoBackToFullRegAccFrozenFree.value = "GoBackToFullRegAccFrozenFree";
	document.frm.submit();
}

//-------------------------------------------------------

function branchpage(buttonAction) {
 frm.PG.value=buttonAction; 
 frm.submit();
}

//-------------------------------------------------------

function enlargePic(){
	document.frm.hiddenFieldEditTheItem.value="";
	document.frm.hiddenFieldEnlarge.value="ENLARGE";
	frm.submit();
}

//-------------------------------------------------------

function goToPic(imgName,PID){
	document.frm.hiddenFieldPD.value=imgName;
	document.frm.hiddenFieldPICID.value=PID;	
	frm.submit();
	
	
}

//-------------------------------------------------------

//-------------------------------------------------------chela new code

function goToPic_New(imgName,PID){
	
	document.frm.hiddenFieldPD.value=imgName;
	document.frm.hiddenFieldPICID.value=PID;
	window.location.href = 'Data.php?hiddenFieldEnlarge=ENLARGE&'+'hiddenFieldPD=' + imgName + '&hiddenFieldPICID=' + PID + '&hiddenGoBackToItemEditPage&' + '#ELPA';

	//frm.submit();
}

//-------------------------------------------------------chela new code


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//-------------------------------------------------------

function gobackto_itemedit(butaction){
document.frm.hiddenGoBackToItemEditPage.value = butaction;
document.frm.hiddenFieldEnlarge.value = "";

frm.submit();
}
//------------------------------------------------------

function print_alert(){
	
	alert("fgfgfgfgfg");
	window.print();
}

//------------------------------------------------------


function checknumberValue(){//This is item registration Value field
var x=document.frm.txt_Value.value
x=trim(x)
//var anum=/(^\d+$)|(^\d+\.\d+$)/
var anum=/(^\d+$)|(^\d+\d+$)/
if (anum.test(x))
testresult=true
else{
testresult=false
}
return (testresult)
}



//------------------------------------------------------
function submit_It_Reg_Page(fromHistory){
	
	document.frm.hiddenFieldFromPage.value= fromHistory;
	ShowWaiting();
	//window.setTimeout("alert('this')",8000);
	//alert(fromHistory);
	var user_value="";
	user_value = document.frm.txt_Value.value;
	user_value = trim(user_value);
	
	if (user_value != ''){
	    if (checknumberValue() == false){
			alert("Your value field is not a whole dollar amount.\n Please enter whole dollar amounts only.");
			return false;
		}else{
			
			document.frm.submit();
			return true;
		}
	}else{
		document.frm.submit();
		return true;
	}
	
	
}

//-----------------------------------------------------

//----------------------------------------------------- printable version from chela
function printableversion(){
window.open ("?PG=Inventory_List","mywindow","location=1,status=1,scrollbars=0,width=800");
//window.open('Data.php?Inventory_List.php',)

}

//----------------------------------------------------- printable version from chela


