// JavaScript Document

function alertProd() {
  var PROD = document.enquiryForm.prodName.value;
  var DESC = document.enquiryForm.prodDesc.value;
  alert(PROD);	
}

function setText() {
  var selectProd = cookieVal("SetTextProduct");
  var selectQuan = cookieVal("SetTextDescription");
  if (selectProd != "" || selectQuan != "") {
    document.enquiryForm.Product.value = selectProd;
    document.enquiryForm.r_Message.value = selectQuan;
  }
}


function constructorDetails(name,description) {
	this.name = name;
	this.description = description;
}

var constructors = new Array();

constructors[0] = new constructorDetails("Combi Colour Striper", "Please send me information on the Combi Colour Stripers.  Could you let me know costing for my quantity required and the lead times etc.....Thank You");

constructors[1] = new constructorDetails("<h2>The Incredibles</h2>", "<p><img src='http://www.dat1.co.uk/images/theincredibles.jpg'></p>");

constructors[2] = new constructorDetails("<h2>Shanghai Noon</h2>", "<p><img src='http://www.dat1.co.uk/images/shanghainoon.jpg'></p>");

constructors[3] = new constructorDetails("<h2>Chicken Little</h2>", "<p><img src='http://www.dat1.co.uk/images/chickenlittle.jpg'></p>");

constructors[4] = new constructorDetails("<h2>Monsters Inc.</h2>", "<p><img src='http://www.dat1.co.uk/images/monstorsinc.jpg'></p>");

constructors[5] = new constructorDetails("<h2>Kill Bill</h2>", "<p><img src='http://www.dat1.co.uk/images/killbill.jpg'></p>");

constructors[6] = new constructorDetails("<h2>Renault</h2>", "<p><img src='http://www.dat1.co.uk/images/renault.jpg'></p>");

constructors[7] = new constructorDetails("<h2>Renault</h2>", "<p><img src='http://www.dat1.co.uk/images/nationaltreasurepedometer.jpg'></p>");

constructors[8] = new constructorDetails("<h2>Racing Stripes</h2>", "<p><img src='http://www.dat1.co.uk/images/stripes.jpg'></p>");


function applyContent(Fill) { 
	if (Fill == "combi") {
	    var expireDate = new Date();
	    expireDate.setMinutes(expireDate.getMinutes()+1);
	    document.cookie = "SetTextProduct=" + constructors[0].name + ";expires=" + expireDate.toGMTString();
		document.cookie = "SetTextDescription=" + constructors[0].description+ ";expires=" + expireDate.toGMTString();
		window.location = "http://www.dat1.co.uk/order";
	}
	else if (Fill == "flash") {
	    var expireDate = new Date();
	    expireDate.setMinutes(expireDate.getMinutes()+1);
	    document.cookie = "SetTextProduct=" + constructors[0].name + ";expires=" + expireDate.toGMTString();
		document.cookie = "SetTextDescription=" + constructors[0].description+ ";expires=" + expireDate.toGMTString();
		window.location = "http://www.dat1.co.uk/index.php?page=Order";
	}
	else if (Fill == "incredibles") {
	  	document.getElementById('clients').innerHTML = constructors[1].name + constructors[1].description;
	}
	else if (Fill == "shanghai") {
	  	document.getElementById('clients').innerHTML = constructors[2].name + constructors[2].description;
	}
	else if (Fill == "chicken") {
	  	document.getElementById('clients').innerHTML = constructors[3].name + constructors[3].description;
	}
	else if (Fill == "monstors") {
	  	document.getElementById('clients').innerHTML = constructors[4].name + constructors[4].description;
	}
	else if (Fill == "killbill") {
	  	document.getElementById('clients').innerHTML = constructors[5].name + constructors[5].description;
	}
	else if (Fill == "renault") {
	  	document.getElementById('clients').innerHTML = constructors[6].name + constructors[6].description;
	}
	else if (Fill == "nationaltreasure") {
	  	document.getElementById('clients').innerHTML = constructors[7].name + constructors[7].description;
	}
	else if (Fill == "racingstripes") {
	  	document.getElementById('clients').innerHTML = constructors[8].name + constructors[8].description;
	}
}
	
function cookieVal(cookieName) {
  var thisCookie = document.cookie.split("; ");
  
  for (var i = 0; i < thisCookie.length; i++) {
	  if (thisCookie[i].split("=")[0] == cookieName) {
		  return thisCookie[i].split("=")[1];
	  }
  }
  return 0;
}

