//---------------------------------------------------------------------------
function RedirectMe_FULL(full_url)
{
	document.location.href=full_url;		
}

//---------------------------------------------------------------------------
function RedirectMe(action)
{
	var full_url = "../index.php?action=" + action;
	document.location.href=full_url;		
}


//---------------------------- Function to add stuffall into favorites ----------------------

function bookmark_weblinks()
{
var url="http://www.netforcemarketing.com";
var description="NetForce Marketing - enhancing your online presence";
netscape="Please press CTRL+D to add a bookmark to this site.";
	if (navigator.appName=='Microsoft Internet Explorer')
	{
		window.external.AddFavorite(url, description);
	}
	else if (navigator.appName=='Netscape')
	{
		alert(netscape);
	}

	
}

//-------------------- function to go to New account signup form -------------------------

function GotoNewAccountSignupForm()
{
	var full_url = "index.php?action=newaccountsignup";
	document.location.href=full_url;	
}


//------------------------------ Function to validate new user registration form ----------------


function validateCreateNewUserForm()                           // function to validate correct entries into new user registration form
{
	invalidFlag=false;
	var cnL = Trim(window.document.NewUserAccount_Form.CN.value).length;
	var cnV = Trim(window.document.NewUserAccount_Form.CN.value);
	
	var clistV = Trim(window.document.NewUserAccount_Form.countrylist.value);
	
	var unL = Trim(window.document.NewUserAccount_Form.UN.value).length;
	var unV = Trim(window.document.NewUserAccount_Form.UN.value);
	
	var fnL = Trim(window.document.NewUserAccount_Form.FN.value).length;
	var fnV = Trim(window.document.NewUserAccount_Form.FN.value);
	
	var emL = Trim(window.document.NewUserAccount_Form.EM.value).length;

	var pw1L = Trim(window.document.NewUserAccount_Form.PW1.value).length;
	var pw2L = Trim(window.document.NewUserAccount_Form.PW2.value).length;

	var captchaL = Trim(window.document.NewUserAccount_Form.captcha.value).length;

	
	// ----- Check Length of company name
	if((cnL<2) && (invalidFlag==false))
	{
		alert("Please enter company name of at least 2 characters");
		invalidFlag=true;
		window.document.NewUserAccount_Form.CN.focus();
	}
	
	//---------------------
	if(clistV<=0)
	{
		alert("Please select your country");
		invalidFlag=true;
		window.document.NewUserAccount_Form.countrylist.focus();		
	}
	
	// ----- Check Length of Username selected
	if((unL<6) && (invalidFlag==false))
	{
		alert("Please choose your User Name of at least 6 characters");
		invalidFlag=true;
		window.document.NewUserAccount_Form.UN.focus();
	}

	//-------- Check Presence of white spaces in user name (white spaces not allowed)
	var whitespacepresence = unV.indexOf(" ");
	if((whitespacepresence!=-1) && (invalidFlag==false))
	{
		alert("No spaces allowed in Username. Please Remove spaces");
		invalidFlag=true;
		window.document.NewUserAccount_Form.UN.focus();
	}

	
	
	
	//----------------- Password limit and matching with confirm password---------------

	var pw1Text = Trim(window.document.NewUserAccount_Form.PW1.value);
	var pw2Text = Trim(window.document.NewUserAccount_Form.PW2.value);



	if((pw1L<6) && (invalidFlag==false))
	{
		alert("Please enter Password of at least 6 characters");
		invalidFlag=true;
		window.document.NewUserAccount_Form.PW1.focus();
	}

	if((pw2L<6) && (invalidFlag==false))
	{
		alert("Please Re enter Password of at least 6 characters");
		invalidFlag=true;
		window.document.NewUserAccount_Form.PW2.focus();
	}

	if((pw1Text!=pw2Text) && (invalidFlag==false))
	{
		alert("Password and Confirm Password fields does not match");
		invalidFlag=true;
		window.document.NewUserAccount_Form.PW1.value="";
		window.document.NewUserAccount_Form.PW2.value="";
		window.document.NewUserAccount_Form.PW1.focus();
	}
	//-------------- Password validation ends here ----------------

	
	
	
	//-- fullname checking
	
	if((fnL<2) && (invalidFlag==false))
	{
		alert("Please enter your Full Name");
		invalidFlag=true;
		window.document.NewUserAccount_Form.FN.focus();
	}

	//-------- Check Presence of white spaces in full name - make sure atleast one space is there for "Firstname Lastname" format
	var whitespacepresence = fnV.indexOf(" ");					// make sure atleast one space is there for "Firstname Lastname" format
	if((whitespacepresence==-1) && (invalidFlag==false))
	{
		alert("Please Enter Your Fullname - Firstname Lastname as two words e.g John Smith");
		invalidFlag=true;
		window.document.NewUserAccount_Form.FN.focus();
	}
	else					// white space is present
	{
		if(((whitespacepresence==0) || (whitespacepresence==fnL-1)) && (invalidFlag==false))			// whitespace present at begining or end of name - so issue warning to user
		{
			alert("Your Fullname have empty spaces is begining or end. Please Remove these spaces");
			invalidFlag=true;
			window.document.NewUserAccount_Form.FN.focus();

		}

	}


	//----------- Email validation ------------

	if((emL<6) && (invalidFlag==false))
	{
		alert("Please enter your Email");
		invalidFlag=true;
		window.document.NewUserAccount_Form.EM.focus();
	}

	var emailText = Trim(window.document.NewUserAccount_Form.EM.value);

	var val1=emailText.indexOf("@");              // for existence of @ in email address

	var val2=emailText.indexOf(".");                  // for existence of . in email address

	var val3=emailText.indexOf(" ");                  // for existence of <space> in email address


	if(((val1==-1) || (val2==-1) || (val3!=-1)) && invalidFlag==false)                    // -1 will be returned if @ or . is missing from email address
	{
		alert("Please enter Correct Email Address");
		invalidFlag=true;
		window.document.NewUserAccount_Form.EM.focus();
	}

//---------------- Email Validation Ends----------------------





	if((captchaL<5) && (invalidFlag==false))
	{
		alert("Please enter 5 digit CODE");
		invalidFlag=true;
		window.document.NewUserAccount_Form.captcha.focus();
	}
//-----------------------------------------------------------

	if((window.document.NewUserAccount_Form.check1.checked==false) && (invalidFlag==false))
	{
		alert("You have not Agreed to Terms and Conditions");
		window.document.NewUserAccount_Form.check1.focus();
		invalidFlag=true;
	}




	// return either true or false to form tag which will determine wheather to submit form or not
	if(invalidFlag==false)
		return true;            // all entries entered in correct format i.e. form passes client side scripting
	else
		return false;            // one or more entries incorrect. DO NOT submit form



}         //------------------------------- function closed




