if (navigator.appName=="Netscape" && parseFloat(navigator.appVersion)<=4.9)
		alert("Warning\n\nYou are using an older Version of Netscape \nwhich is no longer supported.\n\nIt is recommended that you upgrade.\n\nYou may continue,  \nbut screen formatting and some options may not work as it was intended.");

var path = 'http://www.freedompressonline.com/';
var home = 'index.asp';
var Editpath = 'content/';

function showWin(which,parm,parm1)
{
	var newwinname = which;
	switch (which) {
		case 'help': 	
			opts = 'menubar=0,location=0,status=0,scrollbars=1,toolbar=0,width=450,height=340';
			LinkURL = path + 'ShowTextSm.asp?PageType=help&help=' + parm ;
			break;

		case 'helpNum': 	
			opts = 'menubar=0,location=0,status=0,scrollbars=1,toolbar=0,width=450,height=340';
			LinkURL = path + 'ShowTextSm.asp?PageType=help&helpid=' + parm ;
			break;

		case 'upLoad': 	
			opts = 'menubar=0,location=0,status=0,scrollbars=1,toolbar=0,width=450,height=340';
			LinkURL = 'UpLoadFile.asp?up='+parm + '&val='+parm1;
			break;

		case 'pass': 	
			opts = 'menubar=0,location=0,status=0,scrollbars=1,toolbar=0,width=340,height=200';
			LinkURL = path + 'SendPass.asp?ps='+parm;
			break;

		case 'cc': 	
			opts = 'menubar=0,location=0,status=0,scrollbars=0,toolbar=0,width=340,height=150';
			LinkURL = path + Editpath+ 'showCC.asp?OrderId='+parm;
			break;

		case 'quickInfo':
			opts = 'menubar=0,location=0,status=0,scrollbars=1,toolbar=0,resizable=1,width=800,height=340';
			LinkURL = path + 'WIInfo.asp?pt='+parm+ '&UId='+parm1;
			break;

		case 'ResDesc':
			opts = 'menubar=0,location=0,status=0,scrollbars=1,toolbar=0,resizable=1,width=800,height=400';
			LinkURL = path + 'WIShowText.asp?PageType=ResDesc&Id=' + parm ;
			break;
	}

	thiswin = window.open(LinkURL, newwinname, opts );
	thiswin.focus();
	
}

function askDelete( path, strName, delmsg )
{
	var msg = 'Are you sure you want to DELETE\n\n' + strName  + '?' + '\n';
	if (delmsg != '') 
		msg = delmsg ;
		
	if( confirm(msg) )
	{
		path.deleteEntry.value = "yes";
		path.submit();
	}
}

function stripscript(theField)	{

	var astr = theField.value;
	astr = astr.replace(/script/gi, '');
	astr = astr.replace(/.js/gi, '');
	astr = astr.replace(/http/gi, '');
	astr = astr.replace(/</g, '');
	astr = astr.replace(/>/g, '');
	theField.value = astr;
}

function inValidCharacters(str,charset)
{
	var result = false;
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))>-1)
		{	result = true;
			break;
		}
	return result;
}

function logOff() 
{	
	var loc=path+home;
	window.location = loc;
	alert('\nYou have been logged Off.\n\n You may continue at a later time by clicking on resume test on your Wellness Homepage.\n');
}

function OpenLinkUpdate(LinkType, Id, LinkTypeId )
{
	LinkURL = 'EditLinks.asp?LinkType=' + LinkType + '&Id=' + Id + '&LinkTypeId=' + LinkTypeId;	
	window.open (LinkURL, LinkType, 'scrollbars=1,titlebar=1,status=1,resizable=1,ll;l, height=410, width=804');
}
function checkStoreSearch( path )
{
	var msg = '';
	if (path.searchstring.value == "" && path.StateCode.value==0)
		msg += "\n Please fill in a search string or select a State to search on" ;
	if (path.searchstring.value != "" && path.searchby[1].checked==true && path.searchstring.value.length<5)
		msg += "\n Please use at least 5 letters to search by" ;
	if (path.searchstring.value != "" && path.searchby[0].checked==true && path.searchstring.value.length<3)
		msg += "\n Please use at least 3 letters to search by" ;
	if (path.searchstring.value != "" && (path.searchby[2].checked==true || path.searchby[3].checked==true) && path.searchstring.value.length<3)
		msg += "\n Please use at least 3 numbers to search by" ;

	if ( msg != "" )	   	
	{	 alert(msg);
		 return false;
	}
	else 
		return true;
}

