var specialcat;
var options = {path: '/' ,expires: 30 };
$(document).ready(function() {
  $("#login").submit(function() {
      var name = $("input#myusername").val();

      var loc = $("input#mypassword").val();

     	   var country = $('#selectCountry').val();
	    
		var category = $('#selectRegion').val();
		
		var city = $('#selectCity').val();
		
		var datastring = 'state='+category+'&myusername=' + name + '&mypassword='+loc+'&country='+country+'&catname='+specialcat+'&city='+city;


      //deactivate search button
      $("#loginb").attr({ disabled:true, value:"Loading..."});

      $("#loginb").blur();
      $('#login_form').html('<img src="icons/busy.gif" />');
      $.ajax({

        type: "POST", url: "bin/checklogin.php",

        data: datastring,

        complete: function(data) {
        $('#login_form').html(data.responseText);

        $("#loginb").attr({disabled:false, value:"Login"});

        }

      });
	  
    return false;
	  

    });
//$('#country').load('bin/selectcity.php');
//CreateAd();

	$("#fkeyword").submit(function() {



      // validate and process form here



      var name = $("input#name").val();



	   var keyword = $("input#Keyword").val();



      var loc = $("input#loc").val();



      var city = $("input#city1").val();



      var state = $("#state1").val();



      var country = $("#country1").val();



	  var hotel_s = $('#Hotels1').attr('checked')?1:0;



	  var cars_s = $('#Cars1').attr('checked')?1:0;



	  var deliver_s = $('#Delivery').attr('checked')?1:0;



	  var casual_s = $('#Casual').attr('checked')?1:0;



	  var fast_s = $('#Fast1').attr('checked')?1:0;



	  var fine_s = $('#Fine').attr('checked')?1:0;



	  var coffee_s = $('#Coffee').attr('checked')?1:0;



	  var buffet_s = $('#Buffet').attr('checked')?1:0;



	  var comedy_s = $('#Comedy').attr('checked')?1:0;



	  var country_s = $('#Country').attr('checked')?1:0;



	  var dance_s = $('#Dance').attr('checked')?1:0;



	  var piano_s = $('#Piano').attr('checked')?1:0;



	  var malls_s = $('#Stores1').attr('checked')?1:0;



	  var attract_s = $('#Attract').attr('checked')?1:0;



	   var coupon_s = $('#coupon').attr('checked')?1:0;



	   if(coupon_s){var coupon="&coupon=yes";}else{var coupon="&coupon=no";}



	  if(hotel_s){var hotels="&hotel=yes";}else{var hotels="";}



	  if(cars_s){var cars="&cars=yes";}else{var cars="";}



	  if(deliver_s){var deliver="&deliver=yes";}else{var deliver="";}



	  if(casual_s){var casual="&casual=yes";}else{var casual="";}



	  if(fast_s){var fast="&fast=yes";}else{var fast="";}



	  if(fine_s){var fine="&fine=yes";}else{var fine="";}



	  if(coffee_s){var coffee="&coffee=yes";}else{var coffee="";}



	  if(buffet_s){var buffet="&buffet=yes";}else{var buffet="";}



	  if(comedy_s){var comedy="&comedy=yes";}else{var comedy="";}



	  if(dance_s){var dance="&dance=yes";}else{var dance="";}



	  if(piano_s){var piano="&piano=yes";}else{var piano="";}



	  if(malls_s){var malls="&shop=yes";}else{var malls="";}



	  if(attract_s){var other="&att=yes";}else{var other="";}



      var datastring ='name=' + name + '&keyword='+keyword+ '&location='+loc+'&city='+city+'&state='+state+'&country='+country+'&mode=srch'+hotels+cars+fast+deliver+casual+fine+coffee+buffet+comedy+dance+piano+malls+other+coupon;



      //deactivate search button



      $("#submitkey").attr({ disabled:true, value:"Searching..."});



      $("#search").blur();

      $.blockUI({ message:'<h1 class=rounded><img src="../Navigator/icons/busy.gif" /> Searching...</h1>' });



      //$('#results').html("<div align=center><img width=100 height=100 src=../Navigator/icons/loading.gif></div>");







      $.ajax({



        type: "POST", url: "../Navigator/bin/mapsearch.php",



        data: datastring,

		

        complete: function(data) {



			//display datastring for testing



			//alert(datastring);



        clearMarkers();



        $('#results').html(data.responseText);



        $("#submitkey").attr({disabled:false, value:"Keyword Search"});



        }



      });



    return false;



    });



  });



  function PostAD() {



     var email =  $("input#email").val();



      // validate and process form here



      var adtitle = $("input#adtitle").val();



      var make = $("input#make").val();



      var model = $("input#model").val();



      var year = $("input#year").val();



      var price = $("input#price").val();



      var image = $("input#security_code").val();



      var password = $("input#password").val();



      var cat = $("input#cat").val();

	  

	  var description = $('textarea[name="description"]').val();





      var datastring ='email='+email+'&adtitle='+adtitle+'&make='+make+'&model='+model+'&year='+year+'&price='+price+'&security_code='+image+'&password='+password+'&description='+description+'&cat='+cat;



      //deactivate search button



      $.ajax({



        type: "POST", url: "bin/add.php",



        data: datastring,



        complete: function(data) {



			//display datastring for testing



			alert(datastring);





        $('#adddiv').html(data.responseText);





        }



      });



    return false;

  }

	  function Visit(city) {



      // validate and process form here

      var keyword1 = $("input#Keyword").val();

	  

	  if(keyword1 == "Keyword"){keyword="";}else{keyword='&keyword='+keyword1;}

	  

      var name = $("input#name").val();



      var loc = $("input#loc").val();



      var state = $("#state1").val();



      var country = $("#country1").val();



	  var hotel_s = $('#Hotels').attr('checked')?1:0;



	  var cars_s = $('#Cars').attr('checked')?1:0;



	  var deliver_s = $('#Delivery').attr('checked')?1:0;



	  var casual_s = $('#Casual').attr('checked')?1:0;



	  var fast_s = $('#Fast').attr('checked')?1:0;



	  var fine_s = $('#Fine').attr('checked')?1:0;



	  var coffee_s = $('#Coffee').attr('checked')?1:0;



	  var buffet_s = $('#Buffet').attr('checked')?1:0;



	  var comedy_s = $('#Comedy').attr('checked')?1:0;



	  var country_s = $('#Country').attr('checked')?1:0;



	  var dance_s = $('#Dance').attr('checked')?1:0;



	  var piano_s = $('#Piano').attr('checked')?1:0;



	  var malls_s = $('#Malls').attr('checked')?1:0;



	  var attract_s = $('#Attract').attr('checked')?1:0;



	 var coupon_s = $('#coupon').attr('checked')?1:0;



	   if(coupon_s){var coupon="&coupon=yes";}else{var coupon="&coupon=no";}



	  var hotels="&hotel=yes";



	  if(cars_s){var cars="&cars=yes";}else{var cars="";}



	  if(deliver_s){var deliver="&deliver=yes";}else{var deliver="";}



	  if(casual_s){var casual="&casual=yes";}else{var casual="";}



	  if(fast_s){var fast="&fast=yes";}else{var fast="";}



	  if(fine_s){var fine="&fine=yes";}else{var fine="";}



	  if(coffee_s){var coffee="&coffee=yes";}else{var coffee="";}



	  if(buffet_s){var buffet="&buffet=yes";}else{var buffet="";}



	  if(comedy_s){var comedy="&comedy=yes";}else{var comedy="";}



	  if(dance_s){var dance="&dance=yes";}else{var dance="";}



	  if(piano_s){var piano="&piano=yes";}else{var piano="";}



	  if(malls_s){var malls="&malls=yes";}else{var malls="";}



	  if(attract_s){var other="&att=yes";}else{var other="";}



      var datastring ='name=' + name + '&location='+loc+'&city='+city+'&state='+state+'&country='+country+keyword+'&mode=srch'+hotels+cars+fast+deliver+casual+fine+coffee+buffet+comedy+dance+piano+malls+other+coupon;



      $.ajax({



        type: "POST", url: "../Navigator/bin/mapsearch.php",



        data: datastring,



        complete: function(data) {



			//display datastring for testing



			//alert(datastring);



		

		

        clearMarkers();



        $('#results').html('<div align=center><b>Visit ' + city + '</b></div><br><br>' + data.responseText);





        $("#search").attr({disabled:false, value:"Search"});



        }



			 });



  }







 







