
/* Crag List  */
$(document).ready(function(){
	$.blockUI.defaults.pageMessage = "";
	//updateFlyerList(1,6);
	//updateCraigList(1,6);
	
	
	 $("#src").click(function () {
      	animatedcollapse.toggle('subDiv');
     });
	 
	 $("#search_text").keypress(function (e) {
		SearchSubmit2(e,1);
	 });
	 
	 $("#frmSearch_Class").submit(function() {
		checkSubmission();
	 });


	 getTopMenuCategory();

});



function getTopMenuCategory(){

  document.getElementById("subDiv").innerHTML = "";	

  $.ajax({
	  url: "index-ajax.php?mod=flyer&pg=list.topmenu",
	  cache: false,
	  success: function(html){
	 	document.getElementById("subDiv").innerHTML = html;
	  }
	});
}



function updateCraigList(startIndex,currLimit){
  $('#craigContent').block({ message: null });


  document.getElementById("craigContent").innerHTML = DefMsg;	

  $.ajax({
	  //url: "index-ajax.php?mod=flyer&pg=list.craig&act=list&pageNo="+startIndex+"&limit="+currLimit,
	  url: "index-ajax.php?mod=flyer&pg=list.craig&act=listCraig&pageNo="+startIndex+"&limit="+currLimit,
	  cache: false,
	  success: function(html){
	 	var tempHtml = new Array();
		tempHtml = html.split('|');

		document.getElementById("craigContent").innerHTML = html;
		//document.getElementById("craigPaging").innerHTML  = tempHtml[1];
		$('#craigContent').unblock(); 
	  }
	});
}



/* Crag List  */




function updateFlyerList(startIndex,currLimit){
  $('#flyerContent').block({ message: null });
  document.getElementById("flyerContent").innerHTML = DefMsg;	


  $.ajax({
	  url: "index-ajax.php?mod=flyer&pg=list.craig&act=listMemlist&pageNo="+startIndex+"&limit="+currLimit,
	  cache: false,
	  success: function(html){
	 	var tempHtml = new Array();
		tempHtml = html.split('|');
		document.getElementById("flyerContent").innerHTML = html;
		//document.getElementById("flyerPaging").innerHTML  = tempHtml[1];
		$('#flyerContent').unblock(); 
	  }
	});
}

animatedcollapse.addDiv('subDiv', 'fade=2,height=120')
animatedcollapse.init()
function disp(des)
{
	var data = 'In '+des;
	var category = '';
	document.getElementById("src").innerHTML=data;
	/* Code for the category URL in the slide menu */
		if(des == 'Cars & Vehicles')
		{
			category = 'vehicle';
		}
		else if(des == 'Real Estate')
		{
			category = 'housing/sale';
		}
		else if(des == 'Property For Rent')
		{
			category = 'housing/rent';
		}
		else if(des == 'Jobs')
		{
			category = 'job';
		}
		else if(des == 'Personals')
		{
			category = 'personals';
		}
		else if(des == 'Items for Sale')
		{
			category = 'sale';
		}
		else if(des == 'Pets')
		{
			category = 'sale/pet';
		}
		else if(des == 'Tickets')
		{
			category = 'sale/tickets';
		}
		else if(des == 'Services')
		{
			category = 'service';
		}
	/* End of code for the slide menu */
	

	document.getElementById("cat_val").value = category;
	
	animatedcollapse.hide('subDiv');
}
function submit_classified()
{
	
	//document.frmSearch_Class.action = search_classifed_link;
	//document.frmSearch_Class.submit();
	if(document.getElementById("cat_val").value == '')
	{
		searchFlyer();
	}
	else if(document.getElementById("cat_val").value == 'all')
	{
		document.getElementById("cat_val").value = '';
		//document.frmSearch_Class.action = search_classifed_link;
		document.frmSearch_Class.submit();
	}
	else
	{
		//document.frmSearch_Class.action = search_classifed_link;
		document.frmSearch_Class.submit();
	}
}
function SearchSubmit(e,num)  
	{
		var keynum;
		var keychar;
		var numcheck;
		var url;
		
		if(window.event) // IE
		 {
		  keynum = e.keyCode;
		 }
		else if(e.which) // Netscape/Firefox/Opera
		  {
		  keynum = e.which;
		  }
		  if(keynum=='13')
		  {
		 document.fname.submit();
			 return true;
		  }
		 	
	}
	function SearchSubmit2(e,num)  
	{
		var keynum;
		var keychar;
		var numcheck;
		var url;
		
		if(window.event) // IE
		 {
		  keynum = e.keyCode;
		 }
		else if(e.which) // Netscape/Firefox/Opera
		  {
		  keynum = e.which;
		  }
		  if(keynum=='13')
		  {
			if(document.getElementById("cat_val").value == '')
			{
				
			searchFlyer();
			return false;
			}
			else
			{
			submit_classified();
			 return false;
			}
		  }
		 	
	}
