// JavaScript Document

				var intMAXTypes = "<% = maxTypes %>"			
				var http_request = false;           
			
				function getData(o,d,dID,v) {
				
				
				//alert(d)
				
				var data = "datatype=" + d + "&value="+  v +"&typeID=" + dID + "&pos="+o
				
				var maxLists =document.frmData.elements.length
				//var field = document.getElementById('outer_' + d)
				var field = 'outer_' + d
				//alert(field)
				
				AJAXRequest("POST","getData.asp",data,"false",field,'')

					
				}
				
				function clearSubordinates(thenum) {
				
					var theForm = document.frmData
						  var selectCount = 0
						  for(i=thenum; i<theForm.elements.length; i++) {
							if(theForm.elements[i].type == "select-one") {
							
							if (selectCount < intMAXTypes) {
							
							var obj = document.getElementById('outer_' + theForm.elements[i].name)
							//alert('outer_' + theForm.elements[i].name)
							obj.innerHTML = "<select name=" + theForm.elements[i].name + " id=" + theForm.elements[i].name + "><option>None</option></select>"
							//theForm.elements[i].innerHTML="<select name=" + theForm.elements[i].name + " id=" + theForm.elements[i].name + "><option>None</option></select>"
							theForm.elements[i].disabled=true
							  selectCount += 1
							  }
							  }
						 }
					}

function filterBy(sParam,sValue) {

	window.location.href=window.location.pathname + "?" + sParam + "=" + sValue
	
}
function stockSearch() {
	
	var sValue = document.getElementById('stocknumber').value
	window.location.href=window.location.pathname + "?stocknumber=" + sValue
	
}
function clearFilter() {
	
	window.location.href=window.location.pathname
}
function checkStockNumber(s,i) {
   AJAXRequest("POST","checkStockNumber.asp","serial=" +  s + "&item=" + i,"true","alert","")
   
   //if (chk) {alert()};
}