//---------------------- function to validate login form -----------------------------------------------
function ValidateLoginForm()
{

	invalidFlag=false;
	var unL = Trim(window.document.loginform.UN.value).length;

	var unV = Trim(window.document.loginform.UN.value);

	var pwL = Trim(window.document.loginform.PW.value).length;


	if((unL<6) && (invalidFlag==false))
	{
		alert("Please enter your User Name of atleast 6 characters");
		invalidFlag=true;
		window.document.loginform.UN.focus();
	}

	//-------- Check Presence of white spaces in user name (white spaces not allowed)
	var whitespacepresence = unV.indexOf(" ");
	if((whitespacepresence!=-1) && (invalidFlag==false))
	{
		alert("No spaces allowed in Username. Please Remove spaces");
		invalidFlag=true;
		window.document.loginform.UN.focus();
	}

	if((pwL<6) && (invalidFlag==false))
	{
		alert("Please enter password of atleast 6 characters");
		invalidFlag=true;
		window.document.loginform.PW.focus();
	}


	if(invalidFlag==false)
	{
		return true;	// no problems
	}
	else
	{
		return false;	// one or more problems
	}

}

//--------------------

function GoToLogoff()
{
	var full_url = "index.php?action=logoff";
	document.location.href=full_url;		
}


//--------------------------


function ValidateChangeUserStatusForm()
{

	var invalidFlag=false;

	var userid = Trim(window.document.changeuserstatusform.URID.value);

	var useridL = Trim(window.document.changeuserstatusform.URID.value).length;

	if(useridL==0)			//empty article id
	{
		alert("Please Enter User ID");
		window.document.changeuserstatusform.URID.focus();
		invalidFlag=true;
	}
	var returntype = isNumeric(userid);		// defined below

	if((returntype==false) && (invalidFlag==false))
	{
		alert("Please Enter User ID in Correct Format (NUMBER)");
		window.document.changeuserstatusform.URID.focus();
		invalidFlag=true;		
	}

	if(invalidFlag==false)
	return true;			// no problems with check
	else
	return false;			// problem with one or more check
	
	
	 

}


//---------------------------------- Function to validate Contact us form ---------------------------------------

function validateContactUsForm()           // function to validate contact us form
{
	invalidFlag=false;
	var fnL = Trim(window.document.ContactUs1.FN.value).length;

	var captchaL = Trim(window.document.ContactUs1.captcha.value).length;

	var emL = Trim(window.document.ContactUs1.EM.value).length;
	
	var questL = Trim(window.document.ContactUs1.quest.value).length;

	if((fnL<2) && (invalidFlag==false))
	{
		alert("Please enter your Full Name");
		invalidFlag=true;
		window.document.ContactUs1.FN.focus();
	}
	
	
//----------- Email validation ------------

	if((emL<6) && (invalidFlag==false))
	{
		alert("Please enter your Email");
		invalidFlag=true;
		window.document.ContactUs1.EM.focus();
	}

	var emailText = Trim(window.document.ContactUs1.EM.value);

	var val1=emailText.indexOf("@");              // for existence of @ in email address

	var val2=emailText.indexOf(".");                  // for existence of . in email address

	var val3=emailText.indexOf(" ");                  // for existence of <space> in email address


	if(((val1==-1) || (val2==-1) || (val3!=-1)) && invalidFlag==false)                    // -1 will be returned if @ or . is missing from email address
	{
		alert("Please enter Correct Email Address");
		invalidFlag=true;
		window.document.ContactUs1.EM.focus();
	}

//---------------- Email Validation Ends----------------------




	if((questL<5) && (invalidFlag==false))
	{
		alert("Please enter your question");
		invalidFlag=true;
		window.document.ContactUs1.quest.focus();
	}



	
	
	if((captchaL<5) && (invalidFlag==false))
	{
		alert("Please enter 5 digit CODE");
		invalidFlag=true;
		window.document.ContactUs1.captcha.focus();
	}



	// return either true or false to form tag which will determine wheather to submit form or not
	if(invalidFlag==false)
	{
		return true;            // all entries entered in correct format i.e. form passes client side scripting
	}
	else
	{
		return false;            // one or more entries incorrect. DO NOT submit form
	}
	
	
}          // ------------ function closed