function validlogin(e,num)
	{
	
		var keynum;
		
		if(window.event) // IE
		 {
		  keynum = e.keyCode;
		  
		 }
		else if(e.which) // Netscape/Firefox/Opera
		  {
		  keynum = e.which;
		  
		  }
		  
		  if(keynum=='13'|| num=='13' )
		  {
		  	
			 document.fname.submit();
			 return true;
		  }
		  return false;
		 	
	}

function searchFlyer()
{
	if(document.getElementById("search_text").value == '')
	{
		alert("Enter Listing ID");
		document.getElementById("search_text").focus();
	}
	else
	{	var flyer_id = document.getElementById("search_text").value;
		var str = '&search_flyer_id='+flyer_id;
		search_page_link += str;
		window.open(search_page_link);
		return false;
	}
}
function checkSubmission()
{
	if(document.getElementById("cat_val").value == '')
	{
		return false;
	}
}
function disp1(des)
{
	if(des == '')
	{
		document.getElementById("src").innerHTML="Listing ID";
	}
	else
	{
		var data = 'In '+des;
		document.getElementById("src").innerHTML=data;
	}
	var category = '';
	
	/* Code for the category URL in the slide menu */
		if(des == 'Cars & Vehicles')
		{
			category = 'vehicle';
		}
		else if(des == 'Real Estate')
		{
			category = 'housing/sale';
		}
		else if(des == 'Property For Rent')
		{
			category = 'housing/rent';
		}
		else if(des == 'Jobs')
		{
			category = 'job';
		}
		else if(des == 'Personals')
		{
			category = 'personals';
		}
		else if(des == 'Items for Sale')
		{
			category = 'sale';
		}
		else if(des == 'Pets')
		{
			category = 'sale/pet';
		}
		else if(des == 'Tickets')
		{
			category = 'sale/tickets';
		}
		else if(des == 'Services')
		{
			category = 'service';
		}
		else if(des == 'All Categories')
		{
			category = 'all';
		}
		
	/* End of code for the slide menu */
	

	document.getElementById("cat_val").value = category;
	
	animatedcollapse.hide('subDiv');
}
function check_val()
{
	if(document.getElementById("cat_val").value == '')
	{				 	
		return false;
	}
	else
	{ 
		submit_classified();
		return true;
	}
}
//-->

/* Latest Listings */
function updateFlyerListold(startIndex,currLimit){
  $('#flyerContent').block({ message: null });
  document.getElementById("flyerContent").innerHTML = DefMsg;	

  if(document.getElementById('searchkey').value == 'Search Our Members Classifieds')   {
 	 var searchKey =   '';   }
  else   {
 	 var searchKey =   document.getElementById("searchkey").value;   }
  $.ajax({
	  url: "index-ajax.php?mod=flyer&pg=list.newlist&act=list&pageNo="+startIndex+"&limit="+currLimit+"&searchkey="+searchKey,
	  cache: false,
	  success: function(html){
	 	var tempHtml = new Array();
		tempHtml = html.split('|');
		document.getElementById("flyerContent").innerHTML = tempHtml[0];
		document.getElementById("flyerPaging").innerHTML  = tempHtml[1];
		$('#flyerContent').unblock(); 
	  }
	});
}
function clearSearchList(default_tips)
{
	if(document.getElementById('searchkey').value == default_tips)
	{
		document.getElementById('searchkey').value =	'';
	}
}
function submitsearch()
{
	if(document.getElementById('searchkey').value != '') { 
	document.frm_newlisting.submit();
	}
}


function reload_latest()
{
	var str	=	document.getElementById('searchkey').value;
	var len	=	str.length;
	if(len > 2 ) {
	updateFlyerList(1,6);
	}
	else
	{
		if(str == '') {
			updateFlyerList(1,6);
		}
	}
}
function loginfrmsubmit(){
	document.fname.submit();
	return true;
}
animatedcollapse.addDiv('login_div')
animatedcollapse.init()

/*function loginfacebook(facebook_loginlink) {
	alert(facebook_loginlink);
	FB.Connect.requireSession(function() { location.href=facebook_loginlink});
}
function initFB() {
	FB_RequireFeatures(["XFBML"], function(){
		FB.init(facebook_key, site_url+"/resource/xd_receiver.htm");
	});
}
	
function login()
    {
        FB.Connect.requireSession();
        FB.Facebook.get_sessionState().waitUntilReady(function()
        {
            window.location = url;
        });
    }
*/

/* end latest listings*/