$("input").click(function () { 



      alert('hello');



    });



function setOptions(o) 

{ 

var select2 = document.form1.select2; 

select2.options.length = 0; 

select2.options[select2.options.length] = new Option(' '); 

if (o == "1") 

{ 

$('#types').show();

select2.options[select2.options.length] = new Option('Cars'); 

select2.options[select2.options.length] = new Option('RV\'s'); 

select2.options[select2.options.length] = new Option('Boats'); 

select2.options[select2.options.length] = new Option('Trucks'); 

select2.options[select2.options.length] = new Option('Motorcycles'); 

} 

if (o == "2") 

{ 

$('#types').show();

select2.options[select2.options.length] = new Option('Full Time'); 

select2.options[select2.options.length] = new Option('Part Time'); 

select2.options[select2.options.length] = new Option('Seeking Employment'); 

} 

if (o == "3") 

{ 

$('#types').show();

select2.options[select2.options.length] = new Option('Dogs'); 

select2.options[select2.options.length] = new Option('Cats'); 

select2.options[select2.options.length] = new Option('Other Pets'); 

select2.options[select2.options.length] = new Option('Supplies & Services'); 

select2.options[select2.options.length] = new Option('Pet Memorials'); 

} 

if (o == "4") 

{ 

$('#types').show(); 

select2.options[select2.options.length] = new Option('Homes'); 

select2.options[select2.options.length] = new Option('Apartments/Condos'); 

select2.options[select2.options.length] = new Option('Lots'); 

select2.options[select2.options.length] = new Option('Miscellaneous'); 

} 

if (o == "5") 

{ 

$('#types').show(); 

select2.options[select2.options.length] = new Option('Houses'); 

select2.options[select2.options.length] = new Option('Apartments/Condos'); 

select2.options[select2.options.length] = new Option('Vacation/Time Shares'); 

select2.options[select2.options.length] = new Option('Rooms for Rent/Sublets'); 

select2.options[select2.options.length] = new Option('Miscellaneous'); 

} 

if (o == "6") 

{ 

$('#types').show();

select2.options[select2.options.length] = new Option('Business Opportunities'); 

select2.options[select2.options.length] = new Option('Sales/Marketing'); 

select2.options[select2.options.length] = new Option('Money to Lend'); 

select2.options[select2.options.length] = new Option('Investment Opportunities'); 

select2.options[select2.options.length] = new Option('Money Wanted'); 

} 

if (o == "7") 

{ 

$('#types').show();

select2.options[select2.options.length] = new Option('Garage Sales'); 

select2.options[select2.options.length] = new Option('Items for Sale'); 

select2.options[select2.options.length] = new Option('Antiques/Collectibles'); 

} 

if (o == "8") 

{ 

$('#types').show();

select2.options[select2.options.length] = new Option('Electricians/Contractors'); 

select2.options[select2.options.length] = new Option('Legal'); 

select2.options[select2.options.length] = new Option('Moving/Storage'); 

select2.options[select2.options.length] = new Option('Other Services'); 

} 

if (o == "9") 

{ 

$('#types').show();

select2.options[select2.options.length] = new Option('Obituaries'); 

select2.options[select2.options.length] = new Option('Public Legal Notices'); 

select2.options[select2.options.length] = new Option('Announcements'); 

select2.options[select2.options.length] = new Option('Lost & Found'); 

} 

if (o == "10") 

{ 

$('#types').show(); 

select2.options[select2.options.length] = new Option('Travel Promotions'); 

select2.options[select2.options.length] = new Option('Ticket Deals'); 

} 

if (o == "11") 

{ 

$('#types').show(); 

select2.options[select2.options.length] = new Option('Schools'); 

select2.options[select2.options.length] = new Option('Private Instruction'); 

} 

if (o == "12") 

{ 

$('#types').show();

select2.options[select2.options.length] = new Option('Bands/Singers'); 

select2.options[select2.options.length] = new Option('Other Entertainment'); 

} 

} 



