//---------------------------- 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 unL = window.document.NewUserAccount_Form.UN.value.length;
	var unV = window.document.NewUserAccount_Form.UN.value;

	var fnL = window.document.NewUserAccount_Form.FN.value.length;
	var fnV = window.document.NewUserAccount_Form.FN.value;


	var emL = window.document.NewUserAccount_Form.EM.value.length;

	var pw1L = window.document.NewUserAccount_Form.PW1.value.length;
	var pw2L = window.document.NewUserAccount_Form.PW2.value.length;

	var captchaL = window.document.NewUserAccount_Form.captcha.value.length;

	
	// ----- 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();
	}


	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=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----------------------



//----------------- Password limit and matching with confirm password---------------

	var pw1Text=window.document.NewUserAccount_Form.PW1.value;
	var pw2Text=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 ----------------


	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 side login form -----------------------------------------------
function ValidateSideLoginForm()
{

	invalidFlag=false;
	var unL = window.document.sideloginform.UN.value.length;
	var unV = window.document.sideloginform.UN.value;

	var pwL = window.document.sideloginform.PW.value.length;


	if((unL<6) && (invalidFlag==false))
	{
		alert("Please enter your User Name of atleast 6 characters");
		invalidFlag=true;
		window.document.sideloginform.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.sideloginform.UN.focus();
	}


	if((pwL<6) && (invalidFlag==false))
	{
		alert("Please enter password of atleast 6 characters");
		invalidFlag=true;
		window.document.sideloginform.PW.focus();
	}


	if(invalidFlag==false)
	{
		return true;	// no problems
	}
	else
	{
		return false;	// one or more problems
	}

}


//--------------------------------

