// JavaScript Document



function on_load()

{

	get_content().src = './thanks.php';

}



function get_content()

{

	return document.getElementById('content_pane');

}

function is_ie6()
{
	return (document.body.className == 'ie6');
}


function set_link_image(linkName, image)

{

	var imageTag = document.getElementById(linkName);

	imageTag.src = image;		

}



function aboutClick()

{

	get_content().src = './about.php';

}

function aboutHover()

{

   if(is_ie6()) set_link_image('aboutLinkImg', './about-red-fill.jpg');
   else set_link_image('aboutLinkImg', './about-red-fill.png');

   link_cursor();

}

function aboutOut()

{

    if(is_ie6()) set_link_image('aboutLinkImg', './about-black-out.jpg');
	else set_link_image('aboutLinkImg', './about-black-out.png');	

	normal_cursor();

}



function homeClick()

{

	get_content().src = './thanks.php';

}

function homeHover()

{

   if(is_ie6()) set_link_image('homeLinkImg', './home-red-fill.jpg');	
   else set_link_image('homeLinkImg', './home-red-fill.png');

   link_cursor();

}

function homeOut()

{

   if(is_ie6()) set_link_image('homeLinkImg', './home-black-out.jpg');
   else set_link_image('homeLinkImg', './home-black-out.png');

   normal_cursor();

}



function prodClick()

{

	get_content().src = './products.php';

}

function prodHover()

{
   if(is_ie6()) set_link_image('prodLinkImg', './prod-red-fill.jpg');
   else set_link_image('prodLinkImg', './prod-red-fill.png');

   link_cursor();

}

function prodOut()

{
   if(is_ie6()) set_link_image('prodLinkImg', './prod-black-out.jpg');
   else set_link_image('prodLinkImg', './prod-black-out.png');

   normal_cursor();

}



function artClick()

{

	get_content().src = './art-submit.php';

}

function artHover()

{
   if(is_ie6()) set_link_image('artLinkImg', './art-red-fill.jpg');
   else set_link_image('artLinkImg', './art-red-fill.png');

   link_cursor();

}

function artOut()

{
   if(is_ie6()) set_link_image('artLinkImg', './art-black-out.jpg');
   else set_link_image('artLinkImg', './art-black-out.png');

   normal_cursor();

}



function quoteClick()

{

	window.open('quotes.html', 'quotePage','height=550,width=600,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=no,status=yes');

}

function quoteHover()

{
   if(is_ie6()) set_link_image('quoteLinkImg', './quote-red-fill.jpg');
   else set_link_image('quoteLinkImg', './quote-red-fill.png');

   link_cursor();

}

function quoteOut()

{
   if(is_ie6()) set_link_image('quoteLinkImg', './quote-black-out.jpg');
   else set_link_image('quoteLinkImg', './quote-black-out.png');

   normal_cursor();

}



function orderClick()

{

   window.open('order.html', 'quotePage','height=550,width=600,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=no,status=yes');

}

function orderHover()

{
   if(is_ie6()) set_link_image('orderLinkImg', './order-red-fill.jpg');
   else set_link_image('orderLinkImg', './order-red-fill.png');

   link_cursor();

}

function orderOut()

{
   if(is_ie6()) set_link_image('orderLinkImg', './order-black-out.jpg');
   else set_link_image('orderLinkImg', './order-black-out.png');

   normal_cursor();

}



function contactClick()

{

   get_content().src = './contact.php';

}

function contactHover()

{
   if(is_ie6()) set_link_image('contactLinkImg', './contact-red-fill.jpg');
   else set_link_image('contactLinkImg', './contact-red-fill.png');

   link_cursor();

}

function contactOut()

{
   if(is_ie6()) set_link_image('contactLinkImg', './contact-black-out.jpg');
   else set_link_image('contactLinkImg', './contact-black-out.png');

   normal_cursor();

}



function link_cursor()

{

	document.body.style.cursor = 'pointer';	

}



function normal_cursor()

{

	document.body.style.cursor = 'default';

}





function validateQuote()

