/*TO SET THE CURRENT YEAR FOR THE COPYRIGHT*/
var curdate = new Date()
var year = curdate.getYear()

/* Check if Cookies are enabled */
function cc()
{
 /* check for a cookie */
  if (document.cookie == "") 
  {
    /* if a cookie is not found - alert user -
     change cookieexists field value to false */
    alert("You will need to enable COOKIES in order to download any articles or white papers!");

    /* If the user has Cookies disabled an alert will let him know 
        that cookies need to be enabled to log on.*/ 

    document.form1.cookieexists.value ="false"  
  } else {
   /* this sets the value to true and nothing else will happen,
       the user will be able to log on*/
    document.form1.cookieexists.value ="true"
  }
}

/* Set a cookie to be sure that one exists.
   Note that this is outside the function*/
document.cookie = 'killme' + escape('nothing')

/*THIS IS THE VALIDATION FOR THE LEAD FORM*/
function ValidateForm(form)
{
	if (document.form1.realname.value=="")
	{
	alert("Please enter your Name.");
	document.form1.realname.focus();
	return false;
	}

	if (document.form1.Title.value=="")
	{
	alert("Please enter your Job Title.");
	document.form1.Title.focus();
	return false;
	}

	if (document.form1.Company.value=="")
	{
	alert("Please enter your Company Name.");
	document.form1.Company.focus();
	return false;
	}

	if (document.form1.Phone.value=="")
	{
	alert("Please enter your Phone Number.");
	document.form1.Phone.focus();
	return false;
	}
	if(!check_email(document.form1.email.value))
		{
		    alert("Please make sure your Email Address is Correct");
			document.form1.email.focus();
		return false;
		}


	if (document.form1.Heardthrough.value==0)
	{
	alert("Please tell us how you heard about us.");
	document.form1.Heardthrough.focus();
	return false;
	}


	if (document.form1.Heardthrough.value=="Other")
	{
		if (document.form1.ChooseOther.value=="")
			{
			alert("Please tell us how you heard about us.");
			document.form1.ChooseOther.focus();
			return false;
			}
	}
		   
	return true;
} 

function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0) return (false);	
	}
	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) return (-1);
	}
}

//GET VARIABLES IN URL FOR DOWNLOADS
function getArgs() {
	var args = new Object();
	var query = location.search.substring(1); // Get Query String
	var pairs = query.split("&"); // Split query at the comma
	// Begin loop through the querystring
	for(var i = 0; i < pairs.length; i++) {
		var pos = pairs[i].indexOf('='); // Look for "name=value"
		if (pos == -1) continue; // if not found, skip to next
		var argname = pairs[i].substring(0,pos); // Extract the name
		var value = pairs[i].substring(pos+1); // Extract the value
		args[argname] = unescape(value); // Store as a property
	}
	return args; // Return the Object
}

var args = getArgs(); //Get the querystring arguments