﻿	var xmlHttp;
	var theSel;
	var SubSel;
	function createXMLHttpRequest() 
	{
		if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("MICROSOFT.XMLHTTP");
		}
		else if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
		}
	}

	function handleStateChange()
	{
		
		if (xmlHttp.readyState == 1) {
			document.getElementById("wait").style.display = "";
			}
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) 
			{			  				
			document.getElementById("wait").style.display = "none";		
			document.getElementById("mainpage").innerHTML = xmlHttp.responseText;		
			}// else
		//	var xmlDoc=loadXMLDoc("../resultdata.xml");
	//		var x = xmlDoc.getElemnetByTagName('desc');
		//	document.getElementById("code").value= xmlDoc.getElementsByTagName("code")[0].childNodes[0].nodeValue;
		//	document.getElementById("wait").innerText= x[0].childNodes[0].nodeValue;
		//	document.getElementById("txtdesc").innerText= xmlDoc.getElementsByTagName("desc")[0].childNodes[0].nodeValue;
		//	document.getElementById("txtPrice").innerText= xmlDoc.getElementsByTagName("price")[0].childNodes[0].nodeValue;
		//	document.getElementById("txtAmount").innerText= xmlDoc.getElementsByTagName("amount")[0].childNodes[0].nodeValue;
			}
			try {
			if (xmlHttp.status == 500) {
			document.getElementById("wait").innerHTML = "<font color=red size=2 face=tahoma>Please refresh the page!</font></center>";
			}
			}
			catch (e)
			{}	
		}
		
////////////////// Load Categories////////////		
function handleCatStateChange()
	{
		if (xmlHttp.readyState == 1) {
			document.getElementById("wait").style.display = "";
			}
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) 
			{
			document.getElementById("wait").style.display = "none";
			xmlDoc = xmlHttp.responseXML;
			  var x=xmlDoc.getElementsByTagName("Categories");			  		
			  for (i=0; i< x.length; i++) 
			  {			  				  	
			    opt = document.createElement("option");  
                opt.text= x[i].getElementsByTagName("Main")[0].childNodes[0].nodeValue;                
			    try {
			        document.getElementById("MainCat").add(opt,null)
			    }//try
			    catch(e)
			    {
			        document.getElementById("MainCat").add(opt)
			    }//catch
			  }//for
			}//if
		}//if
	}//function
//////////////////End of Load Categories////////////	
////////////////// Load SUB Categories////////////		
function handleSubStateChange()
	{
		if (xmlHttp.readyState == 1) {
			document.getElementById("wait").style.display = "";
			}
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) 
			{
			var selIndex = theSel.selectedIndex;
			var mainCat = theSel.options[selIndex].value;
			//document.write(mainCat);
			xmlDoc = xmlHttp.responseXML;
			  var x=xmlDoc.getElementsByTagName("Categories");			  		
			  for (i=0; i< x.length; i++) 
			  {			  				  	
			     
			    if (mainCat == x[i].getElementsByTagName("Main")[0].childNodes[0].nodeValue)
			    {
				  opt = document.createElement("option");
              	  opt.text= x[i].getElementsByTagName("Sub")[0].childNodes[0].nodeValue;
				    try {
				        document.getElementById("Subcat").add(opt,null)
				    }//try
				    catch(e)
				    {
				        document.getElementById("Subcat").add(opt)
				    }//catch
			    }//if
			  }//for
			  document.getElementById("wait").style.display = "none";
			}//if
		}//if
	}//function
//////////////////End of Load SUB Categories////////////	
///////////////// Load Ads Form ///////////////////////

	function handleformLoadStateChange()
	{
		
		if (xmlHttp.readyState == 1) {
			document.getElementById("wait").style.display = "";
			}
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) 
			{			  				
			document.getElementById("wait").style.display = "none";		
			document.getElementById("AdsInput").innerHTML = xmlHttp.responseText;		
			}// else
			}
			try {
			if (xmlHttp.status == 500) {
			document.getElementById("wait").style.display = "";
			document.getElementById("wait").innerHTML = "<font color=red size=2 face=tahoma>Please refresh the page!</font></center>";
				}	
			}
			catch(e)
			 { }
		}

///////////////End of Load Ads Form //////////////////

	function LoadSignUp() 
	{
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = handleStateChange;
		var url = "signup.aspx?t"+ Math.random();
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);

	}
