
function randomImagecustomer(){
	
	var numimages=6;
	var rndimg = new Array("../CommonFiles/Images/features1cust.jpg", "../CommonFiles/Images/features2cust.jpg", "../CommonFiles/Images/features3.jpg", "../CommonFiles/Images/features4.jpg","../CommonFiles/Images/features3.jpg","../CommonFiles/Images/features4.jpg"); 
	var x=(Math.floor(Math.random()*numimages));
	var randomimage=(rndimg[x]);
	document.getElementById("randomimage").src = randomimage ; 
	
	
}

function randomImage(){
	
	var numimages=6;
	var rndimg = new Array("../CommonFiles/Images/features1.jpg", "../CommonFiles/Images/features2.jpg", "../CommonFiles/Images/features3.jpg", "../CommonFiles/Images/features4.jpg","../CommonFiles/Images/features3.jpg","../CommonFiles/Images/features4.jpg"); 
	var x=(Math.floor(Math.random()*numimages));
	var randomimage=(rndimg[x]);
	document.getElementById("randomimage").src = randomimage ; 
	
	
}

	
function randomImageLinks(){
	
	var numimages=9;
	var rndimg = new Array("../../CommonFiles/Images/bridgebuilding.jpg","../../CommonFiles/Images/Hoop3.jpg", "../../CommonFiles/Images/switch1.jpg","../../CommonFiles/Images/switch2.jpg","../../CommonFiles/Images/goGreen.jpg", "../../CommonFiles/Images/fleetinfohub.jpg","../../CommonFiles/Images/fleetinfohub_2.jpg","../../CommonFiles/Images/switch3.jpg","../../CommonFiles/Images/switch4.jpg");
	var x=(Math.floor(Math.random()*numimages));
	var randomimage=(rndimg[x]);
	if(randomimage==rndimg[0])
	  document.getElementById('randomlink').href="../im3/im3technology.html";
	else if(randomimage==rndimg[1])
		document.getElementById('randomlink').href="../about/about.html";
	else if(randomimage==rndimg[2])
		document.getElementById('randomlink').href="../goGreen/goGreen.asp";
	else if(randomimage==rndimg[3])
		document.getElementById('randomlink').href="../goGreen/goGreen.asp";
	else if(randomimage==rndimg[4])
		document.getElementById('randomlink').href="../goGreen/goGreen.asp";
	else if(randomimage==rndimg[5])
		document.getElementById('randomlink').href="../fleetinfohub/fleetinfohub.html";
	else if(randomimage==rndimg[6])
		document.getElementById('randomlink').href="../fleetinfohub/fleetinfohub.html";
	else if(randomimage==rndimg[7])
		document.getElementById('randomlink').href="../goGreen/goGreen.asp";
	else if(randomimage==rndimg[8])
		document.getElementById('randomlink').href="../goGreen/goGreen.asp";
	document.getElementById("randomimage").src = randomimage ; 
	
	
	
	
	
}
function randomImageLinksCust(){
	
	var numimages=8;
	var rndimg = new Array("../../CommonFiles/Images/Hoop3.jpg", "../../CommonFiles/Images/switch1.jpg","../../CommonFiles/Images/switch2.jpg","../../CommonFiles/Images/goGreen.jpg", "../../CommonFiles/Images/fleetinfohub.jpg","../../CommonFiles/Images/fleetinfohub_2.jpg","../../CommonFiles/Images/switch3.jpg","../../CommonFiles/Images/switch4.jpg");
	var x=(Math.floor(Math.random()*numimages));
	var randomimage=(rndimg[x]);
	
	if(randomimage==rndimg[0])
		document.getElementById('randomlink').href="../about/about.html";
	else if(randomimage==rndimg[1])
		document.getElementById('randomlink').href="../goGreen/goGreen.asp";
	else if(randomimage==rndimg[2])
		document.getElementById('randomlink').href="../goGreen/goGreen.asp";
	else if(randomimage==rndimg[3])
		document.getElementById('randomlink').href="../goGreen/goGreen.asp";
	else if(randomimage==rndimg[4])
		document.getElementById('randomlink').href="../fleetinfohub/fleetinfohub.html";
	else if(randomimage==rndimg[5])
		document.getElementById('randomlink').href="../fleetinfohub/fleetinfohub.html";
	else if(randomimage==rndimg[6])
		document.getElementById('randomlink').href="../goGreen/goGreen.asp";
	else if(randomimage==rndimg[7])
		document.getElementById('randomlink').href="../goGreen/goGreen.asp";
	document.getElementById("randomimage").src = randomimage ; 
	
	
	
	
	
}
function randomGreenLinks(){
	
	var numimages=4;
	var rndimg = new Array("../../CommonFiles/Images/switch1.jpg", "../../CommonFiles/Images/switch2.jpg", "../../CommonFiles/Images/switch3.jpg","../../CommonFiles/Images/switch4.jpg");
	var x=(Math.floor(Math.random()*numimages));
	var randomimage=(rndimg[x]);
	if(randomimage==rndimg[0])
	  document.getElementById('randomlink').href="../goGreen/goGreen.asp";
	else if(randomimage==rndimg[1])
		document.getElementById('randomlink').href="../goGreen/goGreen.asp";
	else if(randomimage==rndimg[2])
	document.getElementById('randomlink').href="../goGreen/goGreen.asp";
	else if(randomimage==rndimg[3])
	document.getElementById('randomlink').href="../goGreen/goGreen.asp";
	document.getElementById("randomimage").src = randomimage ; 
	
	
	
	
	
}


