// JavaScript Document /* FORM VALIDATION FUNCTION */ function formValidate(frm) { if(frm.stock_no.value=='') { alert("Please Enter Reference No"); frm.stock_no.focus(); return false; } else if(frm.fob_price.value=='') { alert("Please Enter FOB Price (AED)"); frm.fob_price.focus(); return false; } else if(frm.make_id.value=='') { alert("Please Select Make"); frm.make_id.focus(); return false; } else if(frm.model_id.value=='') { alert("Please Select Model"); frm.model_id.focus(); return false; } else if(frm.bodytype_id.value=='') { alert("Please Select Body Type"); frm.bodytype_id.focus(); return false; } else if(frm.condition.value=='') { alert("Please Enter Condition"); frm.condition.focus(); return false; } else if(frm.chassis.value=='') { alert("Please Enter Chassis"); frm.chassis.focus(); return false; } else if(frm.handle.value=='') { alert("Please Select Handle"); frm.handle.focus(); return false; } else if(frm.year.value=='') { alert("Please Select Year"); frm.year.focus(); return false; } else return true; } function calM3(frm) { var length = (frm.length.value == '' || frm.length.value == 0)? 1 : frm.length.value; var width = (frm.width.value == '' || frm.width.value == 0)? 1 : frm.width.value; var height = (frm.height.value == '' || frm.height.value == 0)? 1 : frm.height.value; frm.m3.value = Math.round(((length*width*height) / 1000000)*100) / 100 } var picDiv; var vehId; function getPics(veh_id) { if (window.XMLHttpRequest) http_request = new XMLHttpRequest(); else if (window.ActiveXObject) http_request = new ActiveXObject("Microsoft.XMLHTTP"); picDiv = "picsDiv_"+veh_id; vehId = veh_id; url ='http://www.reliancemotors.com.na/secure/ajax/vehicle.ajax.php?action=getPics&veh_id='+veh_id; //window.open(url); try { http_request.open('GET', url,true); } catch(err){alert(err.toString());} http_request.onreadystatechange = handlePics; try { http_request.send(null); } catch(err){alert(err.toString());} } function handlePics() { var xmldoc = http_request.responseXML; if(http_request.readyState != 4 ) { document.getElementById(picDiv).innerHTML = '
'; showDiv(picDiv); } if(http_request.readyState == 4) { if(xmldoc.getElementsByTagName('PIC_COUNT')[0].firstChild.data==0) { document.getElementById(picDiv).innerHTML = '
No Picture is Uploaded, Edit Vehicle to add Pics' } else { var divHtml = ''; for(i=0; i < xmldoc.getElementsByTagName('PIC_COUNT')[0].firstChild.data; i++) { var img = xmldoc.getElementsByTagName('PIC_URL')[i].firstChild.data var pic_id = xmldoc.getElementsByTagName('PIC_ID')[i].firstChild.data var priority = xmldoc.getElementsByTagName('PIC_PRIORITY')[i].firstChild.data divHtml += '
'; divHtml += ''; divHtml += '

'; divHtml += ''; divHtml += '
'; } divHtml += '
'; divHtml += 'Hide'; divHtml += '
'; document.getElementById(picDiv).innerHTML = divHtml; } } } function postFrm(id,j) { var str = ""; for(i = 0 ; i < j; i++) { var pri_fl = 'pic_priority_'+id+'_'+i; var pic_fl = 'pic_id_'+id+'_'+i; var priority = document.getElementById(pri_fl).value; var pic_id = document.getElementById(pic_fl).value; str += "pic_priority["+pic_id+"]="+priority+"&" } if (window.XMLHttpRequest) http_request = new XMLHttpRequest(); else if (window.ActiveXObject) http_request = new ActiveXObject("Microsoft.XMLHTTP"); url ='http://www.reliancemotors.com.na/secure/ajax/vehicle.ajax.php?'+str+"action=UpdatePics"; //window.open(url); try { http_request.open('GET', url,true); } catch(err){alert(err.toString());} http_request.onreadystatechange = updatePics; try { http_request.send(null); } catch(err){alert(err.toString());} } function updatePics() { var xmldoc = http_request.responseXML; if(http_request.readyState == 4) { if(xmldoc.getElementsByTagName('FLAG')[0].firstChild.data==1) { alert("Picture Order Updated"); } else { alert("Cannot Update Pictures"); } } }