//--------------- Function to check isNumeric for mobile number ------------

function isNumeric(vTestValue)
{
	// put the TEST value into a string object variable
//	var sField = new String(Trim(vTestValue));
	var sField=vTestValue;
	
	// check for a length of 0 - if so, return false
	if(sField.length==0) { return false; }
	else if(sField.length==1 && (sField.charAt(0) == '.' || sField.charAt(0) == ',' || (sField.charAt(0) == '-'))) { return false; }
	
	// loop through each character of the string
	for(var x=0; x < sField.length; x++) {
		// if the character is < 0 or > 9, return false (not a number)
		if((sField.charAt(x) >= '0' && sField.charAt(x) <= '9') || sField.charAt(x) == '.' || sField.charAt(x) == ',' || (sField.charAt(x) ==  '-' && x==0)) { /* do nothing */ }
		else { return false; }
	}
	
	// made it through the loop - we have a number
	return true;
}

//---------------------------- Function to validate forgot password form -------------------------

function ValidateForgotPasswordForm()        //  function to validate Password Request form
{
	invalidFlag=false;
	var unL = Trim(window.document.ForgotPassword1.UN.value).length;
	var unV = Trim(window.document.ForgotPassword1.UN.value);
	var captchaL = Trim(window.document.ForgotPassword1.captcha.value).length;
	if((unL<2) && (invalidFlag==false))
	{
		alert("Please enter your User Name");
		invalidFlag=true;
		window.document.ForgotPassword1.UN.focus();
	}
	//-------- Check Presence of white spaces in user name (white spaces not allowed)
	var whitespacepresence = unV.indexOf(" ");
	if((whitespacepresence!=-1) && (invalidFlag==false))
	{
		alert("No spaces allowed in Username. Please Remove spaces");
		invalidFlag=true;
		window.document.ForgotPassword1.UN.focus();
	}
	if((captchaL<5) && (invalidFlag==false))
	{
		alert("Please enter 5 digit CODE");
		invalidFlag=true;
		window.document.ForgotPassword1.captcha.focus();
	}
	// return either true or false to form tag which will determine wheather to submit form or not
	if(invalidFlag==false)
		return true;            // all entries entered in correct format i.e. form passes client side scripting
	else
		return false;            // one or more entries incorrect. DO NOT submit form



}
//-------------------- function to go to list of active users -------------------------

function GoToListActiveUsers()
{
	var full_url = "index.php?action=listactiveusers";
	document.location.href=full_url;	
}

//-------------------- function to go to list of disabled users -------------------------

function GoToListDisabledUsers()
{
	var full_url = "index.php?action=listdisabledusers";
	document.location.href=full_url;	
}

//---------------------------------------------------------

function ValidateUserAdminForm()
{
	var usernameL = window.document.useradminform.username.value.length; 

	if(usernameL<6)
	{
		alert("Please Enter Username");
		window.document.useradminform.username.focus();
		return false;
	}

	return true;

}


//------------------------------------------
function GoToAdministrationPage()
{

	var full_url = "index.php?action=administration";
	document.location.href=full_url;	


}

//-----------------------------------

function ValidateSubmitModifyUserAccountForm()
{

	//------------Validation Logic Pending here
	return true;

}


//------------------------------