function signup()
{	
	//EMAIL VALIDATION
	var goodEmail 	= $F("email").match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.sex)|(\.biz)|(\.aero)|(\.coop)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);
	apos		= $F("email").indexOf("@");
	dotpos		= $F("email").lastIndexOf(".");
	lastpos		= $F("email").length-1;
	var badEmail 	= (apos<1 || dotpos-apos<2 || lastpos-dotpos<2);

	if ($F("fname")=="")
	{
		alert("Please enter your first name");
		$("fname").focus();
		return false;
	}
	else if ($F("lname")=="")
	{
		alert("Please enter your last name");
		$("lname").focus();
		return false;
	}
	else if (($F("email") == "") || (!goodEmail && badEmail))		
	{
		alert("Please enter a valid email");
		$("email").focus();
		return false;
	}else if ($F("fnumber")=="")
	{
		alert("Please enter your fleet count");
		$("fnumber").focus();
		return false;
	}
	//YOU MAY WANT TO CHANGE THE URL IN THE LINE BELOW
	var url = "../contact/optIn.asp";
	var params='email='+$F("email")+'&fname='+encodeURIComponent($F("fname"))+'&lname='+encodeURIComponent($F("lname"))+'&fnumber='+encodeURIComponent($F("fnumber"));
	new Ajax.Request(url, {onComplete:showResponse, onException:showException, onFailure:showException, asynchronous:true, method:"post", evalScripts:false, postBody:params});
	$("submit").hide();
	$("loading").show();

	function showResponse(req)
	{	
		if (req.responseText=="1" || req.responseText=="0")	//1. added to contacts	//2.already in contacts
		{
			$("loading").hide();
			document.getElementById("okmessage").innerHTML="Thank you for subscribing!!";
			$("okmessage").show();
			$("submit").show();
			$("fname").clear();
			$("lname").clear();
			$("email").clear();
			$("fnumber").clear();
		}
		if ( req.responseText=="0")	//1. added to contacts	//2.already in contacts
		{
					$("loading").hide();
					document.getElementById("okmessage").innerHTML="Already subscribed!!. Please try with another email address!";
					$("okmessage").show();
					$("submit").show();
					$("fname").clear();
					$("lname").clear();
					$("email").clear();
					$("fnumber").clear();
		}
		if (req.responseText=="error")	
		{
			alert("An error has occured. Please try again.");
			$("loading").hide();
			$("okmessage").hide();
			$("submit").show();
		}
	}
	function showException()
	{
		alert("Error occured while talking to the server. Please try again.");
		$("loading").hide();
		$("okmessage").hide();
		$("submit").show();
		$("fname").clear();
		$("lname").clear();
		$("email").clear();
		$("fnumber").clear();
	}
}



function signupwebinar()
{	
	//EMAIL VALIDATION
	var goodEmail 	= $F("email").match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.sex)|(\.biz)|(\.aero)|(\.coop)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);
	apos		= $F("email").indexOf("@");
	dotpos		= $F("email").lastIndexOf(".");
	lastpos		= $F("email").length-1;
	var badEmail 	= (apos<1 || dotpos-apos<2 || lastpos-dotpos<2);

	if ($F("fname")=="")
	{
		alert("Please enter your first name");
		$("fname").focus();
		return false;
	}
	else if ($F("lname")=="")
	{
		alert("Please enter your last name");
		$("lname").focus();
		return false;
	}
	else if (($F("email") == "") || (!goodEmail && badEmail))		
	{
		alert("Please enter a valid email");
		$("email").focus();
		return false;
	}else if ($F("fnumber")=="")
	{
		alert("Please enter your fleet count");
		$("fnumber").focus();
		return false;
	}
	//YOU MAY WANT TO CHANGE THE URL IN THE LINE BELOW
	var url = "../index/optIn.asp";
	var params='email='+$F("email")+'&fname='+encodeURIComponent($F("fname"))+'&lname='+encodeURIComponent($F("lname"))+'&fnumber='+encodeURIComponent($F("fnumber"));
	new Ajax.Request(url, {onComplete:showResponse, onException:showException, onFailure:showException, asynchronous:true, method:"post", evalScripts:false, postBody:params});
	$("submit").hide();
	$("loading").show();

	function showResponse(req)
	{	
		if (req.responseText=="1" || req.responseText=="0")	//1. added to contacts	//2.already in contacts
		{
			$("loading").hide();
			document.getElementById("okmessage").innerHTML="Thank you for subscribing!!";
			$("okmessage").show();
			$("submit").show();
			$("fname").clear();
			$("lname").clear();
			$("email").clear();
			$("fnumber").clear();
		}
		if ( req.responseText=="0")	//1. added to contacts	//2.already in contacts
		{
					$("loading").hide();
					document.getElementById("okmessage").innerHTML="Already subscribed!!. Please try with another email address!";
					$("okmessage").show();
					$("submit").show();
					$("fname").clear();
					$("lname").clear();
					$("email").clear();
					$("fnumber").clear();
		}
		if (req.responseText=="error")	
		{
			alert("An error has occured. Please try again.");
			$("loading").hide();
			$("okmessage").hide();
			$("submit").show();
		}
	}
	function showException()
	{
		alert("Error occured while talking to the server. Please try again.");
		$("loading").hide();
		$("okmessage").hide();
		$("submit").show();
		$("fname").clear();
		$("lname").clear();
		$("email").clear();
		$("fnumber").clear();
	}
}