function LoadFirstPage(show,page) 
	{
  	  for (var i=0; i < document.mainForm.layout.length; i++)
	   {
	   if (document.mainForm.layout[i].checked)
	      {
	      var selected = document.mainForm.layout[i].value;
	      }
	   }
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = handleStateChange;
		var url = "firstpage.aspx?show=" + show + "&layout=" + selected +"&page=" + page +"&t="+ Math.random();
		xmlHttp.open("GET", url, true);
		//xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		//xmlHttp.send("fname=Henry&lname=Ford")
		xmlHttp.send(null);
	}
function LoadCategires() 
	{
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = handleCatStateChange;
		var url = "MainCategories.xml";
		xmlHttp.open("GET", url, true);
		//xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		//xmlHttp.send("fname=Henry&lname=Ford")
		xmlHttp.send(null);
	}
function LoadSubCategires(sel) 
	{
		theSel  = sel;
		RemoveOptions();
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = handleSubStateChange;
		var url = "SubCategories.xml";
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
function RemoveOptions()
{
	var opt = document.getElementById("Subcat");
	for(i=opt.length - 1; i>=0; i--)
	{
		opt.remove(i);
	}
}
//*************************  Load Ads Form ***************************
function LoadAdsForm(Subsel) 
	{
		var selIndex = theSel.selectedIndex;
		var mainCat = theSel.options[selIndex].value;
	    selIndex = Subsel.selectedIndex;
	    var SubCat = Subsel.options[selIndex].value;
	   // document.write(mainCat + " " + SubCat);
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = handleformLoadStateChange;
		var url = "adformloader.aspx?main=" + mainCat + "&sub=" + SubCat + "&loadform=add&t="+ Math.random();
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
	
//*************************  Load Ads Form for EDIT ***************************

	function handleEditformLoad()
	{
		
		if (xmlHttp.readyState == 1) {
			document.getElementById("wait").style.display = "";
			}
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) 
			{
						  				
			document.getElementById("wait").style.display = "none";		
			document.getElementById("AdsInput").innerHTML = xmlHttp.responseText;		
			}// else
			}
			try {
			if (xmlHttp.status == 500) {
			document.getElementById("wait").style.display = "";
			document.getElementById("wait").innerHTML = "<font color=red size=2 face=tahoma>Please refresh the page!</font></center>";
				}	
			}
			catch(e)
			 { }
		}


function LoadAdsEditForm(Subsel) 
	{
		var selIndex = Subsel.selectedIndex;
		var AdID = Subsel.options[selIndex].value;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = handleEditformLoad;
		var url = "adformloader.aspx?ID=" + AdID + "&loadform=edit&t="+ Math.random();
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}

//********************** Upload Files ******************************
//******************************************************************
/////////////////////////////////////////////////////////////////
function OpenFileUpload()
{
	var userid = document.getElementById("userid").value;
	popupwin = window.open("fileUpload.aspx","fileupload","scrollbars=1, width=310,height=250,top=100,left=500");
}
/////////////////////////////////////////////////////////////////

	function FileUploadstateChange()
	{
		
		if (xmlHttp.readyState == 1) {
			document.getElementById("message").innerHTML = "<img src='images/uploading.gif'/>";
			}
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) 
			{		  				
			document.getElementById("message").innerHTML =xmlHttp.responseText;		
			document.getElementById("uploadedfiles").innerHTML = xmlHttp.responseText;		
			}// else
			}
			try {
			if (xmlHttp.status == 500) {
			//document.getElementById("UploadedFiles").style.display = "";
			document.getElementById("message").innerHTML = "<font color=red size=2 face=tahoma>Error while uploading the file!</font>";
			}	
			}
			catch(e)
			 { }
		}

function Upload() 
	{
		document.getElementById("message").innerHTML = "Entered";
		//document.GetElemetById("Upload").enable = false;
		createXMLHttpRequest();
		//var userid = document.getElementById("userid").value;
		xmlHttp.onreadystatechange = FileUploadstateChange;
		var url = "fileUpload.aspx?act=upload&t="+ Math.random();
		xmlHttp.open("GET", url, true);
		//xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		//xmlHttp.send("fname=Henry&lname=Ford")
		xmlHttp.send(null);
	}