function ValidateSubmitModifyMyAccountForm()
{

	var invalidFlag=false;

	var fullnameL = Trim(window.document.modifyuseraccountform.fullname.value).length; 

	var fullnameV = Trim(window.document.modifyuseraccountform.fullname.value); 

	



//----------------- Password limit and matching with confirm password---------------

	
	var pw1L = Trim(window.document.modifyuseraccountform.PW1.value).length;
	var pw2L = Trim(window.document.modifyuseraccountform.PW2.value).length;

	var pw1Text = Trim(window.document.modifyuseraccountform.PW1.value);
	var pw2Text = Trim(window.document.modifyuseraccountform.PW2.value);



	if((pw1L<6) && (pw1L>0) && (invalidFlag==false))
	{
		alert("Please enter Password of atleast 6 characters");
		invalidFlag=true;
		window.document.modifyuseraccountform.PW1.focus();
	}

	if((pw2L<6) && (pw1L>0) && (invalidFlag==false))
	{
		alert("Please Re enter Password of atleast 6 characters");
		invalidFlag=true;
		window.document.modifyuseraccountform.PW2.focus();
	}

	if((pw1Text!=pw2Text) && (invalidFlag==false))
	{
		alert("Password and Confirm Password fields does not match");
		invalidFlag=true;
		window.document.modifyuseraccountform.PW1.value="";
		window.document.modifyuseraccountform.PW2.value="";
		window.document.modifyuseraccountform.PW1.focus();
	}
//-------------- Password validation ends here ----------------

	if((fullnameL<2) && (invalidFlag==false))
	{
		alert("Please Enter fullname");
		window.document.modifyuseraccountform.fullname.focus();
		invalidFlag=true;
	}


	//-------- Check Presence of white spaces in full name - make sure atleast one space is there for "Firstname Lastname" format
	var whitespacepresence = fullnameV.indexOf(" ");					// make sure atleast one space is there for "Firstname Lastname" format
	if((whitespacepresence==-1) && (invalidFlag==false))
	{
		alert("Please Enter Your Fullname - Firstname Lastname as two words e.g John Smith");
		invalidFlag=true;
		window.document.modifyuseraccountform.fullname.focus();
	}
	else					// white space is present
	{
		if(((whitespacepresence==0) || (whitespacepresence==fullnameL-1)) && (invalidFlag==false))			// whitespace present at begining or end of name - so issue warning to user
		{
			alert("Your Fullname have empty spaces is begining or end. Please Remove these spaces");
			invalidFlag=true;
			window.document.modifyuseraccountform.fullname.focus();

		}

	}
//---------- Company name -------------------------------

	var companynameL = Trim(window.document.modifyuseraccountform.companyname.value).length;
	if(companynameL < 2)
	{
		alert("Please enter your company name of at least 2 chars");
		invalidFlag=true;
		window.document.modifyuseraccountform.companyname.focus();		
	}

//---------- Jobtitle -------------------------------

	var jobtitleL = Trim(window.document.modifyuseraccountform.jobtitle.value).length;
	if((jobtitleL > 0) && (jobtitleL < 2))
	{
		alert("Please enter your Job Title of at least 2 chars");
		invalidFlag=true;
		window.document.modifyuseraccountform.jobtitle.focus();		
	}
//---------- address line 1 -------------------------------

	var aline1L = Trim(window.document.modifyuseraccountform.aline1.value).length;
	if((aline1L > 0) && (aline1L < 5))
	{
		alert("Please enter your address of at least 5 chars");
		invalidFlag=true;
		window.document.modifyuseraccountform.aline1.focus();		
	}

//---------- city -------------------------------

	var cityL = Trim(window.document.modifyuseraccountform.city.value).length;
	if((cityL > 0) && (cityL < 2))
	{
		alert("Please enter your city of at least 2 chars");
		invalidFlag=true;
		window.document.modifyuseraccountform.city.focus();		
	}


//---------- state -------------------------------

	var stateL = Trim(window.document.modifyuseraccountform.state.value).length;
	if((stateL > 0) && (stateL < 2))
	{
		alert("Please enter your state of at least 2 chars");
		invalidFlag=true;
		window.document.modifyuseraccountform.state.focus();		
	}


//---------- postcode -------------------------------

	var postcodeL = Trim(window.document.modifyuseraccountform.postcode.value).length;
	if((postcodeL > 0) && (postcodeL < 2))
	{
		alert("Please enter your postcode of at least 2 chars");
		invalidFlag=true;
		window.document.modifyuseraccountform.postcode.focus();		
	}


//---------- country -------------------------------

	var countrylistV = Trim(window.document.modifyuseraccountform.countrylist.value);
	if(countrylistV == 0)
	{
		alert("Please choose your country");
		invalidFlag=true;
		window.document.modifyuseraccountform.countrylist.focus();		
	}


//---------- telephone -------------------------------

	var telephoneL = Trim(window.document.modifyuseraccountform.telephone.value).length;
	if((telephoneL > 0) && (telephoneL < 8))
	{
		alert("Please enter your telephone of at least 8 chars");
		invalidFlag=true;
		window.document.modifyuseraccountform.telephone.focus();		
	}






	if(invalidFlag==false)
		return true;
	else
		return false;


}

//------------------------------------------
function GoToMyAccountPage()
{

	var full_url = "index.php?action=myaccount";
	document.location.href=full_url;	


}


//------------------------------------


function ConfirmationNotGiven()
{
	history.back();					// just navigate back
}

//------------------------------------

function ConfirmationGiven()
{

	var full_url = document.location.href;
	
	full_url = full_url + "&confirm=1";

	document.location.href=full_url;	

}

//-------------------- function to go to Awaiting Approval Articles List -------------------------

function GoToAwaitingApproval()
{
	var full_url = "index.php?action=awaitingapproval";
	document.location.href=full_url;	
}




//---------------------------------------------------------------------