function checkemail( path, type )
{
	var msg = '';
	if (path.subject.value == "")
		 msg += "\n Subject" ;
	if ( path.mailBody.value == "" )
		 msg += '\n Email Body' ;

	if ( type == 'test' )	{
		if ( path.TestFrom.value == "" )
			 msg += '\n Test email address' ;
		}
	else	{
		if ( path.fromName.value == "" )
			 msg += '\n From Name' ;
		if ( path.fromEmail.value == "" )
			 msg += '\n From Email' ;
	}

	if ( msg != "" )	   	
		{	msg = 'Please fill in the following field(s)\n' + msg;
			alert(msg);
		}
	else {
	 	path.action.value=type;
		window.document.email.submit(); 
	}
}

function checkProfile( path, type )
{
	var msg = '';
	msg += ValidateEmail(path.email.value) ;
	if ( path.FirstName.value == "" )
		 msg += '\n First Name' ;
	if ( path.LastName.value == "" )
		 msg += '\n Last Name' ;
	if ( msg != "" )	   	
		{	msg = 'Please fill in the following field(s)\n' + msg;
			alert(msg);
			return false;
		}
	else return true;
}

function checkNewMember( path )
{
	var msg = '';

	msg += ValidateEmail(path.Email.value) ;

	if ( path.Name.value == "" )
		 msg += '\n     -  Name' ;

	if ( path.PostalCode.value == "" )
		 msg += '\n     -  Postal Code' ;

	if( path.Pass.value == '')
		msg += '"\n     -  Password' ;
		
	if( path.Pass.value != path.Pass2.value)
		msg += '\n     -  Passwords must match' ;

	if ( msg != "" )	   	
		{	msg = 'Please fill or correct the following field(s)\n' + msg;
			alert(msg);
			return false;
		}
	else return true;
}


function checkFields(path){
	
	if( path.Retailer.value == ''){
		alert('Retailer Name is Required');
		path.Retailer.focus();
		return false;} 
	
	if( path.Address.value == ''){
		alert('Address is Required');
		path.Address.focus();
		return false;} 

	if( path.City.value == ''){
		alert('City is Required');
		path.City.focus();
		return false;} 
	
	if( path.StateId.value == ''){
		alert('State is Required');
		path.StateId.focus();
		return false;}  

	if( path.StateId.value == ''){
		alert('State is Required');
		path.StateId.focus();
		return false;}  

	if( path.Zip.value == ''){
		alert('Zip Code is Required');
		path.Zip.focus();
		return false;}  

	if( path.Contact.value == ''){
		alert('Contact is Required');
		path.Contact.focus();
		return false;}  

	if( path.Phone.value == ''){
		alert('Phone is Required');
		path.Phone.focus();
		return false;}  

	if( path.Email.value == ''){
		alert('Email is Required');
		path.Email.focus();
		return false;}  

//	if( path.Password.value == ''){
//		alert('Password is Required');
//		path.Password.focus();
//		return false;}  
		
//	if( path.Password.value != path.Password2.value){
//		alert('Passwords must match');
//		path.Password.focus();
//		return false;}  
	
		
	return true;
}

