function onTermChange(frm){var item=frm.get_amount;if(frm.get_ref_term.value==1){item.disabled=true;frm.get_amount.value='';}
else{item.disabled=false;}}
function onCompanyChange(frm){var item=frm.get_leasing_company_other;if(frm.get_leasing_company.value!='-- Other --'){item.readOnly=true;item.value='';}else{item.readOnly=false;}}
function confirm_del(){var reply=confirm("This will permanantly delete this record!");if(reply){return true;}
else{return false;}}
function confirm_del_listing(){var reply=confirm("Mark this listing as deleted?");if(reply){return true;}
else{return false;}}
function confirm_cancel(){var reply=confirm("Cancel this listing without winner selected?");if(reply){return true;}
else{return false;}}
function inputForgot(frm){var prefix0='get_';var input_array=new Array('username');var error_array=new Array('Username');for(var i=0;i<input_array.length;i++){var source=prefix0+input_array[i];if(frm.elements[source].value.length==0){alert(error_array[i].substr(0,1).toUpperCase()+error_array[i].substr(1)+' can not be empty ');frm.elements[source].focus();return false;}}}
function inputContest(frm){var prefix0='get_';var input_array=new Array('firstname','lastname','email');var error_array=new Array('First Name','Last name','Email');for(var i=0;i<input_array.length;i++){var source=prefix0+input_array[i];if(frm.elements[source].value.length==0){alert(error_array[i].substr(0,1).toUpperCase()+error_array[i].substr(1)+' can not be empty ');frm.elements[source].focus();return false;}}}
function inputPlaceMsg(frm){var prefix0='get_';var input_array=new Array('text');var error_array=new Array('Message');for(var i=0;i<input_array.length;i++){var source=prefix0+input_array[i];if(frm.elements[source].value.length==0){alert(error_array[i].substr(0,1).toUpperCase()+error_array[i].substr(1)+' can not be empty ');frm.elements[source].focus();return false;}}}
function inputTellAFriendForm(frm){var prefix0='get_';var input_array=new Array('email','text');var error_array=new Array('E-Mail','Message');for(var i=0;i<input_array.length;i++){var source=prefix0+input_array[i];if(frm.elements[source].value.length==0){alert(error_array[i].substr(0,1).toUpperCase()+error_array[i].substr(1)+' can not be empty ');frm.elements[source].focus();return false;}}}
function inputCustomInfo1(frm){var prefix0='get_';var input_array=new Array('firstname','lastname','username','email');var error_array=new Array('First Name','Last Name','UserID','E-Mail Address');for(var i=0;i<input_array.length;i++){var source=prefix0+input_array[i];if(frm.elements[source].value.length==0){alert(error_array[i].substr(0,1).toUpperCase()+error_array[i].substr(1)+' can not be empty ');frm.elements[source].focus();return false;}}
var input_array=new Array('address','city','ref_state','postcode','ref_country','phone');var error_array=new Array('Street Address','City','Province / State','Postal Code','Country','Phone');for(var i=0;i<input_array.length;i++){var source=prefix0+input_array[i];if(frm.elements[source].value.length==0){alert(error_array[i].substr(0,1).toUpperCase()+error_array[i].substr(1)+' can not be empty ');frm.elements[source].focus();return false;}}
if(!frm.get_phone.value.match(/^\d\d\d-\d\d\d-\d\d\d\d$/)){alert('Phone is invalid');frm.get_phone.focus();return false;}
if(frm.get_mobile_phone.value!=''){if(!frm.get_mobile_phone.value.match(/^\d\d\d-\d\d\d-\d\d\d\d$/)){alert('Mobile Phone is invalid');frm.get_mobile_phone.focus();return false;}}
if(frm.get_fax.value!=''){if(!frm.get_fax.value.match(/^\d\d\d-\d\d\d-\d\d\d\d$/)){alert('Fax is invalid');frm.get_fax.focus();return false;}}
if(!frm.get_terms.checked){alert('Please read Terms and Conditions before proceed');frm.get_terms.focus();return false;}
return true;}
function inputCustomInfo2(frm){var prefix0='get_';var input_array=new Array('firstname','lastname','email','address','city','ref_state','ref_country','postcode','phone');var error_array=new Array('First Name','Last Name','E-Mail Address','Street Address','City','Province / State','Country','Postal Code','Phone');for(var i=0;i<input_array.length;i++){var source=prefix0+input_array[i];if(frm.elements[source].value.length==0){alert(error_array[i].substr(0,1).toUpperCase()+error_array[i].substr(1)+' can not be empty ');frm.elements[source].focus();return false;}}
if(!frm.get_phone.value.match(/^\d\d\d-\d\d\d-\d\d\d\d$/)){alert('Phone is invalid');frm.get_phone.focus();return false;}
if(frm.get_mobile_phone.value!=''){if(!frm.get_mobile_phone.value.match(/^\d\d\d-\d\d\d-\d\d\d\d$/)){alert('Mobile Phone is invalid');frm.get_mobile_phone.focus();return false;}}
if(frm.get_fax.value!=''){if(!frm.get_fax.value.match(/^\d\d\d-\d\d\d-\d\d\d\d$/)){alert('Fax is invalid');frm.get_fax.focus();return false;}}
return true;}
function onListingAdd(frm){var prefix0='get_';var input_array=new Array('year','ref_make','ref_model','ref_vehicle','ref_color_exterior','ref_color_interior','engine','ref_transmission','lease_mileage_actual','leasing_company','lease_amount','purchase_option','lease_mileage_allow','lease_mileage_charge','lease_original_term','description','city');var error_array=new Array('Year','Make','Model','Trim','Exterior Color','Interior Color','Engine Cylinder','Transmission','Current Kilometers','Leasing Company','Monthly Payment','Purchase Option','Total Kilometre Allowance','Excess Kilometre Charge','Original Lease Term','Description','City');for(var i=0;i<input_array.length;i++){var source=prefix0+input_array[i];if(frm.elements[source].value.length<1||frm.elements[source].value==0){alert(error_array[i].substr(0,1).toUpperCase()+error_array[i].substr(1)+' can not be empty ');frm.elements[source].focus();return false;}}
active_features=str_active_features();if(!active_features){alert('Please fill Features&Options before proceed');open_features('',650,620);return false;}
if(frm.elements['get_postcode'].value.length>7){alert('Postcode should be less than 7 chars');frm.elements['get_postcode'].focus();return false;}
if(!frm.get_agreement.checked){alert('Please read LISTING AGREEMENT before proceed');frm.get_agreement.focus();return false;}
return true;}
function onListingAddDealer(frm){var prefix0='get_';var input_array=new Array('year','ref_make','ref_model','ref_vehicle','ref_color_exterior','ref_color_interior','engine','ref_transmission','lease_mileage_actual','leasing_company','lease_amount','purchase_option','lease_mileage_allow','lease_mileage_charge','lease_original_term','description','city');var error_array=new Array('Year','Make','Model','Trim','Exterior Color','Interior Color','Engine Cylinder','Transmission','Current Kilometers','Leasing Company','Monthly Payment','Purchase Option','Total Kilometre Allowance','Excess Kilometre Charge','Lease Term','Description','City');for(var i=0;i<input_array.length;i++){var source=prefix0+input_array[i];if(frm.elements[source].value.length<1||frm.elements[source].value==0){alert(error_array[i].substr(0,1).toUpperCase()+error_array[i].substr(1)+' can not be empty ');frm.elements[source].focus();return false;}}
if(frm.elements['get_description'].value.length>500){alert('Description should be less than 500 chars');frm.elements['get_description'].focus();return false;}
if(frm.elements['get_postcode'].value.length>7){alert('Postcode should be less than 7 chars');frm.elements['get_postcode'].focus();return false;}
active_features=str_active_features();if(!active_features){alert('Please fill Features&Options before proceed');open_features('',650,620);return false;}
return true;}
function onListingMod(frm){var prefix0='get_';var input_array=new Array('ref_make','ref_model','ref_vehicle','lease_mileage_actual','description');var error_array=new Array('Make','Model','Trim','Odometer','Description');for(var i=0;i<input_array.length;i++){var source=prefix0+input_array[i];if(frm.elements[source].value.length<1||frm.elements[source].value==0){alert(error_array[i].substr(0,1).toUpperCase()+error_array[i].substr(1)+' can not be empty ');frm.elements[source].focus();return false;}}
if(frm.elements['get_description'].value.length>500){alert('Description should be less than 500 chars');frm.elements['get_description'].focus();return false;}
if(frm.elements['get_postcode'].value.length>7){alert('Postcode should be less than 7 chars');frm.elements['get_postcode'].focus();return false;}
var input_array=new Array('lease_amount','lease_original_term','lease_mileage_allow','lease_mileage_charge');var error_array=new Array('Current Lease Payment','Original Lease Term','Total Kilometers Allowed ','Excess Kilometers Charge');for(var i=0;i<input_array.length;i++){var source=prefix0+input_array[i];if(frm.elements[source].value.length<1||frm.elements[source].value==0){alert(error_array[i].substr(0,1).toUpperCase()+error_array[i].substr(1)+' can not be empty ');frm.elements[source].focus();return false;}}
return true;}
function onListingAddSell(frm){var prefix0='get_';var input_array=new Array('year','ref_make','ref_model','ref_vehicle','ref_color_exterior','ref_color_interior','engine','ref_transmission','mileage','ask_price','description','city');var error_array=new Array('Year','Make','Model','Trim','Exterior Color','Interior Color','Engine Cylinder','Transmission','Current Kilometers','Asking Price','Description','City');for(var i=0;i<input_array.length;i++){var source=prefix0+input_array[i];if(frm.elements[source].value.length<1||frm.elements[source].value==0){alert(error_array[i].substr(0,1).toUpperCase()+error_array[i].substr(1)+' can not be empty ');frm.elements[source].focus();return false;}}
if(frm.elements['get_postcode'].value.length>7){alert('Postcode should be less than 7 chars');frm.elements['get_postcode'].focus();return false;}
active_features=str_active_features();if(!active_features){alert('Please fill Features&Options before proceed');open_features('',650,620);return false;}
if(!frm.get_agreement.checked){alert('Please read LISTING AGREEMENT before proceed');frm.get_agreement.focus();return false;}
return true;}
function onListingModSell(frm){var prefix0='get_';var input_array=new Array('ref_make','ref_model','ref_vehicle','mileage','description');var error_array=new Array('Make','Model','Trim','Odometer','Description');for(var i=0;i<input_array.length;i++){var source=prefix0+input_array[i];if(frm.elements[source].value.length<1||frm.elements[source].value==0){alert(error_array[i].substr(0,1).toUpperCase()+error_array[i].substr(1)+' can not be empty ');frm.elements[source].focus();return false;}}
if(frm.elements['get_description'].value.length>500){alert('Description should be less than 500 chars');frm.elements['get_description'].focus();return false;}
if(frm.elements['get_postcode'].value.length>7){alert('Postcode should be less than 7 chars');frm.elements['get_postcode'].focus();return false;}
var input_array=new Array('ask_price');var error_array=new Array('Asking Price');for(var i=0;i<input_array.length;i++){var source=prefix0+input_array[i];if(frm.elements[source].value.length<1||frm.elements[source].value==0){alert(error_array[i].substr(0,1).toUpperCase()+error_array[i].substr(1)+' can not be empty ');frm.elements[source].focus();return false;}}
return true;}
function inputPswd(frm){if(frm.get_username.value.length==0){alert('Your Username/Email can not be empty ');frm.get_username.focus();return false;}}
function viewform(m,w,h){var scroll='yes';var settings;var LeftPosition;var TopPosition;var win;LeftPosition=(screen.width)?(screen.width-w)/2:0;TopPosition=(screen.height)?(screen.height-h)/2:0;settings='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll;settings=settings+',resizable=no,maximize=no,status=no,toolbar=no,directories=no,menubar=no,location=no';win=window.open(m,'pre',settings);win.name='name';win.focus();}
function viewform_ns(m,w,h){var scroll='no';var settings;var LeftPosition;var TopPosition;var win;var k;if(w>600){k=w/600;w=w/k;h=h/k;}
LeftPosition=(screen.width)?(screen.width-w)/2:0;TopPosition=(screen.height)?(screen.height-h)/2:0;settings='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll;settings=settings+',resizable=no,maximize=no,status=no,toolbar=no,directories=no,menubar=no,location=no';win=window.open(m,'pre',settings);win.name='name';win.focus();}
function findAPI(win){if(win.API!=null){return win.API;}
return null;}
var marked_row=new Array;function setPointer(theRow,theRowNum,theAction,theDefaultColor,thePointerColor,theMarkColor)
{var theCells=null;if((thePointerColor==''&&theMarkColor=='')
||typeof(theRow.style)=='undefined'){return false;}
if(typeof(document.getElementsByTagName)!='undefined'){theCells=theRow.getElementsByTagName('td');}
else if(typeof(theRow.cells)!='undefined'){theCells=theRow.cells;}
else{return false;}
var rowCellsCnt=theCells.length;var domDetect=null;var currentColor=null;var newColor=null;if(typeof(window.opera)=='undefined'
&&typeof(theCells[0].getAttribute)!='undefined'){currentColor=theCells[0].getAttribute('bgcolor');domDetect=true;}
else{currentColor=theCells[0].style.backgroundColor;domDetect=false;}
if(currentColor.indexOf("rgb")>=0)
{var rgbStr=currentColor.slice(currentColor.indexOf('(')+1,currentColor.indexOf(')'));var rgbValues=rgbStr.split(",");currentColor="#";var hexChars="0123456789ABCDEF";for(var i=0;i<3;i++)
{var v=rgbValues[i].valueOf();currentColor+=hexChars.charAt(v/16)+hexChars.charAt(v%16);}}
if(currentColor==''
||currentColor.toLowerCase()==theDefaultColor.toLowerCase()){if(theAction=='over'&&thePointerColor!=''){newColor=thePointerColor;}
else if(theAction=='click'&&theMarkColor!=''){newColor=theMarkColor;marked_row[theRowNum]=true;}}
else if(currentColor.toLowerCase()==thePointerColor.toLowerCase()
&&(typeof(marked_row[theRowNum])=='undefined'||!marked_row[theRowNum])){if(theAction=='out'){newColor=theDefaultColor;}
else if(theAction=='click'&&theMarkColor!=''){newColor=theMarkColor;marked_row[theRowNum]=true;}}
else if(currentColor.toLowerCase()==theMarkColor.toLowerCase()){if(theAction=='click'){newColor=(thePointerColor!='')
?thePointerColor
:theDefaultColor;marked_row[theRowNum]=(typeof(marked_row[theRowNum])=='undefined'||!marked_row[theRowNum])
?true
:null;}}
if(newColor){var c=null;if(domDetect){for(c=0;c<rowCellsCnt;c++){theCells[c].setAttribute('bgcolor',newColor,0);}}
else{for(c=0;c<rowCellsCnt;c++){theCells[c].style.backgroundColor=newColor;}}}
return true;}
function viewform_print(m){var scroll='yes';var settings;var LeftPosition;var TopPosition;var win;settings='scrollbars='+scroll;settings=settings+',resizable=no,maximize=yes,status=no,toolbar=no,directories=no,menubar=no,location=no';win=window.open(m,'pre',settings);win.name='name';win.focus();}