//---------------------- function to validate login form -----------------------------------------------
function ValidateLoginForm()
{

	invalidFlag=false;
	var unL = window.document.loginform.UN.value.length;

	var unV = window.document.loginform.UN.value;

	var pwL = 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 ValidateAddArticleForm()
{

	var invalidFlag=false;			// means no filed has invalid value - initialization

	var titleL = window.document.AddArticleForm.title.value.length;
	var urlL = window.document.AddArticleForm.url.value.length;
	var url = window.document.AddArticleForm.url.value;

	var fileL = window.document.AddArticleForm.file.value.length;

	var file = window.document.AddArticleForm.file.value;

	





	//--------------------------------Important when user click on back button after submitting article and then editing it and resubmitting it ------------------------

//	window.document.AddArticleForm.hiddenimagepath.value = window.document.AddArticleForm.file.value;

	//------------------------------------------------------------------------------------------------------------------------------------------------------------------

	var articletext1L = window.document.AddArticleForm.articletext1.value.length;
	var articletext2L = window.document.AddArticleForm.articletext2.value.length;
	var articletext3L = window.document.AddArticleForm.articletext3.value.length;
	var articletext4L = window.document.AddArticleForm.articletext4.value.length;
	var articletext5L = window.document.AddArticleForm.articletext5.value.length;
	var articletext6L = window.document.AddArticleForm.articletext6.value.length;
	var articletext7L = window.document.AddArticleForm.articletext7.value.length;
	var articletext8L = window.document.AddArticleForm.articletext8.value.length;
	var articletext9L = window.document.AddArticleForm.articletext9.value.length;
	var articletext10L = window.document.AddArticleForm.articletext10.value.length;

	if((titleL < 5 )&& (invalidFlag==false))
	{
		invalidFlag=true;			// invalid value exists
		alert("Please Enter Title of atleast 5 characters");
		window.document.AddArticleForm.title.focus();
	}

	if((urlL < 5 )&& (invalidFlag==false))
	{
		invalidFlag=true;			// invalid value exists
		alert("Please Enter URL of atleast 5 characters");
		window.document.AddArticleForm.url.focus();
	}

	if(url=="http://")						// no url entered
	{
		invalidFlag=true;			// invalid value exists
		alert("Please Enter URL of atleast 5 characters");
		window.document.AddArticleForm.url.focus();
	}

	if((fileL > 0) && (fileL < 5 )&& (invalidFlag==false))
	{
		invalidFlag=true;			// invalid value exists
		alert("Please select image with valid path");
		window.document.AddArticleForm.file.focus();
	}


	//------------ Check For Picture Format (extension) --------------------

	if((fileL>=5) && (invalidFlag==false))	//--- picture is present - check for extension
	{

		var fileext = file.substring((fileL - 4),fileL);	// should return .gif or .jpg
		fileext = fileext.toLowerCase();			// convert the extension to lower case
		if((fileext == ".gif") || (fileext == ".jpg") || (fileext == ".png"))
		{
			// picture is OK
		}
		else
		{
			alert("InCorrect Picture Format - Please choose only .gif, .jpg or .png formats");
			invalidFlag=true;
		}
		

	}
	



//--------------------- Article Category Checkbox array checking ------------------------
//For each checkbox see if it has been checked, record the value.

document.AddArticleForm.storecategoriesselected.value = "";							// ******** very important to clear previous categories
var numberofcheckboxes = window.document.AddArticleForm.numberofcategories.value;

   for (var i = 0; i < numberofcheckboxes; i++)
   {
      if (document.AddArticleForm.articlecategories[i].checked==true)
	{
         document.AddArticleForm.storecategoriesselected.value = document.AddArticleForm.storecategoriesselected.value + document.AddArticleForm.articlecategories[i].value + ";";

      }
  }


	var categoriesselectedL = document.AddArticleForm.storecategoriesselected.value.length;
	if((categoriesselectedL < 2) && (invalidFlag==false))					// no category selected
	{
		invalidFlag=true;
		alert("Please Select one or more Article categories");
	}




	
//------------ Article Text Checking -------------------------------

	if((articletext1L < 20) && (invalidFlag==false))			// for version 1 its different from version 2-10
	{
		invalidFlag=true;
		alert("Please Enter Article Text in Version 1 of atleast 20 characters");
		window.document.AddArticleForm.articletext1.focus();
	}


	if((articletext2L > 0) && (articletext2L < 20) && (invalidFlag==false))			// for versions 2-10 its different from version 1
	{
		invalidFlag=true;
		alert("Please Enter Article Text in Version 2 of atleast 20 characters");
		window.document.AddArticleForm.articletext2.focus();
	}	

	if((articletext3L > 0) && (articletext3L < 20) && (invalidFlag==false))			// for versions 2-10 its different from version 1
	{
		invalidFlag=true;
		alert("Please Enter Article Text in Version 3 of atleast 20 characters");
		window.document.AddArticleForm.articletext3.focus();
	}

	if((articletext4L > 0) && (articletext4L < 20) && (invalidFlag==false))			// for versions 2-10 its different from version 1
	{
		invalidFlag=true;
		alert("Please Enter Article Text in Version 4 of atleast 20 characters");
		window.document.AddArticleForm.articletext4.focus();
	}


	if((articletext5L > 0) && (articletext5L < 20) && (invalidFlag==false))			// for versions 2-10 its different from version 1
	{
		invalidFlag=true;
		alert("Please Enter Article Text in Version 5 of atleast 20 characters");
		window.document.AddArticleForm.articletext5.focus();
	}


	if((articletext6L > 0) && (articletext6L < 20) && (invalidFlag==false))			// for versions 2-10 its different from version 1
	{
		invalidFlag=true;
		alert("Please Enter Article Text in Version 6 of atleast 20 characters");
		window.document.AddArticleForm.articletext6.focus();
	}



	if((articletext7L > 0) && (articletext7L < 20) && (invalidFlag==false))			// for versions 2-10 its different from version 1
	{
		invalidFlag=true;
		alert("Please Enter Article Text in Version 7 of atleast 20 characters");
		window.document.AddArticleForm.articletext7.focus();
	}


	if((articletext8L > 0) && (articletext8L < 20) && (invalidFlag==false))			// for versions 2-10 its different from version 1
	{
		invalidFlag=true;
		alert("Please Enter Article Text in Version 8 of atleast 20 characters");
		window.document.AddArticleForm.articletext8.focus();
	}

	if((articletext9L > 0) && (articletext9L < 20) && (invalidFlag==false))			// for versions 2-10 its different from version 1
	{
		invalidFlag=true;
		alert("Please Enter Article Text in Version 9 of atleast 20 characters");
		window.document.AddArticleForm.articletext9.focus();
	}

	if((articletext10L > 0) && (articletext10L < 20) && (invalidFlag==false))			// for versions 2-10 its different from version 1
	{
		invalidFlag=true;
		alert("Please Enter Article Text in Version 10 of atleast 20 characters");
		window.document.AddArticleForm.articletext10.focus();
	}
//---------------------------------


	if(invalidFlag==false)				// no invalid data - submit form
	return true;
	else							// invalid data - do not submit form
	return false;

}


//------------------------------

function CancelEditArticleForm()
{
	var full_url = "index.php?action=myaccount";
	document.location.href=full_url;	

}


//--------------------


function ValidateAddAnotherVersionForm()
{

var articletextL = window.document.addanotherversionform.articletext.value.length;
if(articletextL<20)
{
	alert("Please Enter 20 or more characters in Version");
	return false;
}

return true;


}

//-------------------------------

function ValidateEditArticleForm()
{


	var invalidFlag=false;			// means no filed has invalid value - initialization

	var titleL = window.document.EditArticleForm.title.value.length;
	var urlL = window.document.EditArticleForm.url.value.length;
	var fileL = window.document.EditArticleForm.file.value.length;
	var file = window.document.EditArticleForm.file.value;
	

	if((titleL < 5 )&& (invalidFlag==false))
	{
		invalidFlag=true;			// invalid value exists
		alert("Please Enter Title of atleast 5 characters");
		window.document.EditArticleForm.title.focus();
	}

	if((urlL < 5 )&& (invalidFlag==false))
	{
		invalidFlag=true;			// invalid value exists
		alert("Please Enter URL of atleast 5 characters");
		window.document.EditArticleForm.url.focus();
	}

	if((fileL > 0) && (fileL < 5 )&& (invalidFlag==false))
	{
		invalidFlag=true;			// invalid value exists
		alert("Please select image with valid path");
		window.document.EditArticleForm.file.focus();
	}


	//------------ Check For Picture Format (extension) --------------------

	if((fileL>=5) && (invalidFlag==false))	//--- picture is present - check for extension
	{

		var fileext = file.substring((fileL - 4),fileL);	// should return .gif or .jpg
		fileext = fileext.toLowerCase();			// convert the extension to lower case
		if((fileext == ".gif") || (fileext == ".jpg") || (fileext == ".png"))
		{
			// picture extension is OK
		}
		else
		{
			alert("InCorrect Picture Format - Please choose only .gif, .jpg or .png formats");
			invalidFlag=true;
		}
		

	}


	var returntype= BuildNewCategoryList();
	if(returntype==false)
	{
		invalidFlag=true;			// problem with new category list - new list empty no category selected
	}


	if(invalidFlag==false)				// no invalid data - submit form
	return true;
	else							// invalid data - do not submit form
	return false;
	

}



//-------------------------------

function ValidateLimitedEditArticleForm()
{


	var invalidFlag=false;			// means no filed has invalid value - initialization

	var titleL = window.document.LimitedEditArticleForm.title.value.length;
	var fileL = window.document.LimitedEditArticleForm.file.value.length;
	

	if((titleL < 5 )&& (invalidFlag==false))
	{
		invalidFlag=true;			// invalid value exists
		alert("Please Enter Title of atleast 5 characters");
		window.document.LimitedEditArticleForm.title.focus();
	}


	if((fileL > 0) && (fileL < 5 )&& (invalidFlag==false))
	{
		invalidFlag=true;			// invalid value exists
		alert("Please select image with valid path");
		window.document.LimitedEditArticleForm.file.focus();
	}



	if(invalidFlag==false)				// no invalid data - submit form
	return true;
	else							// invalid data - do not submit form
	return false;
	

}




//------------------

function BuildNewCategoryList()
{
	
var totalnumberofcategories = window.document.EditArticleForm.hiddentotalnumberofcategories.value;
var id="";
	for(var i=0;i<totalnumberofcategories;i++)
	{
		if(document.EditArticleForm.articlecategories[i].checked)
		{
			var temp = document.EditArticleForm.articlecategories[i].value;
			id= id + temp + ';';
		}

	}

	if(id=="")
	{
		alert("Please Select atleast one category");
		return false;
	}
	else
	{
		window.document.EditArticleForm.hiddennewcategorylist.value = id;
		return true;
	}


}








//--------------------

function GoToLogoff()
{
	var full_url = "index.php?action=logoff";
	document.location.href=full_url;		
}

//-------------------------------------

function GoToCheckExpiredArticlesPage()
{
	
	var full_url = "index.php?action=checkexpiredarticles";
	document.location.href=full_url;		

}

//-------------------------------------

function GoToListFreeArticles()
{
	
	var full_url = "index.php?action=listfreearticles";
	document.location.href=full_url;		

}



//-------------------------------------

function GoToListExpiredArticles()
{
	
	var full_url = "index.php?action=listexpiredarticles";
	document.location.href=full_url;		

}


//-------------------------------------

function GoToListActiveArticles()
{
	
	var full_url = "index.php?action=listactivearticles";
	document.location.href=full_url;		

}


//-------------------------------------

function GoToListDisabledArticles()
{
	
	var full_url = "index.php?action=listdisabledarticles";
	document.location.href=full_url;		

}

//-----------------
function GoToModifyArticle()
{
	var arid = window.document.modifyarticleform.ARID.value;
	var returntype = isNumeric(arid);
	if(returntype==true)
	{	
		var full_url = "index.php?action=editarticle&id=" + arid;
		document.location.href=full_url;		
	}
	else
	{
		alert("Please Enter Article ID in numeric Format");
		window.document.modifyarticleform.ARID.focus();
	}


}


//-----------------------

function ValidateChangeArticleStatusForm()
{

	var invalidFlag=false;

	var articleid = window.document.changearticlestatusform.ARID.value;

	var articleidL = window.document.changearticlestatusform.ARID.value.length;

	if(articleidL==0)			//empty article id
	{
		alert("Please Enter Article ID");
		window.document.changearticlestatusform.ARID.focus();
		invalidFlag=true;
	}
	var returntype = isNumeric(articleid);		// defined below

	if((returntype==false) && (invalidFlag==false))
	{
		alert("Please Enter Article ID in Correct Format (NUMBER)");
		window.document.changearticlestatusform.ARID.focus();
		invalidFlag=true;		
	}

	if(invalidFlag==false)
	return true;			// no problems with check
	else
	return false;			// problem with one or more check
	
	
	 

}


//-----------------------

function ValidateChangeExpiryDateForm()
{

	var invalidFlag=false;

	var articleid = window.document.changeexpirydateform.ARID.value;

	var articleidL = window.document.changeexpirydateform.ARID.value.length;

	if(articleidL==0)			//empty article id
	{
		alert("Please Enter Article ID");
		window.document.changeexpirydateform.ARID.focus();
		invalidFlag=true;
	}
	var returntype = isNumeric(articleid);		// defined below

	if((returntype==false) && (invalidFlag==false))
	{
		alert("Please Enter Article ID in Correct Format (NUMBER)");
		window.document.changeexpirydateform.ARID.focus();
		invalidFlag=true;		
	}

	if(invalidFlag==false)
	return true;			// no problems with check
	else
	return false;			// problem with one or more check
	
	
	 

}




//--------------------------


function ValidateChangeUserStatusForm()
{

	var invalidFlag=false;

	var userid = window.document.changeuserstatusform.URID.value;

	var useridL = 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 = window.document.ContactUs1.FN.value.length;

	var captchaL = window.document.ContactUs1.captcha.value.length;

	var emL = window.document.ContactUs1.EM.value.length;
	
	var questL = 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=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)
	{
		var referenceToSendingImage=document.getElementById('sending1');                    // returns reference to passed id sending please wait image as per w3c standards
		referenceToSendingImage.style.visibility="visible";

		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 ValidateEditVersionForm()
{

	var versiontextL = window.document.editversionform.articletext.value.length;
	if(versiontextL<20)
	{
		alert("Please Enter atleast 20 characters in version text"); 
		window.document.editversionform.articletext.focus();
		return false;
	}
	else
		return true;


}

//---------------------------------------------

function ValidateChangePaidStatusForm()
{
	var articleid = window.document.changepaidstatusform.ARID.value;
	var articleidL = window.document.changepaidstatusform.ARID.value.length;
	if(articleidL<1)
	{
		alert("Please Enter atleast Article ID"); 
		window.document.changepaidstatusform.ARID.focus();
		return false;
	}
	
	var returntype = isNumeric(articleid);
	if(returntype==false)
	{
		alert("Please Enter Numeric Article ID");
		window.document.changepaidstatusform.ARID.focus();
		return false;
	}
	else
		return true;


}



//--------------- 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 CalculatePayment(id,discountid,minnumid)
{
	var referenceToPrice=document.getElementById(id);                    // returns reference to passed id sending please wait image as per w3c standards

	var referenceToDiscount=document.getElementById(discountid);                    // returns reference to passed id sending please wait image as per w3c standards

	var referenceToMinNum=document.getElementById(minnumid);                    // returns reference to passed id sending please wait image as per w3c standards
	

	var referenceToPara1=document.getElementById("para1");                    // returns reference to passed id sending please wait image as per w3c standards
	var referenceToPara2=document.getElementById("para2");                    // returns reference to passed id sending please wait image as per w3c standards
	var referenceToPara3=document.getElementById("para3");                    // returns reference to passed id sending please wait image as per w3c standards
	var referenceToPara4=document.getElementById("para4");                    // returns reference to passed id sending please wait image as per w3c standards



	var numberofdomains = document.paidpaymentform.numberofdomains.value;



	referenceToMinNum.innerHTML = numberofdomains;
	
	var priceperlink = document.paidpaymentform.priceperlink.value;

	var duration = document.paidpaymentform.duration.value;
	
	var discount=0;

	if(duration==1)						// one month selected
	{
		discount = document.paidpaymentform.D1M.value;
	}
	if(duration==3)						// 3 month selected
	{
		discount = document.paidpaymentform.D3M.value;
	}
	if(duration==6)						// 6 month selected
	{
		discount = document.paidpaymentform.D6M.value;
	}
	if(duration==12)						// 12 month selected
	{
		discount = document.paidpaymentform.D12M.value;
	}
	
	

	
	var total = numberofdomains * duration * priceperlink;
	var discountamount=0;
	var nettotal

	if(discount > 0)
	{
		discountamount = (discount/100) * total;
		nettotal = total - discountamount;

//		referenceToDiscount.innerHTML = "<font class=normaltext><b>Discount Received :</b> " + discount + "% [$" + total.toFixed(2) + " - $" + discountamount.toFixed(2) + " = $" + nettotal.toFixed(2) + " ]";

		
		referenceToPara1.innerHTML = "<font class=normaltext>$ " + total.toFixed(2) + "</font>"; 
		referenceToPara2.innerHTML = "<font class=normaltext>$" + discountamount.toFixed(2) + "</font>"; 
		referenceToPara3.innerHTML = "<font class=normaltext><b>AU $" + nettotal.toFixed(2) + "</b></font>"; 
		referenceToPara4.innerHTML = "<b>" + discount + "%</b></font>"; 


	}
	else
	{
		nettotal=total;
//		referenceToDiscount.innerHTML = "<font class=success><small>Discount applies to 3, 6 and 12 months subscription</small></font>";
		referenceToPara1.innerHTML = "<font class=normaltext>$" + total.toFixed(2) + "</font>"; 
		referenceToPara2.innerHTML = "<font class=normaltext>$0.00</font>"; 
		referenceToPara3.innerHTML = "<font class=normaltext><b>AU $" + total.toFixed(2) + "</b></font>"; 
		referenceToPara4.innerHTML = "<b>" + discount + "%</b></font>"; 
	}


	referenceToPrice.innerHTML= "AUD $" + nettotal.toFixed(2);
	document.paidpaymentform.pricebox.value = nettotal.toFixed(2);						// enter price in hidden textbox for comparision with server generated price

}


function ValidateChangeArticleOwnerForm()
{
	var invalidFlag=false;

	var articleid = document.changearticleownerform.ARID.value;
	var articleidL = document.changearticleownerform.ARID.value.length;

	var ownerusername = document.changearticleownerform.ownerusername.value;
	var ownerusernameL = document.changearticleownerform.ownerusername.value.length;

	if((articleidL<1) && (invalidFlag==false))
	{
		alert("Please Enter Article ID");
		document.changearticleownerform.ARID.focus();
		invalidFlag=true;
	}


	var returntype = isNumeric(articleid);
	
	if((returntype==false) && (invalidFlag==false))
	{
		alert("Please Enter Numeric Article ID");
		document.changearticleownerform.ARID.focus();
		invalidFlag=true;
	}


	if((ownerusernameL<1) && (invalidFlag==false))
	{
		alert("Please Enter New Owner Username");
		document.changearticleownerform.ownerusername.focus();
		invalidFlag=true;
	}	




	if(invalidFlag==false)
		return true;		// no problem with validation
	else
		return false;		// validation failed		

}

//---------------------------- Function to validate forgot password form -------------------------

function ValidateForgotPasswordForm()        //  function to validate Password Request form
{
	invalidFlag=false;
	var unL = window.document.ForgotPassword1.UN.value.length;

	var unV = window.document.ForgotPassword1.UN.value;

	var captchaL = 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)
	{
		var referenceToSendingImage=document.getElementById('sending1');                    // returns reference to passed id sending please wait image as per w3c standards
		referenceToSendingImage.style.visibility="visible";

		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 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 ValidateAddDomainForm()
{
	invalidFlag=false;

	var domainurlL = window.document.addnewdomainform.domainurl.value.length;
	var templateL = window.document.addnewdomainform.template.value.length;
	var stylesheetL = window.document.addnewdomainform.stylesheet.value.length;
	var displaynameL = window.document.addnewdomainform.displayname.value.length;
	var taglineL = window.document.addnewdomainform.tagline.value.length;

	if((domainurlL<5) && (invalidFlag==false))
	{
		alert("Please enter Correct Domain Name");
		invalidFlag=true;
		window.document.addnewdomainform.domainurl.focus();
	}		

	if((templateL<1) && (invalidFlag==false))
	{
		alert("Please enter Template Folder Name");
		invalidFlag=true;
		window.document.addnewdomainform.template.focus();
	}
	
	if((stylesheetL<5) && (invalidFlag==false))
	{
		alert("Please enter Stylesheet Name");
		invalidFlag=true;
		window.document.addnewdomainform.stylesheet.focus();
	}

	if((displaynameL<2) && (invalidFlag==false))
	{
		alert("Please enter Correct Display Name");
		invalidFlag=true;
		window.document.addnewdomainform.displayname.focus();
	}

	if((taglineL<2) && (invalidFlag==false))
	{
		alert("Please enter Correct Tagline");
		invalidFlag=true;
		window.document.addnewdomainform.tagline.focus();
	}





	//--------------------- Article Category Checkbox array checking ------------------------
	//For each checkbox see if it has been checked, record the value.

	document.addnewdomainform.storecategoriesselected.value = "";							// ******** very important to clear previous categories
	var numberofcheckboxes = window.document.addnewdomainform.numberofcategories.value;

	   for (var i = 0; i < numberofcheckboxes; i++)
	   {
      	if (document.addnewdomainform.articlecategories[i].checked==true)
		{
      	   document.addnewdomainform.storecategoriesselected.value = document.addnewdomainform.storecategoriesselected.value + document.addnewdomainform.articlecategories[i].value + ";";

     		}	
  	  }	


	var categoriesselectedL = document.addnewdomainform.storecategoriesselected.value.length;
	if((categoriesselectedL < 2) && (invalidFlag==false))					// no category selected
	{
		invalidFlag=true;
		alert("Please Select one or more categories");
	}





	// 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 ends here



//-------------------- function to go to list of active domains -------------------------

function GoToListActiveDomains()
{
	var full_url = "index.php?action=listactivedomains";
	document.location.href=full_url;	
}

//-------------------- function to go to list of disabled domains -------------------------

function GoToListDisabledDomains()
{
	var full_url = "index.php?action=listdisableddomains";
	document.location.href=full_url;	
}



//------------------------------------

function ValidateEditDomainSubForm()
{
	var domainurlL = window.document.editdomainsubform.domainurl.value.length;

	if(domainurlL < 1)
	{
		alert("Please Enter Domain URL");
		window.document.editdomainsubform.domainurl.focus();
		return false;
	}
	else
	{
		return true;

	}


}


//--------------------------------

function ValidateModifyDomainForm()
{


	invalidFlag=false;

	var domainurlL = window.document.modifydomainform.domainurl.value.length;
	var templateL = window.document.modifydomainform.template.value.length;
	var stylesheetL = window.document.modifydomainform.stylesheet.value.length;
	var displaynameL = window.document.modifydomainform.displayname.value.length;
	var taglineL = window.document.modifydomainform.tagline.value.length;

	if((domainurlL<5) && (invalidFlag==false))
	{
		alert("Please enter Correct Domain Name");
		invalidFlag=true;
		window.document.modifydomainform.domainurl.focus();
	}		

	if((templateL<1) && (invalidFlag==false))
	{
		alert("Please enter Template Folder Name");
		invalidFlag=true;
		window.document.modifydomainform.template.focus();
	}
	
	if((stylesheetL<5) && (invalidFlag==false))
	{
		alert("Please enter Stylesheet Name");
		invalidFlag=true;
		window.document.modifydomainform.stylesheet.focus();
	}

	if((displaynameL<2) && (invalidFlag==false))
	{
		alert("Please enter Correct Display Name");
		invalidFlag=true;
		window.document.modifydomainform.displayname.focus();
	}

	if((taglineL<2) && (invalidFlag==false))
	{
		alert("Please enter Correct Tagline");
		invalidFlag=true;
		window.document.modifydomainform.tagline.focus();
	}



	var returntype= BuildNewDomainCategoryList();			// defined below
	if(returntype==false)
	{
		invalidFlag=true;			// problem with new category list - new list empty no category selected
	}


	if(invalidFlag==false)				// no invalid data - submit form
	return true;
	else							// invalid data - do not submit form
	return false;





}



//------------------

function BuildNewDomainCategoryList()
{
	
var totalnumberofcategories = window.document.modifydomainform.hiddentotalnumberofcategories.value;
var id="";
	for(var i=0;i<totalnumberofcategories;i++)
	{
		if(document.modifydomainform.domaincategories[i].checked)
		{
			var temp = document.modifydomainform.domaincategories[i].value;
			id= id + temp + ';';
		}

	}

	if(id=="")
	{
		alert("Please Select atleast one category");
		return false;
	}
	else
	{
		window.document.modifydomainform.hiddennewcategorylist.value = id;
		return true;
	}


}




//-------------------- function to go to 1 or 7 day reminider to user page -------------------------

function GoToSendReminderToUser()

{
	var full_url = "index.php?action=sendreminders";
	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 = window.document.modifyuseraccountform.fullname.value.length; 

	var fullnameV = window.document.modifyuseraccountform.fullname.value; 

	var emailText = window.document.modifyuseraccountform.email.value; 

	var emL = window.document.modifyuseraccountform.email.value.length; 


	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();

		}

	}

	
//----------- Email validation ------------

	if((emL<6) && (invalidFlag==false))
	{
		alert("Please enter your Email");
		invalidFlag=true;
		window.document.modifyuseraccountform.email.focus();
	}


	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.modifyuseraccountform.email.focus();
	}

//---------------- Email Validation Ends----------------------

//----------------- Password limit and matching with confirm password---------------

	
	var pw1L = window.document.modifyuseraccountform.PW1.value.length;
	var pw2L = window.document.modifyuseraccountform.PW2.value.length;

	var pw1Text=window.document.modifyuseraccountform.PW1.value;
	var pw2Text=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(invalidFlag==false)
		return true;
	else
		return false;


}

//------------------------------------------
function GoToMyAccountPage()
{

	var full_url = "index.php?action=myaccount";
	document.location.href=full_url;	


}
//--------------------------------------

function ValidateShowAllArticlesPostedByUserForm()
{
	
	var invalidFlag=false;

	var uid = window.document.ShowAllArticlesPostedByUserForm.URID.value;

	var uidL = window.document.ShowAllArticlesPostedByUserForm.URID.value.length;
	
	var username = window.document.ShowAllArticlesPostedByUserForm.username.value;

	var usernameL = window.document.ShowAllArticlesPostedByUserForm.username.value.length;
	
	if(uidL>0)
	{
		var returnvalue = isNumeric(uid);
		if(returnvalue==false)
		{
			alert("Please Enter Numeric User ID");
			window.document.ShowAllArticlesPostedByUserForm.URID.focus();
			invalidFlag=true;
		}
	}
	
	if(((uidL==0) && (usernameL==0)) && (invalidFlag==false))
	{
		alert("Please Enter User ID or User Name");

		window.document.ShowAllArticlesPostedByUserForm.URID.focus();
	
		invalidFlag=true;


	}

	if(invalidFlag==true)
		return false;
	else
		return true;

}



//------------------------------------


function ConfirmationNotGiven()
{
//	var full_url = "index.php?action=myaccount";
//	document.location.href=history.back();	

	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 to go to Rejected Articles List -------------------------

function GoToListRejectedArticles()

{
	var full_url = "index.php?action=listrejectedarticles";
	document.location.href=full_url;	
}


//-------------------------------------------------------
function FillNumberOfDomains()
{
	var domainnumberselected = document.paidpaymentform.websitenumber.value;
	document.paidpaymentform.numberofdomains.value = domainnumberselected;
	
	//------ Update Price When Number of Websites Changed
	CalculatePayment('price','discountid','minnum');

}



//----------------------------------------------------------

function GoToListArticleHostWebsites()
{
	var arid = window.document.listhostwebsitesform.ARID.value;
	var returntype = isNumeric(arid);
	if(returntype==true)
	{	
		var full_url = "index.php?action=showhostwebsites&id=" + arid;
		document.location.href=full_url;		
	}
	else
	{
		alert("Please Enter Article ID in numeric Format");
		window.document.listhostwebsitesform.ARID.focus();
	}


}



//---------------------------------------------------------------------

//--------------------------------------

function ValidateUserPaymentDetailsForm()
{
	
	var invalidFlag=false;

	var uid = window.document.userpaymentdetailsform.URID.value;

	var uidL = window.document.userpaymentdetailsform.URID.value.length;
	
	var username = window.document.userpaymentdetailsform.username.value;

	var usernameL = 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 ValidateDomainAllocationForm()
{

	var invalidFlag=false;

	var aid = window.document.domainallocationform.ARID.value;

	var aidL = window.document.domainallocationform.ARID.value.length;
	
	var numdomains = window.document.domainallocationform.numdomains.value;

	var numdomainsL = window.document.domainallocationform.numdomains.value.length;


	if(aidL==0)
	{
			alert("Please Enter Article ID");
			window.document.domainallocationform.ARID.focus();
			invalidFlag=true;

	}


	if((aidL>0) && (invalidFlag==false))
	{
		var returnvalue = isNumeric(aid);
		if(returnvalue==false)
		{
			alert("Please Enter Article ID (Numeric)");
			window.document.domainallocationform.ARID.focus();
			invalidFlag=true;
		}
	}


	if((numdomainsL==0) && (invalidFlag==false))
	{
			alert("Please Enter Number of Domains");
			window.document.domainallocationform.numdomains.focus();
			invalidFlag=true;

	}
	

	if((numdomainsL>0) && (invalidFlag==false))
	{
		var returnvalue = isNumeric(numdomains);
		if(returnvalue==false)
		{
			alert("Please Enter Number of Domains (Numeric)");
			window.document.domainallocationform.numdomains.focus();
			invalidFlag=true;
		}
	}

	if(invalidFlag==true)
		return false;
	else
		return true;


}


//-------------------------------------------------------
function ValidateReasonForRejectionForm()
{

	var reasonL = 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 GoToArticleAdministration()
{
	var full_url = "index.php?action=mainarticleadministration";
	document.location.href=full_url;	

}


//----------------------------------------------------------------

function GoToUserAdministration()
{
	var full_url = "index.php?action=mainuseradministration";
	document.location.href=full_url;	

}

//----------------------------------------------------------------

function GoToDomainAdministration()
{
	var full_url = "index.php?action=maindomainadministration";
	document.location.href=full_url;	

}


//----------------------------------------------------------------

function GoToGenerateDomainHitsReport()
{
	var full_url = "index.php?action=generatedomainhitsreport";
	document.location.href=full_url;	

}





//--------------------------------------

function ValidateUserReportForm1()
{
	
	var invalidFlag=false;

	var uid = window.document.userreportform1.URID.value;

	var uidL = window.document.userreportform1.URID.value.length;
	
	var username = window.document.userreportform1.username.value;

	var usernameL = window.document.userreportform1.username.value.length;
	
	if(uidL>0)
	{
		var returnvalue = isNumeric(uid);
		if(returnvalue==false)
		{
			alert("Please Enter Numeric User ID");
			window.document.userreportform1.URID.focus();
			invalidFlag=true;
		}
	}
	
	if(((uidL==0) && (usernameL==0)) && (invalidFlag==false))
	{
		alert("Please Enter User ID or User Name");

		window.document.userreportform1.URID.focus();
	
		invalidFlag=true;


	}

	if(invalidFlag==true)
		return false;
	else
		return true;

}

//---------------------------------------------------------------------


function GoToGenerateArticlesHostedReport()
{
	var full_url = "index.php?action=generatearticleshostedreport";
	document.location.href=full_url;	

}



//-----------------------------------------------------

function PrintThis()                                               // function for printing the Invoices
{
	window.print();
}


//-------------------------------------------------------------------------------

function ValidateFreePaymentForm()
{

	var couponcodeL = window.document.freepaymentform.couponcode.value.length;
	
	if((couponcodeL > 0) && (couponcodeL < 8))				// if coupon code is entered but length is less than 8 chars
	{

		alert("Please Enter 8 digit Coupon Code. If you do not have a Coupon Code please leave Coupon field blank and click on Submit button");
		window.document.freepaymentform.couponcode.value="";
		window.document.freepaymentform.couponcode.focus();
		return false;
		
	}
	else
	{
		return true;				// either coupon code of 8 digits is entered or coupon code is not entered at all - Submit form
	}


}
//----------------------------------------------------------------------------------

function GotoCouponsPage(pagenumber)
{

	if(pagenumber=='1')				// user has clicked on "Create New Coupon" button
	{
		var full_url = "index.php?action=createnewcoupon";
		document.location.href=full_url;	
	
	}

	else if(pagenumber=='2')			// user has clicked on "List / Modify Coupons" button
	{
		var full_url = "index.php?action=listcoupons";
		document.location.href=full_url;	
	}


}

//-------------------------------------------------------------------------------------

function ValidateCreateNewCouponForm()
{

	var couponcodeL = window.document.createnewcouponform.couponcode.value.length;
	
	var couponsitesL	= window.document.createnewcouponform.couponsites.value.length;

	var couponsitesV	= window.document.createnewcouponform.couponsites.value;
	
	var totaldomains = window.document.createnewcouponform.hiddentotaldomains.value;


	var invalidFlag=false;

	if((couponcodeL < 8) && (invalidFlag==false))				// if coupon code is length is less than 8 chars
	{

		alert("Please Enter 8 digit Coupon Code.");
		window.document.createnewcouponform.couponcode.value="";
		window.document.createnewcouponform.couponcode.focus();
		invalidFlag=true;
		return false;
		
	}
	
	var returntype = isNumeric(couponsitesV);				// check format / value length for number of websites - function defined above
	
	if((returntype==false) && (invalidFlag==false))
	{
		alert("Please Enter Number of Sites (Numeric Format)");
		window.document.createnewcouponform.couponsites.value="";
		window.document.createnewcouponform.couponsites.focus();
		invalidFlag=true;
		return false;
	}
	

	if((couponsitesV > totaldomains) && (invalidFlag==false))
	{
		alert("Available Sites are less than Sites Allocated to Coupon.");
//		window.document.createnewcouponform.couponsites.value="";
		window.document.createnewcouponform.couponsites.focus();
		invalidFlag=true;
		return false;
	}
	
	return true;

}





//*************************************************************************************


function ValidateAddPressReleaseForm()
{


	invalidFlag=false;
	var headlineL = window.document.AddPressReleaseForm.headline.value.length;			// 10 chars

	var summaryL = window.document.AddPressReleaseForm.summary.value.length;			// 50 chars


	var newsbodyL = window.document.AddPressReleaseForm.newsbody.value.length;			// 100 chars

	var authorL = window.document.AddPressReleaseForm.author.value.length;				// 2 chars

	var emailL = window.document.AddPressReleaseForm.email.value.length;			// 5 chars


	var captchaL = window.document.AddPressReleaseForm.captcha.value.length;			// 5 chars

	var addressline1L = window.document.AddPressReleaseForm.addressline1.value.length;			// atleast 2 chars or 0

	var addressline2L = window.document.AddPressReleaseForm.addressline2.value.length;			// atleast 2 chars or 0

	var addressline3L = window.document.AddPressReleaseForm.addressline3.value.length;			// atleast 2 chars or 0

	var countryV = window.document.AddPressReleaseForm.countrylist.value;			// not equal to 0 if address is filled 0

	var postcodeL = window.document.AddPressReleaseForm.postcode.value.length;			// atleast 2 chars or 0
	
	var phoneL = window.document.AddPressReleaseForm.phone.value.length;			// atleast 8 chars or 0

	var faxL = window.document.AddPressReleaseForm.fax.value.length;			// atleast 2 chars or 0

	var websiteL = window.document.AddPressReleaseForm.website.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 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=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 security code
	if((captchaL<5) && (invalidFlag==false))
	{
		alert("Please Enter Security Code of 5 characters");
		invalidFlag=true;
		window.document.AddPressReleaseForm.captcha.focus();
	}

	

	var addressflag = false;

	if((addressline1L>0) || (addressline2L>0) || (addressline3L>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 City
	if((addressline2L<2) && (invalidFlag==false) && (addressflag==true))
	{
		alert("Please Enter City / Town");
		invalidFlag=true;
		window.document.AddPressReleaseForm.addressline2.focus();
	}

	// ----- Check State
	if((addressline3L<2) && (invalidFlag==false) && (addressflag==true))
	{
		alert("Please Enter State");
		invalidFlag=true;
		window.document.AddPressReleaseForm.addressline3.focus();
	}
	
	// ----- Check Country Selection
	if((countryV==0) && (invalidFlag==false) && (addressflag==true))			// 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();
	}

if(invalidFlag==true)
	return false;
else
	return true;




}






//*************************************************************************************


function ValidateEditPressReleaseForm()
{

	invalidFlag=false;
	var headlineL = window.document.EditPressReleaseForm.headline.value.length;			// 10 chars

	var summaryL = window.document.EditPressReleaseForm.summary.value.length;			// 50 chars


	var newsbodyL = window.document.EditPressReleaseForm.newsbody.value.length;			// 100 chars

	var authorL = window.document.EditPressReleaseForm.author.value.length;				// 2 chars

	var emailL = window.document.EditPressReleaseForm.email.value.length;			// 5 chars



	var addressline1L = window.document.EditPressReleaseForm.addressline1.value.length;			// atleast 2 chars or 0

	var addressline2L = window.document.EditPressReleaseForm.addressline2.value.length;			// atleast 2 chars or 0

	var addressline3L = window.document.EditPressReleaseForm.addressline3.value.length;			// atleast 2 chars or 0

	var countryV = window.document.EditPressReleaseForm.countrylist.value;			// not equal to 0 if address is filled 0

	var postcodeL = window.document.EditPressReleaseForm.postcode.value.length;			// atleast 2 chars or 0
	
	var phoneL = window.document.EditPressReleaseForm.phone.value.length;			// atleast 8 chars or 0

	var faxL = window.document.EditPressReleaseForm.fax.value.length;			// atleast 2 chars or 0

	var websiteL = window.document.EditPressReleaseForm.website.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 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=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----------------------









	

	var addressflag = false;

	if((addressline1L>0) || (addressline2L>0) || (addressline3L>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 City
	if((addressline2L<2) && (invalidFlag==false) && (addressflag==true))
	{
		alert("Please Enter City / Town");
		invalidFlag=true;
		window.document.EditPressReleaseForm.addressline2.focus();
	}

	// ----- Check State
	if((addressline3L<2) && (invalidFlag==false) && (addressflag==true))
	{
		alert("Please Enter State");
		invalidFlag=true;
		window.document.EditPressReleaseForm.addressline3.focus();
	}
	
	// ----- Check Country Selection
	if((countryV==0) && (invalidFlag==false) && (addressflag==true))			// address is set but country is not selected
	{
		alert("Please Choose Country");
		invalidFlag=true;
		window.document.EditPressReleaseForm.country.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 = 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;

}