function checkRetailer(path){

	if( path.Retailer.value == '') {
		alert('Retailer Name is Required');
		path.Retailer.focus();
		return false; 	} 
	if( path.Address.value == ''){
		alert('Address is Required');
		path.Address.focus();
		return false;	} 
	if( path.City.value == ''){
		alert('City is Required');
		path.City.focus();
		return false;	} 
	if( path.Contact.value == ''){
		alert('Contact is Required');
		path.Contact.focus();
		return false;	} 
	if( path.Phone.value == ''){
		alert('Phone is Required');
		path.Phone.focus();
		return false; 	} 
	if( path.Email.value == ''){
		alert('Email is Required');
		path.Email.focus();
		return false;} 
	if( path.OrderAmount.value == ''){
		alert('Order Amount is Required');
		path.OrderAmount.focus();
		return false;} 
	return true;
}

function checkPass( path )	{

	if( path.Password.value == ''){
		alert('Password is Required');
		path.Password.focus();
		return false;}  
}

function checkSearch( path )
{
	var msg = '';
	if ( path.search.value == "" && path.CategoryId.value==0)
		 msg += '\n Please select either Keywords or a category to search' ;
	if ( msg != "" )	   	
		{	//msg = 'Please correct the following \n' + msg;
			alert(msg);
			return false;
		}
	else return true;
}

function checkBookSearch( )
{
	var msg = '';
	if ( Store.search.value == "" && Store.CategoryId.value==0)
		 msg += '\n Please select either Keywords or a category to search' ;
	if ( msg != "" )	   	
		{	
			alert(msg);
//			return false;
		}
	else 
		Store.submit();
//		return true;
}

function checkSiteSearch( form )
{
	if (form.searchText.value== "")
		{	
			alert('\n Please enter some text to search by');
			return false;
		}
	else 
		return true;
}

function checkActionSteps(path)
{
	var newfld ='';
	for (var i = 1; i < path.actioncount.value; i++) {
	 	newfld = eval('WellnessName.ActionStep' + i + '.value') ;
		 if (newfld != '') 
		 	return true;
	}		
	alert('Please create at least 1 action step ');
	return false;
}

function checkNotes( path )
{
	if( path.Note.value == "" )
	{
		alert('Please fill in Notes ');
		return false;
	}
	return true;
}

function ValidateEmail(em) {
		if (em == "") 
			return "\n     -  Email Address" ;
		else {
			if (em.length < 6 || em.indexOf('@')==-1 || em.indexOf('@')==0 || em.indexOf('.')==-1) 
				return "\n     -  Invalid Email Address";
			else
				return '';
		}	
}		

function checkStart(form) {
	var msg='';
	if (form.UserName.value == '')
		 msg += "\n     -  User Name" ;
	if (form.Password.value == '') 
		msg += "\n     -  Password";

	if ( msg != "" )	   	
		{	msg = "Please fill in the following field(s)\n" + msg;
			alert(msg);
			return false
		}
	else return true; 
}

function checkLogin( path )	
{
	var msg='';
	msg += ValidateEmail(path.Email.value);

	if ( path.Pass.value == "" )
		msg += '\n     -  Your Password' ;

	if (msg != "") {
		msg ="\n" +
			 "The following fields must be filled in or corrected\n" +
			 msg + "\n" +
			 "\nPlease re-enter ";
		alert(msg);
		return false;
	}
	else return true;
}

function checkInquiry( path )	{

	var msg='';
	if ( path.Name.value == "" )
		msg += '\n     -  Your Name' ;
	if ( path.City.value == "" )
		msg += '\n     -  Your City' ;
	if ( path.Question.value == "" )
		msg += '\n     -  Question Text ' ;
	msg += ValidateEmail(path.Email.value);

	if (msg != "") {
		msg ="\n" +
			 "The following fields must be filled in or corrected\n" +
			 msg + "\n" +
			 "\nPlease re-enter ";
		alert(msg);
		return false;
	}
	else return true;

}