function ClearMessage()
{
	document.getElementById("message").innerHTML = "";
}
////////////////////////////////////////////////////////////////
function UpdateThePrice()
{
	var price = 0;
	for (var i=0; i < document.form3.stars.length; i++)
   {
   if (document.form3.stars[i].checked)
      {
      var selected = document.form3.stars[i].value;
      }
   }
	//var selected = document.getElementById("stars").value;
	switch (selected)
	{
		case "0": price = 0; break;
		case "1": price = 10; break;
		case "2": price = 20; break;
		case "3": price = 30; break;
		case "4": price = 40; break;
		case "5": price = 50; break;
	}
	if (document.form3.Vip[0].checked) 
	{ 
    	for (var i=0; i < document.form3.stars.length; i++)
 	      var selected = document.form3.stars[i].disabled =false;	 
	}
	else {
	  price= 100;
	for (var i=0; i < document.form3.stars.length; i++)
 	      var selected = document.form3.stars[i].disabled =true;	
	  }

	if (price == 0) 
		document.getElementById("StarsPrice").innerText = "Free!";
	else
		document.getElementById("StarsPrice").innerText = "$" + price;
	
}
/////////////////////////////////////////////////////////////////
function OpenTermAndCond()
{
	popupwin = window.open("TermandCond.html","termCond","scrollbars=1, width=550,height=400");
}
/////////////////////////////////////////////////////////////////
	function SaveFormstateChange()
	{
		
		if (xmlHttp.readyState == 1) {
			document.getElementById("LoadSave").style.display = "";
			}
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) 
			{
			var output = "<br/><br/><div style='text-align:center;font-size:15pt;color:blue;font-family:Verdana;font-style:italic'><img src='images/ok.png' height='54' width='51' alt='OK'/>Your advertisement successfully saved</div>";
			output += "<br/><br/><br/><br/><p style='font-family: Verdana;text-align: center;'>[Your advertisement will be appear in the website after approval]</p>";
			document.getElementById("AdsInput").innerHTML = output;
			//document.getElementById("AdsInput").innerHTML = xmlHttp.responseText;		
			}// else
			}
			try {
			if (xmlHttp.status == 500) {
			document.getElementById("LoadSave").style.display = "";
			document.getElementById("LoadSave").innerHTML = xmlHttp.responseText;
			//"<font color=red size=2 face=tahoma>Couldn't save!</font></center>";
				}	
			}
			catch(e)
			 { }
		}
/////////////////////////////////////////////////////////////////

