// JavaScript Document
 function IsBlankField(field){
	var j = 0;
	var chr;

	for(j; j < field.length; j++){
	    chr = field.charAt(j);

	    if(chr != "" && chr != " " && chr != "\n" && chr != "\t"){
		return false;
	    }
	}

	return true;
    }

    function SendTo(id){
        //shortening form elements
        var subscriptionForm      = document.getElementById('subscriptionForm');
        var txttrack   = document.getElementById('TRACK');
		var txtterm   = document.getElementById('TERM');
		var txtbilling  = document.getElementById('BILLING');
        var subURL;    // this variable will hold the URL of the search engine to be used
		var trackVar;    // this variable will hold the tracking code
        var termVar;    // this variable will hold the term of subscription
    
		if(id == "freetrial"){
		subURL = "https://subscribe.pcspublink.com/magazine/Intw/addSubscription.asp";
		trackVar = "JEMBS0";
		termVar = "4";
		billingvar  = "True";
            } else{
		subURL = "https://subscribe.pcspublink.com/magazine/Intw/addSubscription.asp";
		trackVar = "JEMCS0";
		termVar = "5";
		billingvar  = "False";
            }

            //adding the attribute name and values to the form and text field elements
	    subscriptionForm.setAttribute("action", subURL);
	    txttrack.setAttribute("value", trackVar);
		txtterm.setAttribute("value", termVar);
		txtbilling.setAttribute("value", billingvar);
		//subscriptionForm.submit();  
		//}

    }

function validateform(subscriptionForm)
{
		var txtfname   = document.getElementById('FNAME');
		var txtlname   = document.getElementById('LNAME');
		var txtstreet1  = document.getElementById('STREET1');
		var txtstreet2   = document.getElementById('STREET2');
		var txtcity   = document.getElementById('CITY');
		var txtstate   = document.getElementById('STATE');
		var txtzip   = document.getElementById('ZIP');
		var txtemail   = document.getElementById('EMAIL');
		var highlight = "font-size:9px; width:100px; background-color: #fffc00;";
		var blank = "";

		if(txtfname.value == "First Name"){
            //if the form doesn't validate, send this alert
			alert("Please enter your first name!");
			subscriptionForm.FNAME.focus();
			txtfname.setAttribute("style", highlight);
			return (false);
		}
		
		if(txtlname.value == "Last Name"){
            //if the form doesn't validate, send this alert
            alert("Please enter your last name!");
			subscriptionForm.LNAME.focus();
			txtlname.setAttribute("style", highlight);
			return (false);
		}
		
		if(txtstreet1.value == "Address 1"){
            //if the form doesn't validate, send this alert
            alert("Please enter your address!");
			subscriptionForm.STREET1.focus();
			txtstreet1.setAttribute("style", highlight);
			return (false);
		}
		
		if(txtstreet2.value == "Address 2"){
            //if the form doesn't validate, send this alert
			txtstreet2.setAttribute("value", blank);
		}
		
		if(txtcity.value == "City"){
            //if the form doesn't validate, send this alert
            alert("Please enter your city!");
			subscriptionForm.CITY.focus();
			txtcity.setAttribute("style", highlight);
			return (false);
		}
		
		if(txtstate.value == ""){
            //if the form doesn't validate, send this alert
            alert("Please enter your state!");
			subscriptionForm.STATE.focus();
			txtstate.setAttribute("style", highlight);
			return (false);
		}
		
		if(txtzip.value == "Zip Code"){
            //if the form doesn't validate, send this alert
            alert("Please enter your zip code!");
			subscriptionForm.ZIP.focus();
			txtzip.setAttribute("style", highlight);
			return (false);
		}
		if(txtemail.value == "Email"){
            //if the form doesn't validate, send this alert
            alert("Please enter your email address!");
			subscriptionForm.EMAIL.focus();
			txtemail.setAttribute("style", highlight);
			return (false);
		}
}