function checkSubscribe( path )	
{
	var msg='';
	if ( path.Name.value == "" )
		msg += '\n     -  Your Name' ;

	msg += ValidateEmail(path.Email.value);

	if (msg != "") {
		msg ="\n" +
			 "The following fields must be filled in or corrected\n" +
			 msg + "\n" +
			 "\nPlease re-enter ";
		alert(msg);
		return false;
	}
	else return true;
}

function checkMagRequest( path )	
{
	var msg='';
	if ( path.StoreName.value == "" )
		msg += '\n     -  Store Name' ;
	if ( path.Name.value == "" )
		msg += '\n     -  Your Name' ;
	if ( path.Phone.value == "" )
		msg += '\n     -  Phone' ;
	if ( path.Email.value == "" )
		msg += '\n     -  Email' ;

	if (msg != "") {
		msg ="\n" +
			 "The following fields must be filled in or corrected\n" +
			 msg + "\n" +
			 "\nPlease re-enter ";
		alert(msg);
		return false;
	}
	else return true;

}

function checkReprints( path )	{

	var cnt = path.ArtCount.value*3; 	// 3 control 2=1 for every check box 
	var invalid = true;
	var thisval = ''; 
	for (var i = 0; i < cnt; i++) {
		 if (path.elements[i].type=='checkbox') 
		 	if (path.elements[i].checked) 
		 		if (path.elements[i+2].value!='') {
					invalid = false;
					thisval+=path.elements[i].value + ':' + path.elements[i+2].value +',';
				}	
	}		

	if (invalid==true) {
		alert ('\n   Please select at least 1 Article with quantity for reprint') ;
		return false; 
	}
	path.orderMe.value=thisval;
	return true;	
}

function checkRequest( path )	
{
	var msg='';
	if ( path.Name.value == "" )
		msg += '\n     -  Your Name' ;
	if ( path.StoreName.value == "" )
		msg += '\n     -  Store Name' ;
	if ( path.Phone.value == "" )
		msg += '\n     -  Phone' ;

	msg += ValidateEmail(path.Email.value);

	if (msg != "") {
		msg ="\n" +
			 "The following fields must be filled in or corrected\n" +
			 msg + "\n" +
			 "\nPlease re-enter ";
		alert(msg);
		return false;
	}
	else return true;
}

function openEdit(OrderDetailId,del,ShipId) {
	if (del==1) {
		url = '/store/updatequantity.asp?NewQuantity=0&OrderDetailId=' + OrderDetailId ;
		window.location=url;
		}
	else {	
		url = '/store/editItem.asp?Id=' + OrderDetailId + '&ShippingTypeId='+ ShipId + '&del=' + del;	
		window.open(url,'eiwin','menubar=0,resizable,location=0,status=0,scrollbars=1,toolbar=0,width=340,height=400');
	}
}

function checkQuiz(form)  {
	var valid = false;
	for (var i = 1; i <= form.Qcnt.value; i++) {
		for (var j = 0; j <= eval('QuizScore.Acnt'+i+'.value')-1; j++) {
//			alert(i+' : '+j);
			if (eval('QuizScore.Poll'+i+'['+j+'].checked')==true)
				valid=true;				
		}
		if (valid==false) {
			alert ('Please fill in one answer for each question');
			return false;
		}
		else
			valid = false;				
	}
	return true;
}

function setImage(CCId)
{
	var imgpath = '/images/';
	var w = 75;
	var h = 47;
	switch (CCId) {
		case '0':
			var src = imgpath+'cc_M_V.gif';
			w = 127;
			h = 103;
			break;
		case '1' : 	
			var src = imgpath+'cc_VisaCard.gif';
			break;
		case '2' :
			var src = imgpath+'cc_MasterCard.gif';
			break;
		case '3' :
			var src = imgpath+'cc_AmexCard.gif';
			break;
		case '4' :
			var src = imgpath+'cc_DiscoverCard.gif';
			break;
	}	
	StoreForm.ccImage.src=src;
	StoreForm.ccImage.height=h;
	StoreForm.ccImage.width=w;
}