function ValidateUserPaymentDetailsForm()
{
	
	var invalidFlag=false;

	var uid = Trim(window.document.userpaymentdetailsform.URID.value);

	var uidL = Trim(window.document.userpaymentdetailsform.URID.value).length;
	
	var username = Trim(window.document.userpaymentdetailsform.username.value);

	var usernameL = Trim(window.document.userpaymentdetailsform.username.value).length;
	
	if(uidL>0)
	{
		var returnvalue = isNumeric(uid);
		if(returnvalue==false)
		{
			alert("Please Enter Numeric User ID");
			window.document.userpaymentdetailsform.URID.focus();
			invalidFlag=true;
		}
	}
	
	if(((uidL==0) && (usernameL==0)) && (invalidFlag==false))
	{
		alert("Please Enter User ID or User Name");

		window.document.userpaymentdetailsform.URID.focus();
	
		invalidFlag=true;


	}

	if(invalidFlag==true)
		return false;
	else
		return true;

}



//-------------------------------------------------------
function ValidateReasonForRejectionForm()
{

	var reasonL = Trim(window.document.reasonforrejectionform.reason.value).length;
		
	if(reasonL<10)
	{
		alert ("Please Fill Reason For rejection (atleast 10 chars)");
		window.document.reasonforrejectionform.reason.focus();	
		return false;
	}
	
return true;


}


//----------------------------------------------------------------

function GoToUserAdministration()
{
	var full_url = "index.php?action=mainuseradministration";
	document.location.href=full_url;	

}




//-----------------------------------------------------

function PrintThis()                                               // function for printing the Invoices
{
	window.print();
}





//*************************************************************************************


function ValidateAddPressReleaseForm()
{
	invalidFlag=false;
	
	var headlineL = Trim(window.document.AddPressReleaseForm.headline.value).length;			// 10 chars

	var summaryL = Trim(window.document.AddPressReleaseForm.summary.value).length;			// 50 chars

	var newsbodyL = Trim(window.document.AddPressReleaseForm.newsbody.value).length;			// 100 chars

	var authorL = Trim(window.document.AddPressReleaseForm.author.value).length;				// 2 chars

	var emailL = Trim(window.document.AddPressReleaseForm.email.value).length;			// 5 chars

	var captchaL = Trim(window.document.AddPressReleaseForm.captcha.value).length;			// 5 chars

	var addressline1L = Trim(window.document.AddPressReleaseForm.addressline1.value).length;			// atleast 2 chars or 0

	var countryV = Trim(window.document.AddPressReleaseForm.countrylist.value);			// not equal to 0 if address is filled 0

	var postcodeL = Trim(window.document.AddPressReleaseForm.postcode.value).length;			// atleast 2 chars or 0
	
	var phoneL = Trim(window.document.AddPressReleaseForm.phone.value).length;			// atleast 8 chars or 0

	var faxL = Trim(window.document.AddPressReleaseForm.fax.value).length;			// atleast 2 chars or 0

	var websiteL = Trim(window.document.AddPressReleaseForm.website.value).length;			// atleast 5 chars or 0
	
	var cat1 = Trim(window.document.AddPressReleaseForm.cat1.value);			// atleast 5 chars or 0
	
	var companyL = Trim(window.document.AddPressReleaseForm.company.value).length;			// atleast 5 chars or 0
	

	
	// ----- Check headline
	if((headlineL<10) && (invalidFlag==false))
	{
		alert("Please Enter Headline of atleast 10 characters");
		invalidFlag=true;
		window.document.AddPressReleaseForm.headline.focus();
	}


	// ----- Check summary
	if((summaryL<50) && (invalidFlag==false))
	{
		alert("Please Enter Summary of atleast 50 characters");
		invalidFlag=true;
		window.document.AddPressReleaseForm.summary.focus();
	}

	// ----- Check news body
	if((newsbodyL<100) && (invalidFlag==false))
	{
		alert("Please Enter News Body of atleast 100 characters");
		invalidFlag=true;
		window.document.AddPressReleaseForm.newsbody.focus();
	}	
	
	// ----- Check news body
	if((cat1==0) && (invalidFlag==false))
	{
		alert("Please choose press release category");
		invalidFlag=true;
		window.document.AddPressReleaseForm.cat1.focus();
	}
	
	
	
	// ----- Check author
	if((authorL<2) && (invalidFlag==false))
	{
		alert("Please Enter Author of atleast 2 characters");
		invalidFlag=true;
		window.document.AddPressReleaseForm.author.focus();
	}

//----------- Email validation ------------

	if((emailL<6) && (invalidFlag==false))
	{
		alert("Please enter your Email");
		invalidFlag=true;
		window.document.AddPressReleaseForm.email.focus();
	}

	var emailText = Trim(window.document.AddPressReleaseForm.email.value);

	var val1=emailText.indexOf("@");              // for existence of @ in email address

	var val2=emailText.indexOf(".");                  // for existence of . in email address

	var val3=emailText.indexOf(" ");                  // for existence of <space> in email address


	if(((val1==-1) || (val2==-1) || (val3!=-1)) && invalidFlag==false)                    // -1 will be returned if @ or . is missing from email address
	{
		alert("Please enter Correct Email Address");
		invalidFlag=true;
		window.document.AddPressReleaseForm.email.focus();
	}

//---------------- Email Validation Ends----------------------


	
	// ----- Check company
	if((companyL<2) && (invalidFlag==false))
	{
		alert("Please Enter Company Name of atleast 2 characters");
		invalidFlag=true;
		window.document.AddPressReleaseForm.company.focus();
	}
	

	var addressflag = false;

	if((addressline1L>0) || (postcodeL>0))
	{
		addressflag = true;				// customer has entered address in all or one of the fields

	}


	// ----- Check street
	if((addressline1L<2) && (invalidFlag==false) && (addressflag==true))
	{
		alert("Please Enter Street Number and Name characters");
		invalidFlag=true;
		window.document.AddPressReleaseForm.addressline1.focus();
	}

	
	// ----- Check Country Selection
	if((countryV==0) && (invalidFlag==false))			// address is set but country is not selected
	{
		alert("Please Choose Country");
		invalidFlag=true;
		window.document.AddPressReleaseForm.countrylist.focus();
	}


	// ----- Check postcode
	if((postcodeL<2) && (invalidFlag==false) && (addressflag==true))
	{
		alert("Please Enter Post Code");
		invalidFlag=true;
		window.document.AddPressReleaseForm.postcode.focus();
	}
	


	// ----- Check phone
	if((phoneL>0) &&(phoneL<5) && (invalidFlag==false))
	{
		alert("Please Enter Phone Number of atleast 8 characters");
		invalidFlag=true;
		window.document.AddPressReleaseForm.phone.focus();
	}

	// ----- Check fax
	if((faxL>0) &&(faxL<5) && (invalidFlag==false))
	{
		alert("Please Enter Fax Number of atleast 8 characters");
		invalidFlag=true;
		window.document.AddPressReleaseForm.fax.focus();
	}

	// ----- Check website
	if((websiteL>0) &&(websiteL<5) && (invalidFlag==false))
	{
		alert("Please Enter Website of atleast 5 characters");
		invalidFlag=true;
		window.document.AddPressReleaseForm.website.focus();
	}
	
	
	// ----- Check security code
	if((captchaL<5) && (invalidFlag==false))
	{
		alert("Please Enter Security Code of 5 characters");
		invalidFlag=true;
		window.document.AddPressReleaseForm.captcha.focus();
	}

if(invalidFlag==true)
	return false;
else
	return true;




}