function Compare(type)



{

var str = type.replace(/\?/,"");

$("#compare").load("../Navigator/bin/"+str+".php");



$("#checkin_date").datepicker({minDate: 0,numberOfMonths: 2,showOn: 'both', buttonImage: 'calendar.jpg', buttonImageOnly: true});



$("#checkout_date").datepicker({minDate: 0,numberOfMonths: 2,showOn: 'both', buttonImage: 'calendar.jpg', buttonImageOnly: true});



}



function MM_jumpMenu(targ,selObj,restore){ //v3.0+++

var category=selObj.options[selObj.selectedIndex].value;

switch(category)

{

case 'Cars':

  	load_form('car');

  break;

}

  if (restore) selObj.selectedIndex=0;

}

function load_form(category)

{

	var datastring = 'catname='+category;

	      $.ajax({



        type: "POST", url: "bin/form.php",



        data: datastring,



        complete: function(data) {



        $('#adddiv').html(data.responseText);







        }



			 });

}
function CreateAd() {
		
		var datastring = 'create=1';

	      $.ajax({



        type: "POST", url: "bin/selectcity.php",



        data: datastring,



        complete: function(data) {


        
        $('#country1').html(data.responseText);
		
		

        
		
		}
				 });
}

function CountrySelect(create) {
	   $('#cities').html('');
	   $('#cities1').html('');
	   
	    if(create)
		{
			$('#regionstate1').html('<img src=icons/busy.gif>');
		var category = $('#selectCountry1').val();
		}else{
			$('#regionstate').html('<img src=icons/busy.gif>');
			var category = $('#selectCountry').val();
		}
		var datastring = 'type=Region&code='+category+'&create='+create;

	      $.ajax({



        type: "POST", url: "bin/selectcity.php",



        data: datastring,



        complete: function(data) {


        if(create)
		{
        $('#regionstate1').html(data.responseText);
		}else{
		$('#regionstate').html(data.responseText);
		}

        
		
		}
				 });
}
function RegionSelect(create) {
	
	   
	   
	   	if(create)
		{
			$('#cities1').html('<img src=icons/busy.gif>');
		var country = $('#selectCountry1').val();
		var category = $('#selectRegion1').val();
		}else{
			$('#cities').html('<img src=icons/busy.gif>');
			var country = $('#selectCountry').val();
			var category = $('#selectRegion').val();
		}

		
		var datastring = 'type=City&code='+category+'&country='+country+'&create='+create;

	      $.ajax({



        type: "POST", url: "bin/selectcity.php",



        data: datastring,



        complete: function(data) {


        if(create)
		{
        $('#cities1').html(data.responseText);
		}else{
		$('#cities').html(data.responseText);
		}
		}
				 });
}
function CitySelect(create) {
	
	   $('#mcats').html('<img src=icons/loading.gif>');
	   	   	if(create)
		{
		var country = $('#selectCountry1').val();
		var category = $('#selectRegion1').val();
		var city = $('#selectCity1').val();
				$.cookie('country1', country, options);
		$.cookie('region1', category, options);
		$.cookie('city1', city, options);
		}else{
			var country = $('#selectCountry').val();
			var category = $('#selectRegion').val();
			var city = $('#selectCity').val();
					$.cookie('country', country, options);
		$.cookie('region', category, options);
		$.cookie('city', city, options);
		}

		

		var datastring = 'reg='+category+'&country='+country+'&city='+city;

	      $.ajax({



        type: "POST", url: "bin/mcats.php",



        data: datastring,



        complete: function(data) {
        if(create)
		{
        $('#editdel').html("<a href=\"javascript:void(0)\" onclick=createad()>Create an Ad</a>&nbsp;&nbsp;&nbsp;");
		}
        $('#mcats').html(data.responseText);
		}
				 });
}
function ChangeCity(create) {
	if(create) {
		$('#country1').html('<img src=icons/busy.gif>');
		$.cookie('country1', null, options);
		$.cookie('region1', null, options);
		$.cookie('city1',  null, options);
         CreateAd();
	}else{
	   $('#country').html('<img src=icons/busy.gif>');
		$.cookie('country', null, options);
		$.cookie('region', null, options);
		$.cookie('city',  null, options);
        $('#country').load('bin/selectcity.php');
 	}
}
function createad() {
	
	   $('#mcats').html('<img src=icons/loading.gif>');
	   
	   if($.cookie('city1') != null){
		   
		 var country = $.cookie('country1');
	    
		var category = $.cookie('region1');
		
		var city = $.cookie('city1');
	   }else{
	   
	   var country = $('#selectCountry1').val();
	    
		var category = $('#selectRegion1').val();
		
		var city = $('#selectCity1').val();
	   }
		
		var datastring = 'reg='+category+'&country='+country+'&type=create&city='+city;

	      $.ajax({



        type: "POST", url: "bin/mcats.php",



        data: datastring,



        complete: function(data) {

        $('#adlis').load('bin/adcat.php');
        $('#mcats').html(data.responseText);
		
		}
				 });
}
function editad() {
	
	   $('#mcats').html('<img src=icons/loading.gif>');
	   
	   var country = $('#selectCountry').val();
	    
		var category = $('#selectRegion').val();
		
		var city = $('#selectCity').val();
		
		var datastring = 'reg='+category+'&country='+country+'&type=edit&city='+city;

	      $.ajax({



        type: "POST", url: "bin/mcats.php",



        data: datastring,



        complete: function(data) {

        $('#editlist').load('bin/edcat.php');
        $('#mcats').html(data.responseText);
		
		}
				 });
}
function editlis(catname) {
	/*
	   $('#mcats').html('<img src=icons/loading.gif>');
	   
	   var country = $('#selectCountry').val();
	    
		var category = $('#selectRegion').val();
		var city = $('#selectCity').val();
		alert($('#selectEditcat').val());
		var datastring = 'state='+category+'&country='+country+'&catname='+catname+'&city='+city;

	      $.ajax({



        type: "POST", url: "login.php",



        data: datastring,



        complete: function(data) {


        $('#mcats').html(data.responseText);
		
		}
				 });
		  */
		  specialcat = catname;
		
		  	$.blockUI.defaults.css.width = '310px'; 
			
	$.blockUI.defaults.css.cursor = 'default';  
    $.blockUI.defaults.overlayCSS.cursor = 'default';  
	$.blockUI({ message: $('#login') });

}
function closes()
{
	$.unblockUI();
}
function adlis(catname) {
	
	   $('#mcats').html('<img src=icons/loading.gif>');
	   
	   if($.cookie('city1') != null){
		   
		 var country = $.cookie('country1');
	    
		var category = $.cookie('region1');
		
		var city = $.cookie('city1');
	   }else{
	   
	   var country = $('#selectCountry1').val();
	    
		var category = $('#selectRegion1').val();
		
		var city = $('#selectCity1').val();
	   }
		
		var datastring = 'state='+category+'&country='+country+'&catname='+catname+'&city='+city;
		

	      $.ajax({



        type: "POST", url: "bin/forms.php",



        data: datastring,



        complete: function(data) {


        $('#mcats').html(data.responseText);
		
		}
				 });
}
function updatcap(number) {
	
		var caption = $("input#"+number).val();
		var datastring = 'number='+number+'&caption='+caption;
		$("input#"+number).attr({disabled:true, value:caption});

	      $.ajax({



        type: "POST", url: "bin/caption.php",



        data: datastring,



        complete: function(data) {

        $("input#"+number).attr({disabled:false, value:caption});
        $('#s'+number).html(data.responseText);
		
		}
				 });
}