function changePrimaryPhoto(id) {
					window.showModalDialog('primaryPhoto.asp?stockid='+ id + '&noCache=' + (new Date()).valueOf(),self,'dialogHeight:200px;dialogWidth:500px;status:no;scroll:auto;help:no;resizable:yes;center:yes')
					}
					
					function deletePrimaryPhoto(eID) {
					var conf = confirm("Are you sure you want to delete this photo?")
					if (conf) {				
					
					var data = "stockID=" + eID +"&frmaction=deletePrimary"
					var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
					xmlhttp.Open("POST","AdditionalPhotos.asp",false);
					xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					xmlhttp.send(data);
					if (xmlhttp.readyState==4) {
					//alert(xmlhttp.responseText)
					document.getElementById('titleimg').value="";
					document.getElementById('primaryThumbnail').src='/images/noImage.gif';

							}
						}
					
					}
					
					function deletePhotos(v,p) {
					 var conf = confirm("Are you sure you want to delete this photograph?")
					 if (conf) {
						//document.getElementById('CreatePDF').disabled=true;
						var data = "stockID=" + v +"&photoid=" +p+"&frmaction=delete"
						var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
						xmlhttp.Open("POST","AdditionalPhotos.asp",false);
						xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
						xmlhttp.send(data);
						if (xmlhttp.readyState==4) {
							//document.getElementById('additionalPhotos').innerHTML=xmlhttp.responseText
							}
						}
						}
					
					 function getPhotos(v) {
					//document.getElementById('CreatePDF').disabled=true;
					
					var data = "stockID=" + v +"&frmaction=display"
					//alert(data)
					var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
					xmlhttp.Open("POST","AdditionalPhotos.asp",false);
					xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					xmlhttp.send(data);
					if (xmlhttp.readyState==4) {
						document.getElementById('additionalPhotos').innerHTML=xmlhttp.responseText
						}
					}
					
					 function getDocs(v) {
					//document.getElementById('CreatePDF').disabled=true;
					
					var data = "stockID=" + v +"&frmaction=displaydocs"
					//alert(data)
					var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
					xmlhttp.Open("POST","AdditionalPhotos.asp",false);
					xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					xmlhttp.send(data);
					if (xmlhttp.readyState==4) {
						document.getElementById('vehicleDocs').innerHTML=xmlhttp.responseText
						}
					}
					
					function deleteDocument(v,p) {
					 var conf = confirm("Are you sure you want to delete this document?")
					 if (conf) {
						//document.getElementById('CreatePDF').disabled=true;
						var data = "stockID=" + v +"&documentid=" +p+"&frmaction=deletedocument"
						var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
						xmlhttp.Open("POST","AdditionalPhotos.asp",false);
						xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
						xmlhttp.send(data);
						if (xmlhttp.readyState==4) {
							//document.getElementById('vehicleDocs').innerHTML=xmlhttp.responseText
							//alert(xmlhttp.responseText)
							}
						}
					}
					
					function makePrimary(i,p) {
					
					var conf = confirm("Are you sure you want to make this the primary photo?")
					 if (conf) {
						//document.getElementById('CreatePDF').disabled=true;
						var data = "stockID=" + i +"&photo=" +p+"&frmaction=makePrimary"
						var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
						xmlhttp.Open("POST","AdditionalPhotos.asp",false);
						xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
						xmlhttp.send(data);
						if (xmlhttp.readyState==4) {
							//document.getElementById('vehicleDocs').innerHTML=xmlhttp.responseText
							//alert(xmlhttp.responseText)
							//document.getElementById('titleimg').value="";
							document.getElementById('primaryThumbnail').src='/photos/thumbnails/' + p;
							
							
							
							getPhotos(i);
							}
						}
						
					}
					
					function getCategoryData(dataID) {						
						AJAXRequest("POST","machineryProperties.asp","cat1=" +  dataID,"true","dataFields",'');
						}
						
					function manageData(i) {
						if (i==0) {alert("Please select a value from the previous drop down list")}
						else {
						window.showModalDialog('manageData.asp?dataid='+ i + '&noCache=' + (new Date()).valueOf(),self,'dialogHeight:400px;dialogWidth:500px;status:no;scroll:auto;help:no;resizable:yes;center:yes')
						}
					}		
					
					 function createPDF(v,c,field) {
						 
						// AJAXRequest("POST","createPDF.asp","stockID=" +  v,false,'','');
					document.getElementById('btnCreatePDF').disabled=true;
					document.getElementById('btnCreatePDF').value="Creating PDF, please wait...";
					//alert(c)
					var data = "stockID=" + v +"&company=" + c
					var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
					xmlhttp.Open("POST","createPDF.asp",true);
					xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					xmlhttp.send(data);
					if (xmlhttp.readyState==4) {
					//alert(xmlhttp.responseText)
						}
					 document.getElementById('btnCreatePDF').disabled=false;
					 document.getElementById('btnCreatePDF').value="Auto generate PDF Datasheet";
					}
					
					function KickUser() {
						
						var w = window.dialogArguments;
						if (w) {
							w.location.href='/aon/login.asp?action=expired';
							self.close();
							} else {
								window.location.href='/aon/login.asp?action=expired';
							}
						}
					
					
					function ConfirmLogout()
					{
						input_box=confirm('Are you sure you want to logout?');
						if (input_box==true){ 
						location.href="/admin/login.asp?action=logout";
						}
					}
					
					function changeMMD(stockID) {
					
						window.showModalDialog('changeMMD.asp?stockID='+ stockID +'&noCache=' + (new Date()).valueOf(),self,'dialogHeight:350px;dialogWidth:550px;status:no;scroll:auto;help:no;resizable:yes;center:yes')

						}
						
					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_showHideLayers() { //v6.0
					  var i,p,v,obj,args=MM_showHideLayers.arguments;
					  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
						if (obj.style) { obj=obj.style; v=(v=='show')?'inline':(v=='hide')?'none':v; }
						obj.display=v; }
					}
//-->