$(document).ready(function() {

	$('.submenu').hide();
	
	
	$('div#menu > ul > li').live('mouseenter',function(event) {
	
		$(this).children('.submenu').show();
	
	});
	
	$('div#menu > ul > li').live('mouseleave',function(event) {
	
		$(this).children('.submenu').hide();
	
	});
	
	$('.search_item').live('mouseenter',function(event) {
	
		$(this).css('background-color', '#bccbd3');
	
	});
	
	$('.search_item').live('mouseleave',function(event) {
	
		$(this).css('background-color', '#FFFFFF');
	
	});
	
	
	$('.text').live('focusin',function(event) {
	
		if(this.value == "Search"){
			this.value = "";
		}
	
	});
	
	$('.text').live('focusout',function(event) {
	
		if(this.value == ""){
			this.value = "Search";
		}
	
	});
	
	$('#search_btn').live('click',function(event) {
	
		var value = $('#search_field').val();
		
		if(value == "Search" || value == ""){
			return false;
		} else {
			return true;
		}
	
	});
	
});


function ajaxresponse(url, divid, hidePreloader) {
	
	document.body.style.cursor = "wait";
	
	if (divid != "" && hidePreloader != true) {
		$('#'+divid).html('<img src="/app/design/backend/default/skin/img/preload.gif"/>');
	}
	
	$.ajax({
		type: "POST",
		url: url,
		data: "name=John&location=Boston",
		success: function(data){
		
			document.body.style.cursor = "default";
			
			// data
			$('#'+divid).html(data);
			
		},
		error: function(){
			
			document.body.style.cursor = "default";
			
			$('#'+divid).html('An error occurred, with response: '+data);
		
		}
	});


}


function sonitor_change_news(page, total){
	var page = parseInt(page);
	var total = parseInt(total);
	if(page >= 1 && page <= total){
		ajaxresponse("/api/ajax/type/newscontent?page=" + page, "news_change", true);
	}
	return false;
}