function SaveThisForm()
{
	if (!document.form3.CheckAgree.checked) 
	{
		document.getElementById("AgreeMessage").innerText  = "Check To Agree";
		document.form3.title.style.borderColor = "#336600";
	} 
	else 
	if (document.form3.title.value == "")
	{
		document.getElementById("AgreeMessage").innerText = "Title is Empty!";
		document.form3.title.style.borderColor = "#FF0000";
	}
	else
	{
		var param = "";
		var sel = false;
		var mainCat = document.getElementById("MainCat").options[document.getElementById("MainCat").selectedIndex].value;
		var SubCat = document.getElementById("Subcat").options[document.getElementById("Subcat").selectedIndex].value;
		param = param + "Gender=" + document.getElementById("gender").options[document.getElementById("gender").selectedIndex].value + "&";
		param = param + "Fname=" + document.form3.fname.value + "&";
		param = param + "Mname=" + document.form3.mname.value + "&";
		param = param + "Lname=" + document.form3.lname.value + "&";
		param = param + "Add1=" + document.form3.add1.value + "&";
		param = param + "Add2=" + document.form3.add2.value + "&";
		param = param + "City=" + document.form3.city.value + "&";
		param = param + "State=" + document.form3.state.value + "&";
		param = param + "Zip=" + document.form3.zipcode.value + "&";
		param = param + "Country=" + document.form3.country.options[document.getElementById("country").selectedIndex].value + "&";
		param = param + "Cellphone=" + document.form3.cellphone.value + "&";
		param = param + "Phone=" + document.form3.phone.value + "&";
		param = param + "Fax=" + document.form3.fax.value + "&";
		param = param + "Facebook=" + document.form3.facebook.value + "&";
		param = param + "Myspace=" + document.form3.myspace.value + "&";
		param = param + "Twitter=" + document.form3.twitter.value + "&";
		param = param + "Emailadd=" + document.form3.emailadd.value + "&";			
		param = param + "Webadd=" + document.form3.webadd.value + "&";
		param = param + "Hours=" + document.form3.hours.value + "&";
		param = param + "Desc=" + document.form3.desc.value + "&";
			for (x=0;x<document.form3.Vip.length; x++)
				if (document.form3.Vip[x].checked) 
				{
				param = param + "Vip=" + document.form3.Vip[x].value + "&";
				}
			for (x=0;x<document.form3.stars.length; x++)
				if (document.form3.stars[x].checked) 
				{
				param = param + "Stars=" + document.form3.stars[x].value + "&";
				}
				//param = param + "placeReg=" + document.form3.placeReg.checked + "&";
				if (document.form3.placeTop.checked){ 
				   param = param + "placeTop=Top&";	
				   }else
				   {
				   param = param + "placeTop=Regular&";	
				   }
	     param = param + "Title=" + document.form3.title.value + "&";
										
		////// Data By Category///////////////////////////////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		if (mainCat == "Business Directory") 
		{
			param = param + "Company=" + document.form3.CompName.value;
		}
		if (mainCat == "Jobs") 
		{
			param = param + "Company=" + document.form3.CompName.value + "&";
			param = param + "JobCat=" + document.form3.Jobcategory.options[document.getElementById("Jobcategory").selectedIndex].value;		
		}// if maincat Jobs
		if (mainCat == "Housing") 
		{
			if (SubCat == "Buy")
			{
			param = param + "Company=" + document.form3.CompName.value + "&";
			param = param + "Describe=" + document.form3.DescribeYourself.options[document.getElementById("DescribeYourself").selectedIndex].value + "&";
			param = param + "PropType=" + document.form3.PropType.options[document.getElementById("PropType").selectedIndex].value + "&";
			param = param + "Size=" + document.form3.size.value + "&";
			param = param + "Price1=" + document.form3.price1.value + "&";
			param = param + "Price2=" + document.form3.price2.value;
			}// if subcat BUY	
			if (SubCat == "Sell")
			{
			param = param + "Company=" + document.form3.CompName.value + "&";
			param = param + "Describe=" + document.form3.DescribeYourself.options[document.getElementById("DescribeYourself").selectedIndex].value + "&";
			param = param + "PropType=" + document.form3.PropType.options[document.getElementById("PropType").selectedIndex].value + "&";
			param = param + "Size=" + document.form3.size.value + "&";
			param = param + "Price=" + document.form3.price.value;
			}// if subcat Sell	
			if (SubCat == "Rent")
			{
			param = param + "Company=" + document.form3.CompName.value + "&";
			param = param + "PropType=" + document.form3.PropType.options[document.getElementById("PropType").selectedIndex].value + "&";
			param = param + "Size=" + document.form3.size.value + "&";
			param = param + "Deposit=" + document.form3.deposit.value + "&";
			param = param + "Price=" + document.form3.price.value;			
			}// if subcat RENT
			if (SubCat == "Roommate")
			{
			param = param + "Occupation=" + document.form3.occupation.value + "&";
			param = param + "Rdesc=" + document.form3.roommatedesc.value + "&";
			param = param + "Rgender=" + document.form3.roomategender.options[document.getElementById("roomategender").selectedIndex].value + "&";
			param = param + "Rsmoke=" + document.form3.smoke.options[document.getElementById("smoke").selectedIndex].value + "&";
			param = param + "Rdrink=" + document.form3.drink.options[document.getElementById("drink").selectedIndex].value + "&";
			param = param + "Rchild=" + document.form3.child.options[document.getElementById("child").selectedIndex].value + "&";
			param = param + "Percent=" + document.form3.percent.value;
			}// if subcat RENT

		}// if maincat housing
		if (mainCat == "Events")
		{
			param = param + "Company=" + document.form3.CompName.value + "&";
			param = param + "Price=" + document.form3.price.value;			
		}// if maincat Events
		if (mainCat == "Cars")
		{
			if (SubCat == "Sell") {
			param = param + "Company=" + document.form3.CompName.value + "&";
			param = param + "Make=" + document.form3.make.options[document.getElementById("make").selectedIndex].value + "&";	
			param = param + "Model=" + document.form3.model.value + "&";
			param = param + "Year=" + document.form3.year.value + "&";								
			param = param + "Price=" + document.form3.price.value;			
			}// if subcat SELL
			if (SubCat == "Buy") {
			param = param + "Company=" + document.form3.CompName.value + "&";
			param = param + "Make=" + document.form3.make.options[document.getElementById("make").selectedIndex].value + "&";
			param = param + "Model=" + document.form3.model.value + "&";
			param = param + "Year=" + document.form3.year.value + "&";
			param = param + "Price1=" + document.form3.price1.value + "&";
			param = param + "Price2=" + document.form3.price2.value;
			}// if subcat BUY
		}// if maincat CARS
		if (mainCat == "Buy and Sell")
		{
			if (SubCat == "Sell") {
			param = param + "Company=" + document.form3.CompName.value + "&";
			param = param + "Product=" + document.form3.product.options[document.getElementById("product").selectedIndex].value + "&";	
			param = param + "PName=" + document.form3.productName.value + "&";
			param = param + "Shipping=" + document.form3.Shipping.value + "&";								
			param = param + "Price=" + document.form3.price.value;			
			}// if subcat SELL
			if (SubCat == "Buy") {
			param = param + "Company=" + document.form3.CompName.value + "&";
			param = param + "PName=" + document.form3.productName.value + "&";
			param = param + "Price=" + document.form3.price.value;			
			}// if subcat Buy

		}// if mancat Buy and Sell
	//	document.write(param);
		createXMLHttpRequest();
		var userid = document.getElementById("userid").value;
		xmlHttp.onreadystatechange = SaveFormstateChange;
		var url = "action.aspx?act=saveform&MainCat=" + mainCat + "&SubCat=" + SubCat + "&" + param + "&t="+ Math.random();
		xmlHttp.open("GET", url, true);
		//xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		//xmlHttp.send("fname=Henry&lname=Ford")
		xmlHttp.send(null);			

	}
}
/////////////////////////////////////////////////////////////////
	function SaveEditFormstateChange()
	{
		
		if (xmlHttp.readyState == 1) {
			document.getElementById("wait").style.display = "";
			}
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) 
			{
			var output = "<br/><br/><div style='text-align:center;font-size:15pt;color:blue;font-family:Verdana;font-style:italic'><img src='images/ok.png' height='54' width='51' alt='OK'/>Your advertisement successfully saved</div>";
			output += "<br/><br/><br/><br/><p style='font-family: Verdana;text-align: center;'>[Your advertisement will be appear in the website after approval]</p>";
			document.getElementById("AdsInput").innerHTML = output;
			document.getElementById("wait").style.display = "none";
			//document.getElementById("AdsInput").innerHTML = xmlHttp.responseText;		
			}// else
			}
			try {
			if (xmlHttp.status == 500) {
			document.getElementById("wait").style.display = "";
			document.getElementById("wait").innerHTML = xmlHttp.responseText;
			//"<font color=red size=2 face=tahoma>Couldn't save!</font></center>";
				}	
			}
			catch(e)
			 { }
		}