//*************************************************************************************


function ValidateEditPressReleaseForm()
{


	invalidFlag=false;
	var headlineL = Trim(window.document.EditPressReleaseForm.headline.value).length;			// 10 chars

	var summaryL = Trim(window.document.EditPressReleaseForm.summary.value).length;			// 50 chars


	var newsbodyL = Trim(window.document.EditPressReleaseForm.newsbody.value).length;			// 100 chars

	var authorL = Trim(window.document.EditPressReleaseForm.author.value).length;				// 2 chars

	var emailL = Trim(window.document.EditPressReleaseForm.email.value).length;			// 5 chars


//	var captchaL = window.document.EditPressReleaseForm.captcha.value.length;			// 5 chars

	var addressline1L = Trim(window.document.EditPressReleaseForm.addressline1.value).length;			// atleast 2 chars or 0

	var countryV = Trim(window.document.EditPressReleaseForm.countrylist.value);			// not equal to 0 if address is filled 0

	var postcodeL = Trim(window.document.EditPressReleaseForm.postcode.value).length;			// atleast 2 chars or 0
	
	var phoneL = Trim(window.document.EditPressReleaseForm.phone.value).length;			// atleast 8 chars or 0

	var faxL = Trim(window.document.EditPressReleaseForm.fax.value).length;			// atleast 2 chars or 0

	var websiteL = Trim(window.document.EditPressReleaseForm.website.value).length;			// atleast 5 chars or 0
	
	var cat1 = Trim(window.document.EditPressReleaseForm.cat1.value);			// atleast 5 chars or 0
	
	var companyL = Trim(window.document.EditPressReleaseForm.company.value).length;			// atleast 5 chars or 0
	

	
	// ----- Check headline
	if((headlineL<10) && (invalidFlag==false))
	{
		alert("Please Enter Headline of atleast 10 characters");
		invalidFlag=true;
		window.document.EditPressReleaseForm.headline.focus();
	}


	// ----- Check summary
	if((summaryL<50) && (invalidFlag==false))
	{
		alert("Please Enter Summary of atleast 50 characters");
		invalidFlag=true;
		window.document.EditPressReleaseForm.summary.focus();
	}

	// ----- Check news body
	if((newsbodyL<100) && (invalidFlag==false))
	{
		alert("Please Enter News Body of atleast 100 characters");
		invalidFlag=true;
		window.document.EditPressReleaseForm.newsbody.focus();
	}	
	
	// ----- Check news body
	if((cat1==0) && (invalidFlag==false))
	{
		alert("Please choose press release category");
		invalidFlag=true;
		window.document.EditPressReleaseForm.cat1.focus();
	}
	
	
	
	// ----- Check author
	if((authorL<2) && (invalidFlag==false))
	{
		alert("Please Enter Author of atleast 2 characters");
		invalidFlag=true;
		window.document.EditPressReleaseForm.author.focus();
	}

//----------- Email validation ------------

	if((emailL<6) && (invalidFlag==false))
	{
		alert("Please enter your Email");
		invalidFlag=true;
		window.document.EditPressReleaseForm.email.focus();
	}

	var emailText = Trim(window.document.EditPressReleaseForm.email.value);

	var val1=emailText.indexOf("@");              // for existence of @ in email address

	var val2=emailText.indexOf(".");                  // for existence of . in email address

	var val3=emailText.indexOf(" ");                  // for existence of <space> in email address


	if(((val1==-1) || (val2==-1) || (val3!=-1)) && invalidFlag==false)                    // -1 will be returned if @ or . is missing from email address
	{
		alert("Please enter Correct Email Address");
		invalidFlag=true;
		window.document.EditPressReleaseForm.email.focus();
	}

//---------------- Email Validation Ends----------------------


	
	// ----- Check company
	if((companyL<2) && (invalidFlag==false))
	{
		alert("Please Enter Company Name of atleast 2 characters");
		invalidFlag=true;
		window.document.EditPressReleaseForm.company.focus();
	}
	

	var addressflag = false;

	if((addressline1L>0) || (postcodeL>0))
	{
		addressflag = true;				// customer has entered address in all or one of the fields

	}


	// ----- Check street
	if((addressline1L<2) && (invalidFlag==false) && (addressflag==true))
	{
		alert("Please Enter Street Number and Name characters");
		invalidFlag=true;
		window.document.EditPressReleaseForm.addressline1.focus();
	}

	
	// ----- Check Country Selection
	if((countryV==0) && (invalidFlag==false))			// address is set but country is not selected
	{
		alert("Please Choose Country");
		invalidFlag=true;
		window.document.EditPressReleaseForm.countrylist.focus();
	}


	// ----- Check postcode
	if((postcodeL<2) && (invalidFlag==false) && (addressflag==true))
	{
		alert("Please Enter Post Code");
		invalidFlag=true;
		window.document.EditPressReleaseForm.postcode.focus();
	}
	


	// ----- Check phone
	if((phoneL>0) &&(phoneL<5) && (invalidFlag==false))
	{
		alert("Please Enter Phone Number of atleast 8 characters");
		invalidFlag=true;
		window.document.EditPressReleaseForm.phone.focus();
	}

	// ----- Check fax
	if((faxL>0) &&(faxL<5) && (invalidFlag==false))
	{
		alert("Please Enter Fax Number of atleast 8 characters");
		invalidFlag=true;
		window.document.EditPressReleaseForm.fax.focus();
	}

	// ----- Check website
	if((websiteL>0) &&(websiteL<5) && (invalidFlag==false))
	{
		alert("Please Enter Website of atleast 5 characters");
		invalidFlag=true;
		window.document.EditPressReleaseForm.website.focus();
	}
	
	
	

if(invalidFlag==true)
	return false;
else
	return true;




}




