﻿	var numfiles = 1
	
	function readCookies() {
		var expDays = 365; // number of days the cookie should last
		var expDate = new Date();
		expDate.setTime(expDate.getTime() +  (24 * 60 * 60 * 1000 * expDays)); 
		var company = GetCookie('company');
		var email = GetCookie("email");
		if (email == null) {
				if (location.search.length > 1) email = location.search.substring(1, location.search.length);
				else email = "";
				if (email != GetCookie('email')) SetCookie('email', email, expDate);
			}	
		if (company == null) {
				if (location.search.length > 1) company = location.search.substring(1, location.search.length);
				else company = "";
				if (company != GetCookie('company')) SetCookie('company', company, expDate);
			}
		document.myform.company.value = company;
		document.myform.email.value = email;
	}
	
	function form_valid()
	{
	    var valid = false;
	    var i = 0;
	    var filefield;
	    var filefields = document.getElementsByTagName('input');
	    while (!valid && (i <= filefields.length))
	    {
	        filefield = filefields[i];
	        try
	        {
	            if (filefield.type == 'file')
	                valid = (filefield.value != '');
	        }
	        catch(err) {}
	        i++;
	    }   
        i++;
        return valid;
	}
	
	function getCookieVal (offset) {  
		var endstr = document.cookie.indexOf (";", offset);  
		if (endstr == -1)    
		endstr = document.cookie.length;  
		return unescape(document.cookie.substring(offset, endstr));
	}
	function GetCookie (name) {  
		var arg = name + "=";  
		var alen = arg.length;  
		var clen = document.cookie.length;  
		var i = 0;  
		while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
		return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
	}
	function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
	}
	
	function checkMail( x )
	{
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) return true;
		else return false;
	}
	
	function checkCompany( x )
	{
		var illegal_chars = "/?<>\\:*|\""
		for (var i=0; i < x.length; i++) {
		var letter = x.charAt(i);
		if (illegal_chars.indexOf(letter) == -1)
			  continue
			else {
				alert("Invalid character in Company Name: \"" + letter + "\"");
				return false;
			}
		}
		return true;
	}
	
	function addfiles() {
		if (numfiles < 10) {
			numfiles++;
			var temp = "document.getElementById('file" + numfiles + "').style.display='block'";	
			eval( temp );
		}
		return false;
	}
	

	