{	

	var allOk = true;

	var theForm = document.quoteForm;

	

	if(theForm.companyName.value == '')	{

		allOk = false;

		theForm.companyName.className = 'badtextfield';

	}

	else {

		theForm.companyName.className = 'textfield';

	}

	if(theForm.contactName.value == '')	{

		allOk = false;

		theForm.contactName.className = 'badtextfield';

	}

	else {

		theForm.contactName.className = 'textfield';

	}

	if(theForm.phoneNumber.value == '') {

		allOk = false;

		theForm.phoneNumber.className = 'badtextfield';

	}

	else {

		theForm.phoneNumber.className = 'textfield';

	}

	/*if(theForm.faxNumber.value == '') {

		allOk = false;

		theForm.faxNumber.className = 'badtextfield';

	}

	else {

		theForm.faxNumber.className = 'textfield';

	}

	if(theForm.emailAddress.value == '') {

		allOk = false;

		theForm.emailAddress.className = 'badtextfield';

	}

	else {
		if(!isEmail(theForm.emailAddress.value)){
			theForm.emailAddress.className = 'badtextfield';
			allOk = false;
			alert("Please enter a valid e-mail address");
		}
		else{
			theForm.emailAddress.className = 'textfield';
		}
	}*/

	if(theForm.numberOfParts.value == '') {

		allOk = false;

		theForm.numberOfParts.className = 'badtextfield';

	}

	else {

		theForm.numberOfParts.className = 'textfield';

	}

	if(theForm.quantity.value == '') {

		allOk = false;

		theForm.quantity.className = 'badtextfield';

	}

	else {

		theForm.quantity.className = 'textfield';

	}

	if(theForm.paperType.value == '') {

		allOk = false;

		theForm.paperType.className = 'badtextfield';

	}

	else {

		theForm.paperType.className = 'textfield';

	}

	if(theForm.emailArt.value == '') {

		allOk = false;

		theForm.emailArt.className = 'badtextfield';

	}

	else {

		theForm.emailArt.className = 'textfield';

	}

	if(!allOk)

    {

		scroll(0,0);

		document.getElementById('pageTitle').innerHTML = 'Details for Quote<br /> <span class="redtext">Please complete highlighted fields</span>';

		return false;

	}

	return allOk;

}



function validateOrder()

{

	var allOk = true;

	var theForm = document.orderForm;

	

	if((theForm.billTo1.value == '') ||

	   (theForm.billTo2.value == '') ||

	   (theForm.billTo3.value == '')) {

		allOk = false;

		theForm.billTo1.className = 'badtextfield';

		theForm.billTo2.className = 'badtextfield';

		theForm.billTo3.className = 'badtextfield';		

	}

	else {

		theForm.billTo1.className = 'textfield';

		theForm.billTo2.className = 'textfield';

		theForm.billTo3.className = 'textfield';				

	}

	if((theForm.shipTo1.value == '') ||

	   (theForm.shipTo2.value == '') ||

	   (theForm.shipTo3.value == '')) {

		allOk = false;

		theForm.shipTo1.className = 'badtextfield';

		theForm.shipTo2.className = 'badtextfield';

		theForm.shipTo3.className = 'badtextfield';

	}

	else {

		theForm.shipTo1.className = 'textfield';

		theForm.shipTo2.className = 'textfield';

		theForm.shipTo3.className = 'textfield';	

	}
	
	if(theForm.contact.value == '') { 

		allOk = false;

		theForm.contact.className = 'badtextfield';

	}

	else {

		theForm.contact.className = 'textField';

	}

	if(theForm.phoneNumber.value == '') { 

		allOk = false;

		theForm.phoneNumber.className = 'badtextfield';

	}

	else {

		theForm.phoneNumber.className = 'textField';

	}

	/*if(theForm.faxNumber.value == '') { 

		allOk = false;

		theForm.faxNumber.className = 'badtextfield';

	}

	else {

		theForm.faxNumber.className = 'textField';

	}

	if(theForm.emailAddress.value == '') { 

		allOk = false;

		theForm.emailAddress.className = 'badtextfield';

	}

	else {
		if(!isEmail(theForm.emailAddress.value)){
			theForm.emailAddress.className = 'badtextfield';
			allOk = false;
			alert("Please enter a valid e-mail address");
		}
		else{
			theForm.emailAddress.className = 'textfield';
		}
	}*/

	if(theForm.customerPO.value == '') { 

		allOk = false;

		theForm.customerPO.className = 'badtextfield';

	}

	else {

		theForm.customerPO.className = 'textField';

	}

	if(theForm.jobPO.value == '') { 

		allOk = false;

		theForm.jobPO.className = 'badtextfield';

	}

	else {

		theForm.jobPO.className = 'textField';

	}

	if(theForm.formName.value == '') { 

		allOk = false;

		theForm.formName.className = 'badtextfield';

	}

	else {

		theForm.formName.className = 'textField';

	}

	if(theForm.quantity.value == '') { 

		allOk = false;

		theForm.quantity.className = 'badtextfield';

	}

	else {

		theForm.quantity.className = 'textField';

	}

	if((theForm.size1.value == '') || (theForm.size2.value == '')) { 

		allOk = false;

		theForm.size1.className = 'badtextfield';

		theForm.size2.className = 'badtextfield';

	}

	else {

		theForm.size1.className = 'textfield';

		theForm.size2.className = 'textfield';

	}

	if(!allOk)

    {

		scroll(0,0);

		document.getElementById('pageTitle').innerHTML = 'Order Details<br /> <span class="redtext">Please complete highlighted fields</span>';

		return false;

	}

	return allOk;

}

function isEmail(string) {
   return (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1);
}
