/*
Highlight Image Script II- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/
function borderit(which,color){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
which.style.borderColor=color
}
}

function getQueryString(strParaName) {
		var strQS=location.search.substring(1,location.search.length);
		var strArgs = "";
		var strName = "";
		var strValue = "";
		var strTemp = "";

		if (strQS!="") {
			strArgs = strQS.split('&');

			for (var i=0;i<strArgs.length;i++)
			{
				var pair = strArgs[i].split('=');
				
				// Fix broken unescaping
				strTemp = unescape(pair[0]).split('+');
				strName = strTemp.join(' ');
				
				strTemp = unescape(pair[1]).split('+');
				strValue = strTemp.join(' ');
				
				if (strParaName==strName) return strValue;
			}

		}
		return -1;
	}
function composeASF(strFilePath) {
	var strCode = "<OBJECT id='mediaPlayer' width='372' height='325' " + 
		" classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' " + 
		" codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'" + 
		" standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>" + 
		" <param name='fileName' value='" + strFilePath + "'>" + 
		" <param name='animationatStart' value='true'>" + 
		" <param name='transparentatStart' value='true'>" + 
		" <param name='autoStart' value='true'>" + 
		" <param name='showControls' value='true'>" + 
		" <param name='loop' value='false'>" + 
		" <EMBED type='application/x-mplayer2'" + 
		" pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'" + 
		" id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1' " + 
		" bgcolor='darkblue' showcontrols='true' showtracker='-1' " + 
		" showdisplay='0' showstatusbar='-1' videoborder3d='-1' width='372'= height='325'" + 
		" src='" + strFilePath + "' autostart='true' designtimesp='5311' loop='true'>" + 
		" </EMBED>" + 
		" </OBJECT>";
	return strCode;
}
function composeMPG(intWidth, intHeight, strFilePath) {
	return '<EMBED SRC="' +strFilePath+ '" WIDTH='+intWidth+' HEIGHT='+intHeight+'>';
}
function composeSWF(intWidth, intHeight, strFilePath) {
	var strCode = "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'" + 
		" codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'" + 
		" width='" +intWidth+ "' height='" +intHeight+ "'>" + 
		" <param name='movie' value='" +strFilePath+ "'>" + 
		" <param name='quality' value='high'>" + 
		" <param name='bgcolor' value='#FFFFFF'>" + 
		" <param name='loop' value='true'>" + 
		" <EMBED src='" +strFilePath+ "' quality='high' bgcolor='#FFFFFF' width='" +intWidth+ "'" + 
		" height='" +intHeight+ "' loop='true' type='application/x-shockwave-flash'" + 
		" pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'>" + 
		" </EMBED>" + 
		" </OBJECT>";

	return strCode;
}

function composeMOV(intWidth, intHeight, strFilePath) {
	var strCode = "<OBJECT classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' width='" +intWidth+ "'" +
		"height='" +intHeight+ "' codebase='http://www.apple.com/qtactivex/qtplugin.cab'>" +
		"<param name='src' value='" +strFilePath+ "'>" +
		"<param name='autoplay' value='true'>" +
		"<param name='controller' value='true'>" +
		"<param name='loop' value='true'>" +
		"<EMBED src='" +strFilePath+ "' width='" +intWidth+ "' height='" +intHeight+ "' autoplay='true' " +
		"controller='true' loop='true' pluginspage='http://www.apple.com/quicktime/download/'>" +
		"</EMBED>" +
		"</OBJECT>";

	return strCode;
}
//-------------------------------------------------------------------------------
// Mouseover function
//-------------------------------------------------------------------------------
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function getVote() {
form = document.pollForm;
for (i=0; i < form.vote.length; i++) {
if (form.vote[i].checked) {
form.vote[i].checked = null;
return form.vote[i].value;
}
}
return false;
}
//-------------------------------------------------------------------------------
// End of Mouseover function
//-------------------------------------------------------------------------------

function countDesc(check)
{
  var charcount = 0;
  var charcount = thisform.description.value.length;
  thisform.char_count1.value = charcount;
}

function selectlistindex(check)
{
   var checknull=1;
   for(i=0;i<check.options.length;i++){
     if (check.options[i].selected){
	    checknull=0;
        idx=i;
		break;
     }
   }
   if (checknull!= 0)
	  return 0;
   else
     return idx;
}
function listcheck(check,err_msg){
   var checknull=0;
   for(i=0;i<check.options.length;i++){
     if (check.options[i].selected){
	   if( i == 0 ){
	      checknull=1;
	      break;
	   }
	 }
   }
   if (checknull==1){
      alert(err_msg);
	  check.focus();
	  return false;
   }
}
function ltnum(check,int_no,err_msg){
   str=new String(check.value)
   if(str.length < int_no ){
      alert(err_msg)
	  check.focus();
	  return false;
   }
}


function gtnum(check,int_no,err_msg){
   str=new String(check.value)
   if(str.length > int_no ){
      alert(err_msg)
	  check.focus();
	  return false;
   }
}

function validNum(check, err_msg){
   str=new String(check.value)
   if(isNaN(str) == true ){
      alert(err_msg)
	  check.focus();
	  return false;
   }
   if(check.value<0) {
   	alert(err_msg)
   	check.focus();
   	return false;
   }
 }

function emptyfield(check,err_msg){
   if ((check.value == "") || (check.value.charAt(0) == " ")){
      alert(err_msg + "\n");
	  check.focus();
	  return false;
   }
}

function checkEmail(check){
   email = new String(check.value);
   errmsg="Invalid Email Address";
     if (email.indexOf("@") == -1){
	    alert(errmsg);
		check.focus();
		return false;
	 }
	 else
	 {
	   idx1=email.indexOf("@");
	 }
	 if(email.indexOf(".") == -1){
	    alert(errmsg);
		check.focus();
		return false;
	 }
	 else{
	    idx2=email.indexOf(".");
	 }
	 str1=email.substring(0,idx1);
	 if(str1.length < 2){
	    alert(errmsg);
		check.focus();
		return false;
	 }
	 str2=email.substring(idx1,idx2);
	 if(str2.length < 2){
	    alert(errmsg);
		check.focus();
		return false;
	 }
	 str3=email.substring(idx2,email.length-1);
	 if(str3.length < 2){
		alert(errmsg);
		check.focus();
		return false;
	 }
}

function checkBox(check,err_msg){
   var counter=0;
   for(var i=0;i<check.length;i++)
   {
     if(check[i].checked)
	 {
	   counter=counter+1;
	 }
   }
   if(counter < 1 )
   {
     alert(err_msg);
	 check[0].focus();
	 return false;
   }
}

function rbcheck(check,err_msg){
   for (var i=0;i<check.length;i++){
  	if(check[i].checked){
	     value=check[i].value
	     break;
	}
   }
   if(value == null){
   	alert(err_msg);
	check[0].focus();
	return false;
   }
}

function LZ(x) {return(x<0||x>9?"":"0")+x}

function checkexpiredate(d,e) { // d is text value
	//d1=parseInt(d.substring(4,8)+d.substring(2,4)+d.substring(0,2))+0;
	//e1=parseInt(e.substring(4,8)+e.substring(2,4)+e.substring(0,2))+0;
	d1 = parseInt(d)+0; //yyyymmdd
	e1 = parseInt(e)+0; //yyyymmdd
 	if (d1<e1) 
		return false;

	return true;
}
function ValidateDate(dDay, dMonth, dYear) {
	
	var d="312831303130313130313031";
	var yr;
	var sDate = parseInt(dDay.length + dMonth.length + dYear.length);
	/* For invalid dates, return false */
	if (sDate.length>0 && sDate.length<8) return false;
	
	// Expected inDate format: ddmmyyyy
	//dd = sDate.substring(0,2);
	//mm = sDate.substring(2,4);
	dd = LZ(dDay);
	mm =LZ(dMonth);
	yy = dYear;

	/* Now, convert the string yr1 into a numeric and test for leap year.
	If it is, change the end of month day string for Feb to 29  */		
	
	var isLeap = false;
	yy=yy*1;
	if (yy%400==0) isLeap = true
	else if (yy%100==0) isLeap = false
	else if (yy%4==0) isLeap = true;
	if (isLeap) d=d.substring(0,2)+"29" + d.substring(4,d.length);
	
	/* Pick the end of month day from the d string for this month. */

	pos=(mm*2)-2;
	ld=d.substring(pos,pos+2)+0;
	if (dd<1||dd>ld)
		return false;
	else if (mm<1||mm>12)
		return false;
	else if (yy<1870||yy>2038)
		return false;

	return true;		

}