//------------------------------------


function ConfirmationNotGiven5()
{

	history.back();					// just navigate back

}

//------------------------------------

function ConfirmationGiven5()
{

	var full_url = document.location.href;
	
	full_url = full_url + "&confirm=1";

	document.location.href=full_url;	

}

//----------------------------------------------------------------------

function ValidateUserPressReleasesForm()
{

	var usernameL = Trim(window.document.userpressreleases.username.value).length;			// 6 chars
	
	if(usernameL<6)
	{
		alert("Please enter user name of atleast 6 chars");
		window.document.userpressreleases.username.focus();
		return false;
		
	}

	return true;

}


//----------------------------------------------------------------------------------------------

function fillApproved()
{
	fillList();
	document.listprform.hiddenaction.value="0";	
	if(document.listprform.hiddenprlist.value=="")
	{
		alert("Please Select one or more Press Releases");
		return false;
	}
	document.listprform.submit();
	
	
}
//----------------------------------------------------------------------------------------------
function fillRejected()
{
	fillList();
	document.listprform.hiddenaction.value="1";		
	if(document.listprform.hiddenprlist.value=="")
	{
		alert("Please Select one or more Press Releases");
		return false;
	}
	document.listprform.submit();
}

//----------------------------------------------------------------------------------------------

function fillList()
{
	anyprselected = 0;
	document.listprform.hiddenprlist.value="";
	var numberofprs= document.listprform.checkbox_array.length;
	if(numberofprs==undefined)			// if only one contact is present then javascript is not treating the contactarray as array and showing undefined as length therefore set it to 1
	numberofprs=1;
	
	//alert("Length = " + a);
	
	for (i = 0; i < numberofprs; i++)
	{
	    if(numberofprs==1)					// if only one contact is present then javascript does not treat contactarray as array[]
	    {
			if(document.listprform.checkbox_array.checked)	
			{
					anyprselected=1;				// user has selected atleast one contact		
					document.listprform.hiddenprlist.value = (document.listprform.checkbox_array.value + ',');
	
			}
		}
		else									// if contact are more than 1 then javascript treat contactarray as array[]
		{
			if (document.listprform.checkbox_array[i].checked)
			{
	
				anyprselected=1;				// user has selected atleast one contact
				document.listprform.hiddenprlist.value = document.listprform.checkbox_array[i].value + ',' + document.listprform.hiddenprlist.value;
			}
		}
	}	
}


//--------------------------------------------------------------------------------------------

