// JavaScript Document


//// START DW FUNCTIONS

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_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_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];}
}

//// END DW FUNCTIONS



/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  Copyright 2003 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/
///// ************

var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here
var cdate= dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
function goforit(){
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}

///// ************

///////////// code for time

function openwin(theURL,winName,features,w,h)
{
	var subwin = window.open(theURL,winName,features);
	var x,y;	
	x = (Number(screen.width) - w) / 2;
	y = 125;
	subwin.moveTo(x,y);
	subwin.focus();
}


function set_same(d){

	if(d.same.checked == true){
			d.sp_first_name.value	= d.bl_first_name.value;
			d.sp_last_name.value	= d.bl_last_name.value;
			d.sp_company_name.value	= d.bl_company_name.value;
			d.sp_address1.value 	= d.bl_address1.value;
			d.sp_address2.value 	= d.bl_address2.value;
			//d.sp_suburb.value 		= d.bl_suburb.value;
			d.sp_post_code.value 	= d.bl_post_code.value;
			d.sp_city.value 		= d.bl_city.value;
			d.sp_state.value 		= d.bl_state.value;
			
			var ct 					= d.bl_country.selectedIndex;
			
			d.sp_country.options[ct].selected = true;
			d.sp_phone.value 		= d.bl_phone.value;
			d.sp_mobile.value 		= d.bl_mobile.value;
			d.sp_fax.value 			= d.bl_fax.value;
			d.sp_email.value 		= d.bl_email.value;
			//alert(d.bl_country.selectedIndex);
			//alert(d.sp_country.selectedIndex);
		}
	else{
			d.sp_first_name.value	= "";
			d.sp_last_name.value	= "";
			d.sp_company_name.value	= "";
			d.sp_address1.value 	= "";
			d.sp_address2.value 	= "";
			//d.sp_suburb.value 		= "";
			d.sp_post_code.value 	= "";
			d.sp_city.value 		= "";
			d.sp_state.value 		= "";
			d.sp_country.options[0].selected = true;
			d.sp_phone.value 		= "";
			d.sp_mobile.value 		= "";
			d.sp_fax.value 			= "";
			d.sp_email.value 		= "";
		
		}

}

function fetch_models(make_id, div)
{
	$(div).innerHTML = '<img src="images/loading.gif" align="absmiddle" /> &nbsp;loading, please wait ...';
	var url = 'ajax.php';
	var params = 'pid=1&make_id='+make_id+'&rnd='+Math.random();
	var myAjax = new Ajax.Updater(div,url, {method: 'get', parameters: params});
}