//////////////////SAVE EDIT FORM///////////////////////////////////////////

function SaveEditForm()
{
	if (document.form3.title.value == "")
	{
		document.getElementById("AgreeMessage").innerText = "Title is Empty!";
		document.form3.title.style.borderColor = "#FF0000";
	}
	else
	{
		var param = "";
		var sel = false;
		var mainCat = document.getElementById("MainCat").innerText;
		var SubCat = document.getElementById("SubCat").innerText;
		var AdID = document.getElementById("ID").value;
		param = param + "Gender=" + document.getElementById("gender").options[document.getElementById("gender").selectedIndex].value + "&";
		param = param + "Fname=" + document.form3.fname.value + "&";
		param = param + "Mname=" + document.form3.mname.value + "&";
		param = param + "Lname=" + document.form3.lname.value + "&";
		param = param + "Add1=" + document.form3.add1.value + "&";
		param = param + "Add2=" + document.form3.add2.value + "&";
		param = param + "City=" + document.form3.city.value + "&";
		param = param + "State=" + document.form3.state.value + "&";
		param = param + "Zip=" + document.form3.zipcode.value + "&";
		param = param + "Country=" + document.form3.country.options[document.getElementById("country").selectedIndex].value + "&";
		param = param + "Cellphone=" + document.form3.cellPhone.value + "&";
		param = param + "Phone=" + document.form3.phone.value + "&";
		param = param + "Fax=" + document.form3.fax.value + "&";
		param = param + "Facebook=" + document.form3.facebook.value + "&";
		param = param + "Myspace=" + document.form3.myspace.value + "&";
		param = param + "Twitter=" + document.form3.twitter.value + "&";
		param = param + "Emailadd=" + document.form3.emailadd.value + "&";			
		param = param + "Webadd=" + document.form3.website.value + "&";
		param = param + "Hours=" + document.form3.contactHours.value + "&";
		param = param + "Desc=" + document.form3.desc.value + "&";
			for (x=0;x<document.form3.Vip.length; x++)
				if (document.form3.Vip[x].checked) 
				{
				param = param + "Vip=" + document.form3.Vip[x].value + "&";
				}
			for (x=0;x<document.form3.stars.length; x++)
				if (document.form3.stars[x].checked) 
				{
				param = param + "Stars=" + document.form3.stars[x].value + "&";
				}
				//param = param + "placeReg=" + document.form3.placeReg.checked + "&";
				if (document.form3.location.checked){ 
				   param = param + "placeTop=Top&";	
				   }else
				   {
				   param = param + "placeTop=Regular&";	
				   }
	     param = param + "Title=" + document.form3.title.value + "&";
										
		////// Data By Category///////////////////////////////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		if (mainCat == "Business Directory") 
		{
			param = param + "Company=" + document.form3.company.value;
		}
		if (mainCat == "Jobs") 
		{
			param = param + "Company=" + document.form3.company.value + "&";
			param = param + "JobCat=" + document.form3.jobCat.options[document.getElementById("jobCat").selectedIndex].value;		
		}// if maincat Jobs
		if (mainCat == "Housing") 
		{
			if (SubCat == "Buy")
			{
			param = param + "Company=" + document.form3.company.value + "&";
			param = param + "Describe=" + document.form3.describeurself.options[document.getElementById("describeurself").selectedIndex].value + "&";
			param = param + "PropType=" + document.form3.propertyType.options[document.getElementById("propertyType").selectedIndex].value + "&";
			param = param + "Size=" + document.form3.size.value + "&";
			param = param + "Price1=" + document.form3.price1.value + "&";
			param = param + "Price2=" + document.form3.price2.value;
			}// if subcat BUY	
			if (SubCat == "Sell")
			{
			param = param + "Company=" + document.form3.company.value + "&";
			param = param + "Describe=" + document.form3.describeurself.options[document.getElementById("describeurself").selectedIndex].value + "&";
			param = param + "PropType=" + document.form3.propertyType.options[document.getElementById("propertyType").selectedIndex].value + "&";
			param = param + "Size=" + document.form3.size.value + "&";
			param = param + "Price=" + document.form3.price1.value;
			}// if subcat Sell	
			if (SubCat == "Rent")
			{
			param = param + "Company=" + document.form3.company.value + "&";
			param = param + "PropType=" + document.form3.propertyType.options[document.getElementById("propertyType").selectedIndex].value + "&";
			param = param + "Size=" + document.form3.size.value + "&";
			param = param + "Deposit=" + document.form3.deposit.value + "&";
			param = param + "Price=" + document.form3.price1.value;			
			}// if subcat RENT
			if (SubCat == "Roommate")
			{
			param = param + "Occupation=" + document.form3.occupation.value + "&";
			param = param + "Rdesc=" + document.form3.desc2.value + "&";
			param = param + "Rgender=" + document.form3.roomGender.options[document.getElementById("roomGender").selectedIndex].value + "&";
			param = param + "Rsmoke=" + document.form3.smoking.options[document.getElementById("smoking").selectedIndex].value + "&";
			param = param + "Rdrink=" + document.form3.drinking.options[document.getElementById("drinking").selectedIndex].value + "&";
			param = param + "Rchild=" + document.form3.children.options[document.getElementById("children").selectedIndex].value + "&";
			param = param + "Percent=" + document.form3.percentage.value;
			}// if subcat RENT

		}// if maincat housing
		if (mainCat == "Events")
		{
			param = param + "Company=" + document.form3.company.value + "&";
			param = param + "Price=" + document.form3.price1.value;			
		}// if maincat Events
		if (mainCat == "Cars")
		{
			if (SubCat == "Sell") {
			param = param + "Company=" + document.form3.company.value + "&";
			param = param + "Make=" + document.form3.carMake.options[document.getElementById("carMake").selectedIndex].value + "&";	
			param = param + "Model=" + document.form3.carModel.value + "&";
			param = param + "Year=" + document.form3.carYear.value + "&";								
			param = param + "Price=" + document.form3.price1.value;			
			}// if subcat SELL
			if (SubCat == "Buy") {
			param = param + "Company=" + document.form3.company.value + "&";
			param = param + "Make=" + document.form3.carMake.options[document.getElementById("carMake").selectedIndex].value + "&";
			param = param + "Model=" + document.form3.carModel.value + "&";
			param = param + "Year=" + document.form3.carYear.value + "&";
			param = param + "Price1=" + document.form3.price1.value + "&";
			param = param + "Price2=" + document.form3.price2.value;
			}// if subcat BUY
		}// if maincat CARS
		if (mainCat == "Buy and Sell")
		{
			if (SubCat == "Sell") {
			param = param + "Company=" + document.form3.company.value + "&";
			param = param + "Product=" + document.form3.product.options[document.getElementById("product").selectedIndex].value + "&";	
			param = param + "PName=" + document.form3.produtName.value + "&";
			param = param + "Shipping=" + document.form3.shipping.value + "&";								
			param = param + "Price=" + document.form3.price1.value;			
			}// if subcat SELL
			if (SubCat == "Buy") {
			param = param + "Company=" + document.form3.company.value + "&";
			param = param + "PName=" + document.form3.produtName.value + "&";
			param = param + "Price=" + document.form3.price1.value;			
			}// if subcat Buy

		}// if mancat Buy and Sell
	//	document.write(param);
		createXMLHttpRequest();
		var userid = document.getElementById("userid").value;
		xmlHttp.onreadystatechange = SaveEditFormstateChange;
		var url = "action.aspx?act=saveEdited&MainCat=" + mainCat + "&SubCat=" + SubCat + "&ID=" + AdID + "&" + param + "&t="+ Math.random();
		xmlHttp.open("GET", url, true);
		//xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		//xmlHttp.send("fname=Henry&lname=Ford")
		xmlHttp.send(null);			

	}
}
///////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////LOAD YOUR ADs. ///////////////////////////////////////////////////
	function LoadMyAdsStateChange()
	{

		if (xmlHttp.readyState == 1) {
			document.getElementById("wait").style.display = "";
			}
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) 
			{
			//var selIndex = theSel.selectedIndex;
			//var mainCat = theSel.options[selIndex].value;
			//document.write(mainCat);
			var xmlDoc = xmlHttp.responseXML;
			  var x=xmlDoc.getElementsByTagName("AdsInfo");	
			  document.getElementById("wait").innerText = x[0].getElementsByTagName("Title")[0].childNodes[0].nodeValue;;		  		
			  for (i=0; i< x.length; i++) 
			  {			  				  	
			      opt = document.createElement("option");
              	  opt.label= x[i].getElementsByTagName("Title")[0].childNodes[0].nodeValue;
              	  opt.value= x[i].getElementsByTagName("ID")[0].childNodes[0].nodeValue;
              	  
				    try {
				        document.getElementById("Adslist").add(opt,null)
				    }//try
				    catch(e)
				    {
				        document.getElementById("Adslist").add(opt)
				    }//catch
			  }//for
			  document.getElementById("wait").style.display = none;
			  
			}//if
		}//if
	}//function

 ////////////////////////////////////////////////////////////////////////////////////
function loadMyAds()
{
	    createXMLHttpRequest();
		var userid = document.getElementById("userid").value;
		//document.write(userid);
		xmlHttp.onreadystatechange = LoadMyAdsStateChange;
		var url = "action.aspx?act=LoadMyAds&userid=" + userid + "&t="+ Math.random();
		xmlHttp.open("GET", url, true);
		//xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		//xmlHttp.send("fname=Henry&lname=Ford")
		xmlHttp.send(null);	
}
///////////////////////////////////////////////////////////////////////////
function sortlist(id) {
var lb = document.getElementById(id);
arrTexts = new Array();

for(i=0; i<lb.length; i++)  {
  arrTexts[i] = lb.options[i].text;
}

arrTexts.sort();

for(i=0; i<lb.length; i++)  {
  lb.options[i].text = arrTexts[i];
  lb.options[i].value = arrTexts[i];
}
}