function checkUserForm(form) {
		msg = "";
		
		if (trim(form.ShipFirstName.value) == "") {
			msg += "\n     -  First Name";
		}
		if (trim(form.ShipLastName.value) == "") {
			msg += "\n     -  Last Name";
		}
		if (trim(form.ShipAddress.value) == "") {
			msg += "\n     -  Shipping Address";
		}
		if (trim(form.ShipCity.value) == "") {
			msg += "\n     -  Shipping City";
		}
		if (trim(form.ShipState.value) == "" && (form.ShipCountry.value == "US" || form.ShipCountry.value == "CA" )) {
			msg += "\n     -  Shipping State";
		}
		if (trim(form.ShipPostalCode.value) == "") {
			msg += "\n     -  Shipping Postal Code";
		}
		if (trim(form.ShipCountry.value) == "") {
			msg += "\n     -  Shipping Country";
		}
		if (trim(form.Phone.value) == "") {
			msg += "\n     -  Phone Number";
		}
		msg += ValidateEmail(trim(form.Email.value))

//		if (form.SendGift.checked == true) {
//			if (trim(form.GiftTo.value) == "") msg += "\n     -  Gift To";
//			if (trim(form.GiftFrom.value) == "") msg += "\n     -  Gift From";
//			if (trim(form.GiftNote.value) == "") msg += "\n     -  Gift Note";
//			if (trim(form.BillFirstName.value) == "") msg += "\n     -  Billing First Name";
//			if (trim(form.BillLastName.value) == "") msg += "\n     -  Billing Last Name";
//			if (trim(form.BillAddress.value) == "") msg += "\n     -  Billing Address";
//			if (trim(form.BillCity.value) == "") msg += "\n     -  Billing City";
//			if (trim(form.BillState.value) == "") msg += "\n     -  Billing State";
//			if (trim(form.BillPostalCode.value) == "") msg += "\n     -  Billing Zip Code";
//			if (trim(form.BillCountry.value) == "") msg += "\n     -  Billing Country";			
//		}

		// credit card checks		

		if ( form.Lessfreight.value=="Yes" ) {
			
			if (form.Shipping.value == 0 ) {
				msg += "\n     -  Shipping Method";
			}
			
			var ccNum = trim(form.CCNumber.value);
			var ccty = form.CCType.value;
			var len  = 0; 
			if (ccty == 0) {
				msg += "\n     -  Credit Card Type";
			}
			if (ccNum == "") {
				msg += "\n     -  Credit Card Number";
			}
			else {
				if (ccNum.indexOf('-') > 0) {
					msg += "\n     -  No dashes allowed in Credit Card Number";
				}
				if (ccNum.indexOf(' ') > 0) {
					msg += "\n     -  No spaces allowed in Credit Card Number";
				}
				if (ccty.charAt(0) == "A") 
					 len = 15
				else
					 len = 16
				if (ccNum.length != len) 
					msg += "\n     -  Invalid or Inocomplete Credit Card Number"
			}	
		}
		if (msg != "") {
			msg ="\n" +
				 "The following fields must be filled in or corrected\n" +
				 msg + "\n" +
				 "\nPlease re-enter ";
			alert(msg);
			return false;
		}
		else return true;
}

function OrderComplete()
{
	alert('Your order has been received and your payment has been accepted\n\n Thank you for shopping at Freedom Press Online'); 
}

function mxCreate(which) {
	var mt = 'mailto';
	var m  = 'support';
	var gu = 'freedompressonline';
	var fem = mt + ':' + m + '@' + gu + '.' + 'com';
	document.write("<a href='" + fem + "'>E-mail Customer Support</a>");
}	

function ltrim ( s )
{
	return s.replace( /^\s*/, "" );
}

function rtrim ( s )
{
	return s.replace( /\s*$/, "" );
}

function trim ( s )
{
	return rtrim(ltrim(s));
}