function ShowHideCategoriesMenu(id,mode)
{
	
	var referenceToCatmenu=document.getElementById(id);                    // returns reference to passed id sending please wait image as per w3c standards
	
		
	if(mode==0)					// hide
	{
		referenceToCatmenu.style.visibility="hidden";	
	}
	else						// visible
	{
		referenceToCatmenu.style.visibility="visible";		
	}
	
}



//-----------------------------------------------------------------------------------------

function HighlightRow(id,mode)
{
	var id_1 = id + "_1";
	var id_2 = id + "_2";
	var id_summary = id + "_summary";
	var referenceToRow=document.getElementById(id); 
	var referenceToRow_1=document.getElementById(id_1);
	var referenceToRow_2=document.getElementById(id_2);
	var referenceToRow_summary=document.getElementById(id_summary);
	
	if(mode==1)					// hide
	{
		referenceToRow.className="highlight1";	
		referenceToRow_1.className="highlight1";	
		referenceToRow_2.className="highlight1";	
		referenceToRow_summary.style.color = "#000000";
	}
	else						// visible
	{
		referenceToRow.className="highlight0";	
		referenceToRow_1.className="highlight0";	
		referenceToRow_2.className="highlight0";
		referenceToRow_summary.style.color = "#AAAAAA";	
	}
}

//-----------------------------------------------------------------------------------------

function HighlightRow2(id,mode)
{
	
	var referenceToRow=document.getElementById(id); 
	
	if(mode==1)					// hide
	{
		referenceToRow.className="highlight1";	
	}
	else						// visible
	{
		referenceToRow.className="highlight0";	
	}
}

//-----------------------------------------------------------------------------------------

function HighlightRow3(id,mode)
{
	var id2 = id + "_2";	
	var referenceToRow=document.getElementById(id); 
	var referenceToRow2=document.getElementById(id2); 
	
	if(mode==1)					// hide
	{
		referenceToRow.className="highlight1";	
		referenceToRow2.className="highlight1";	
	}
	else						// visible
	{
		referenceToRow.className="highlight0";	
		referenceToRow2.className="highlight0";	
	}
}



//--------------------------------------------------------------------------

function StartSearch()
{
	var referenceToSearchBox=document.getElementById("searchtextbox");
	var txt = Trim(referenceToSearchBox.value);
	var txtL = Trim(referenceToSearchBox.value).length;
	if(txtL < 3)
	{
		alert("Please enter search criteria with atleast 3 chars");
		referenceToSearchBox.focus();
	}
	else
	{
		document.location.href= "../search?query=" + encodeURIComponent(txt);	
	}
	
}



//-----------------------------------------------------------

function Trim(stringToTrim) 
{
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

//-------------------------------------------------------------

function ChangePage(pageurl,id)
{
	var referenceToPageBox=document.getElementById(id);
	
	page = referenceToPageBox.value;
	
	document.location.href = pageurl + page;
	
}


//------------------------------------------------------------

function SubmitSearchForm()
{
	
	if (event.keyCode == 13) 
	{
		StartSearch();			// defined above
	}	
}



//---------------------------------------------------------

function ValidateStep1()
{
	var referenceToCheckBox=document.getElementById("acceptterms");
	
	if(referenceToCheckBox.checked)
	{
		return true;	
	}	
	else
	{
		alert("Please tick the terms and conditions box if you agree to our Terms and Conditions");
		referenceToCheckBox.focus();
	}

	return false;

}

//-----------------------------------------------------------------------------------

function ValidateNewsletterSubscription()
{
	invalidFlag=false;
	var emL = Trim(window.document.sub1.email.value).length;
	var emV = Trim(window.document.sub1.email.value);
	

	var captchaL = Trim(window.document.sub1.captcha.value).length;
	if((emL<6) && (invalidFlag==false))
	{
		alert("Please enter valid email address");
		invalidFlag=true;
		window.document.sub1.email.focus();
	}
	//-------- Check Presence of white spaces in user name (white spaces not allowed)
	var whitespacepresence = emV.indexOf(" ");
	if((whitespacepresence!=-1) && (invalidFlag==false))
	{
		alert("No spaces allowed in Email. Please Remove spaces");
		invalidFlag=true;
		window.document.sub1.email.focus();
	}



	var val1=emV.indexOf("@");              // for existence of @ in email address

	var val2=emV.indexOf(".");                  // for existence of . in email address

	var val3=emV.indexOf(" ");                  // for existence of <space> in email address


	if(((val1==-1) || (val2==-1) || (val3!=-1)) && invalidFlag==false)                    // -1 will be returned if @ or . is missing from email address
	{
		alert("Please enter Correct Email Address");
		invalidFlag=true;
		window.document.sub1.email.focus();
	}

		

	if((captchaL<5) && (invalidFlag==false))
	{
		alert("Please enter 5 digit CODE");
		invalidFlag=true;
		window.document.sub1.captcha.focus();
	}
	// return either true or false to form tag which will determine wheather to submit form or not
	if(invalidFlag==false)
		return true;            // all entries entered in correct format i.e. form passes client side scripting
	else
		return false;            // one or more entries incorrect. DO NOT submit form



}