function openWindow(url,toolbar ,x ,y) {
	subWindow=open(url, "newwin", "status=yes, resizable=yes, toolbar="+toolbar+", scrollbars=yes, width="+x+", height="+y+"");
	if(subWindow.opener==null) subWindow.opener=self;
}

function openFullscreen(frmurl, scrollbar, wd, hg) {
//newwindow=window.open('fullpage.html','name','resizable=no, width=996,height=710,left=0,top=0 toolbar=no,location=no,status=no,menubar=no');
	if (wd==0) {
	var wd=screen.width-5;
	}
	if (hg==0)
	{
	var hg=screen.height-75;
	}
	winame='maginfo';
	features='scrollbars='+scrollbar+',width='+ wd +',height='+ hg +',left=0,screenX=0,top=0,screenY=0,status=0';
	var nW = window.open("","_blank",features);
	nW.location.href = 	frmurl ; 
	nW = null; 
}

function catenquiry_check(frm) {
	if(emptyfield(frm.name1, "Please enter Name!")==false) {
	 	frm.name1.focus();
		return;
	}
	if(emptyfield(frm.email, "Please enter Email Address!")==false) {
	 	frm.email.focus();
		return;
	}
	if(checkEmail(frm.email, "Please enter a valid Email Address!")==false) {
	 	frm.email.focus();
	   	return;
	}
	if(emptyfield(frm.contact, "Please enter Contact!")==false) {
	 	frm.contact.focus();
		return;
	}
	frm.submit();
}
function bookaservice_check(frm) {
	if((frm.booking_day.value=="") || (frm.booking_month.value=="") || (frm.booking_year.value=="")) {
		alert("Please select Booking Date")
		frm.booking_day.focus();
		return;
	}
	if (ValidateDate(frm.booking_day.value,frm.booking_month.value,frm.booking_year.value) == 0)
	{
		alert("Invalid Booking Date!");
		frm.booking_day.focus();
		return;
	}
	if (!checkexpiredate(frm.booking_year.value+LZ(frm.booking_month.value)+LZ(frm.booking_day.value),frm.odate_year.value+LZ(frm.odate_month.value)+LZ(frm.odate_day.value))) 
			{
				alert("Booking Date must be at least 2 days of advanced notice.");
				frm.booking_day.focus();
				return;
			}
	if(emptyfield(frm.regno, "Please enter Motorcycle Registration No!")==false) {
	 	frm.regno.focus();
		return;
	}
	if(emptyfield(frm.model, "Please enter Model!")==false) {
	 	frm.model.focus();
		return;
	}
	if(emptyfield(frm.owner_name, "Please enter Owner Title/Name!")==false) {
	 	frm.owner_name.focus();
		return;
	}
	if(emptyfield(frm.owner_contact, "Please enter Contact!")==false) {
	 	frm.owner_contact.focus();
		return;
	}
	if(emptyfield(frm.owner_email, "Please enter Email!")==false) {
	 	frm.owner_email.focus();
		return;
	}
	if(checkEmail(frm.owner_email, "Please enter a valid Email!")==false) {
	 	frm.owner_email.focus();
	   	return;
	}
	frm.submit();
}
function partsenquiry_check(frm) {
	if(emptyfield(frm.customer_name, "Please enter Customer Name!")==false) {
	 	frm.customer_name.focus();
		return;
	}
	if(emptyfield(frm.customer_email, "Please enter Email Address!")==false) {
	 	frm.customer_email.focus();
		return;
	}
	if(checkEmail(frm.customer_email, "Please enter a valid Email Address!")==false) {
	 	frm.customer_email.focus();
	   	return;
	}
	if(emptyfield(frm.customer_contact, "Please enter Contact!")==false) {
	 	frm.customer_contact.focus();
		return;
	}
	if(emptyfield(frm.model, "Please enter Models & Tyre!")==false) {
	 	frm.model.focus();
		return;
	}
	frm.submit();
}
function registration_check(frm) {
	if(emptyfield(frm.vehicle_model, "Please enter Vehicle Model!")==false) {
	 	frm.vehicle_model.focus();
		return;
	}
	if(emptyfield(frm.vehicle_regn_no, "Please enter Vehicle Regn No.!")==false) {
	 	frm.vehicle_regn_no.focus();
		return;
	}
	if((frm.vehicle_reg_day.value=="") || (frm.vehicle_reg_month.value=="") || (frm.vehicle_reg_year.value=="")) {
		alert("Please select Vehicle Reg Date!")
		frm.vehicle_reg_day.focus();
		return;
	}
	if (ValidateDate(frm.vehicle_reg_day.value, frm.vehicle_reg_month.value, frm.vehicle_reg_year.value)==false)
	{
		alert("Invalid Vehicle Reg Date!");
		frm.vehicle_reg_day.focus();
		return;
	}
	if(emptyfield(frm.manufactured_year, "Please enter Year of Manufacture!")==false) {
	 	frm.manufactured_year.focus();
		return;
	}
	if(isNaN(frm.manufactured_year.value) == true ) {
		alert("Year of Manufacture must be numeric!");
		frm.manufactured_year.focus();
		return;
	}
	if(emptyfield(frm.colour, "Please enter Colour!")==false) {
	 	frm.colour.focus();
		return;
	}
	if(emptyfield(frm.engine_no, "Please enter Engine No.!")==false) {
	 	frm.engine_no.focus();
		return;
	}
	if(emptyfield(frm.framechassis_no, "Please enter Frame / Chassis No.!")==false) {
	 	frm.framechassis_no.focus();
		return;
	}
	if(emptyfield(frm.ownername, "Please enter Name!")==false) {
	 	frm.ownername.focus();
		return;
	}
	if(emptyfield(frm.address, "Please enter Address!")==false) {
	 	frm.address.focus();
		return;
	}
	if(emptyfield(frm.postal_code, "Please enter Postal code!")==false) {
	 	frm.postal_code.focus();
		return;
	}
	if(emptyfield(frm.email_address, "Please enter Email!")==false) {
		frm.email_address.focus();
		return;
	}
	if(checkEmail(frm.email_address, "Please enter a valid Email!")==false) {
	 	frm.email_address.focus();
	   	return;
	}
	if(emptyfield(frm.tel_no, "Please enter Tel. No.!")==false) {
		frm.tel_no.focus();
		return;
	}
	if(emptyfield(frm.dealer_name, "Please enter Dealer Name!")==false) {
		frm.dealer_name.focus();
		return;
	}
	frm.submit();
}

function poll_check() {
	var okFlag = true;
	var frm=document.pollForm;

	if(checkBox(frm.vote,"Please select POLL at least one")==false) {
		okFlag = false;
	   	return false;
	}
	if (okFlag == true) {
		frm.submit();
	}
}
function gotonews(u)
{
document.getElementById('datamain').setAttribute('src','news.asp#'+u);
window.location.href="news.asp#"+u;
}

function openFullscreen(frmurl, scrollbar, wd, hg) {
//newwindow=window.open('fullpage.html','name','resizable=no, width=996,height=710,left=0,top=0 toolbar=no,location=no,status=no,menubar=no');
	if (wd==0) {
	var wd=screen.width-5;
	}
	if (hg==0) {
	var hg=screen.height-55;
	}
	winame='maginfo';
	features='scrollbars='+scrollbar+',width='+ wd +',height='+ hg +',left=10,screenX=0,top=0,screenY=0,status=0';
	window.open(frmurl,winame,features);
}



