//---------------------------------------------------------------------------------------------------------------------\\
//                                                 AJ Parkes - Motiv8 Website                                          \\
//                                          Developed and Maintained by E-volution                                     \\
//---------------------------------------------------------------------------------------------------------------------\\
//  All code, images and data collected remains the property of AJ Parkes & Co and may not be edited, re-distributed   \\
//            copied or sold. All work is subject to copyright and infringement may result in legal action.            \\
//---------------------------------------------------------------------------------------------------------------------\\
//          Phone: 07 3349 7224     ---     Mobile: 0401 499 477     ---     E-mail: admin@e-volution.com.au           \\
//---------------------------------------------------------------------------------------------------------------------\\
//                                      Designer: Brent Wilkinson     Date: Mar, 2008                                  \\
//                                         ----- Motiv8 Javascript Functions -----                                     \\
//---------------------------------------------------------------------------------------------------------------------\\

function ImgSwap(el,val)
{	
	if(event.type == 'mouseover')
	{	el.src = window.sht + '/img/index/se_' + val + '_hi.jpg';	}
	else
	{	el.src = window.sht + '/img/index/se_' + val + '.jpg';	}
}

function StartFlasher()
{
	if(window.flashing == "on")
	{
		document.getElementById("flasher").innerHTML	= "&lt;";
		window.flashing									= "2";
	}
	else if(window.flashing == "2")
	{
		document.getElementById("flasher").innerHTML	= "&lt;&lt;";
		window.flashing									= "3";
	}
	else if(window.flashing == "3")
	{
		document.getElementById("flasher").innerHTML	= "&lt;&lt;&lt;";
		window.flashing									= "off";
	}
	else
	{
		document.getElementById("flasher").innerHTML	= "&nbsp;";
		window.flashing									= "on";
	}
		
	setTimeout("StartFlasher();",500);
}

function IsNumeric(strString)
   //  check for valid numeric strings	
{
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) 
   {	return false;	}

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
		  strChar = strString.charAt(i);
		  if (strValidChars.indexOf(strChar) == -1)
			 {	blnResult = false;	}
      }
   return blnResult;
}

function roundNumber(rnum) {
	var rlength = 3; // The number of decimal places to round to
	if (rnum > 8191 && rnum < 10485) {
		rnum = rnum-5000;
		var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
		newnumber = newnumber+5000;
	} else {
		var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
	}
	return newnumber;
}

function calc_sqm()
{
	if(IsNumeric(document.getElementById('width').value) == false || IsNumeric(document.getElementById('height').value) == false || IsNumeric(document.getElementById('qty').value) == false)
	{	return true;	}
	else
	{	
		var fix	= roundNumber(((document.getElementById('width').value/1000) * (document.getElementById('height').value/1000)) * document.getElementById('qty').value);
		document.getElementById('sqm').value = fix;	
		if(fix > 2.0)
		{
			document.getElementById('timeh').innerHTML	= '<select id="time" name="time">'
														+ '<option value="2">Standard - 2 weeks</option>'
														+ '<option value="3">Extended - 4-6 weeks (10% discount)</option>'
														+ '</select>';
			document.getElementById('time').value		= '2';
		}
		else if(fix > 1.0)
		{
			document.getElementById('timeh').innerHTML	= '<select id="time" name="time">'
														+ '<option value="1">Express - 1 week (10% surcharge)</option>'
														+ '<option value="2">Standard - 2 weeks</option>'
														+ '<option value="3">Extended - 4-6 weeks (10% discount)</option>'
														+ '</select>';
			document.getElementById('time').value		= '2';
		}
		else
		{
			document.getElementById('timeh').innerHTML	= '<select id="time" name="time">'
														+ '<option value="0">Priority - 2 days (25% surcharge)</option>'
														+ '<option value="1">Express - 1 week (10% surcharge)</option>'
														+ '<option value="2">Standard - 2 weeks</option>'
														+ '</select>';
			document.getElementById('time').value		= '2';
		}
	}
}

function showImg(dir,sts,ref,des,brand,contact)
{
	var newWin 				= window.open('','sampleImg','status=1,width=675,height=607,toolbar=0,location=0,menubar=0,directories=0,resizeable=0,scrollbars=0'); 
	var nStatus 			= brand + ' - ' + sts;

	newWin.document.write	(
								'<html>'
							+	'<head>'
							+	'<title>' + brand + ' - Image Gallery</title>'
							+	'<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">'
							+	'<link rel="stylesheet" href="' + window.sht + '/css/' + brand + '.css">'
							+	'<script type="text/javascript" src="' + window.sht + '/js/' + brand + '.js"></script>'
							+	'</head>'
							+	'<body style="margin-top:7px;" onLoad="self.focus();">'
							+	'<table align="center" cellpadding="0" cellspacing="0">'
							+	'<tr><td colspan="3">'
							+	'<img src="' + dir + '" alt="' + nStatus + '" style="border: 2px solid #333333;">'
							+	'</td></tr>'
							+	'<tr><td style="font-weight: bold; color: #333333; text-align: left; padding-top:2px;">'
							+	sts
							+	'</td>'
							+	'<td style="font-size: 12px; color: #333333; text-align: center; padding-top:4px;">'
							+	'Ref #: ' + ref
							+	'</td>'
							+	'<td style="font-size: 12px; color: #999999; text-align: right; padding-top:4px;">'
							+	'<a id="prod_index_link" href="javascript: self.print();" title="Print Image">Print</a>'
							+	'&nbsp;&nbsp;||&nbsp;&nbsp;'
							+	'<a id="prod_index_link" href="javascript: self.close();" title="Close Image">Close</a>'
							+	'</td></tr>'
							+	'<tr><td colspan="3" style="padding-top:2px;">'
							+	'<div style="width:660px; height:56px; border:2px solid #333333; padding:3px 5px 2px 5px; font-size:12px; color:#333333;">'
							+	des.replace(/-weblink-/g,'"')
							+	'</div>'
							+	'</td></tr>'
							+	'<tr><td colspan="3" style="text-align:center; font-size:12px; color:#FFFFFF; padding-top:2px;">'
							+	'Call <strong>1800 777 125</strong> or '
							+	'<a id="prod_index_link" href="javascript: doContact(\'' + contact + '\');" title="Contact Us" style="font-weight:bold;">e-mail us</a> '
							+	'to enquire about this product....'
							+	'</td></tr>'
							+	'</table>'
							+	'</body>'
							+	'</html>'
							);
	
	newWin.document.close();
	newWin.status			= nStatus;
}

function doContact(contact)
{
	window.opener.location	= contact;
	self.close();
}

window.flashing			= "on";
window.defaultStatus	= 'Welcome to the Motiv8 online catalogue....';