var temp='';
var temp1='';
// JavaScript Document
$(function() {
   $('#Laptop-Tabs').tabs();
   });
$(document).ready(function(){

	//References
	var pages = $("#laptop_menu li");
//	var pages1 = $("#menu1 li");
	var loading = $("#loading");
	var content = $("#content");
	var extra1 = $("#b_name").html();
	var extra2 = $("#b_price").html();
	var extra3 = $("#b_processor").html();
	var extra4 = $("#b_memory").html();
  var price = $("#price li");
  var processor = $("#processor li");
  var memory = $("#memory li");
  var hdd = $("#hdd li");
  var display = $("#display li");
  var graphics = $("#graphics li");
  var os = $("#os li");
  var application = $("#application li");
  var p_weight = $("#p_weight li");
  var extra = $("#extra li");
  var pagessearch=$("#menu-search li");
  
  
price.click(function(){ 
		//show the loading bar
  	getoverlayfun();
	
		//Highlight current page number
		price.css({'font-weight' : ''});
		processor.css({'font-weight' : ''});
		hdd.css({'font-weight' : ''});
		display.css({'font-weight' : ''});
		graphics.css({'font-weight' : ''});
		os.css({'font-weight' : ''});
		application.css({'font-weight' : ''});
		p_weight.css({'font-weight' : ''});
    extra.css({'font-weight' : ''});
    memory.css({'font-weight' : ''});
    //pages.css({'font-weight' : '','border':''});
		
		$(this).css({'font-weight' : 'bold'});
   	//Load content
		var price_value = this.id;
	//	param=pageNum.split("-");
		var targetUrl = "laptop_content.php?page=" +1 + "&tab=laptop_products&price="+price_value;
		var countUrl = "laptop_count.php?page=" +1 + "&tab=laptop_products&price="+price_value;
    window.scrollTo(0,0);
  	$("#lap_content").load(targetUrl, finish);
	  $("#pagination").load(countUrl);
	  $('#laptopTabs').triggerTab(4);

	});

processor.click(function(){ 
		//show the loading bar
		getoverlayfun();
		
		//Highlight current page number
	  price.css({'font-weight' : ''});
		processor.css({'font-weight' : ''});
		hdd.css({'font-weight' : ''});
		display.css({'font-weight' : ''});
		graphics.css({'font-weight' : ''});
		os.css({'font-weight' : ''});
		application.css({'font-weight' : ''});
		p_weight.css({'font-weight' : ''});
    extra.css({'font-weight' : ''});
    memory.css({'font-weight' : ''});
    //pages.css({'font-weight' : '','border':''});
		
		$(this).css({'font-weight' : 'bold'});
   	//Load content
		var processor_value = this.id;
	//	param=pageNum.split("-");
		var targetUrl = "laptop_content.php?page=" +1 + "&tab=laptop_products&processor="+processor_value;
		var countUrl = "laptop_count.php?page=" +1 + "&tab=laptop_products&processor="+processor_value;
		window.scrollTo(0,0);
	$("#lap_content").load(targetUrl, finish);
	$("#pagination").load(countUrl);
  $('#laptopTabs').triggerTab(4);
 });	

hdd.click(function(){ 
		//show the loading bar
		getoverlayfun();
		
		//Highlight current page number
		price.css({'font-weight' : ''});
		processor.css({'font-weight' : ''});
		hdd.css({'font-weight' : ''});
		display.css({'font-weight' : ''});
		graphics.css({'font-weight' : ''});
		os.css({'font-weight' : ''});
		application.css({'font-weight' : ''});
		p_weight.css({'font-weight' : ''});
    extra.css({'font-weight' : ''});
    memory.css({'font-weight' : ''});
    //pages.css({'font-weight' : '','border':''});
		$(this).css({'font-weight' : 'bold'});
   	//Load content
		var hdd_value = this.id;
	//	param=pageNum.split("-");
		var targetUrl = "laptop_content.php?page=" +1 + "&tab=laptop_products&harddrive="+hdd_value;
		var countUrl = "laptop_count.php?page=" +1 + "&tab=laptop_products&harddrive="+hdd_value;
		window.scrollTo(0,0);
	$("#lap_content").load(targetUrl, finish);
	$("#pagination").load(countUrl);
  $('#laptopTabs').triggerTab(4);
 });	

display.click(function(){ 
		//show the loading bar
		getoverlayfun();
		
		//Highlight current page number
		price.css({'font-weight' : ''});
		processor.css({'font-weight' : ''});
		hdd.css({'font-weight' : ''});
		display.css({'font-weight' : ''});
		graphics.css({'font-weight' : ''});
		os.css({'font-weight' : ''});
		application.css({'font-weight' : ''});
		p_weight.css({'font-weight' : ''});
    extra.css({'font-weight' : ''});
    memory.css({'font-weight' : ''});
    //pages.css({'font-weight' : '','border':''});
		$(this).css({'font-weight' : 'bold'});
   	//Load content
		var display_value = this.id;
	//	param=pageNum.split("-");
		var targetUrl = "laptop_content.php?page=" +1 + "&tab=laptop_products&display="+display_value;
		var countUrl = "laptop_count.php?page=" +1 + "&tab=laptop_products&display="+display_value;
	window.scrollTo(0,0);
	$("#lap_content").load(targetUrl, finish);
	$("#pagination").load(countUrl);
  $('#laptopTabs').triggerTab(4);
 });	

graphics.click(function(){ 
		//show the loading bar
		getoverlayfun();
		
		//Highlight current page number
		price.css({'font-weight' : ''});
		processor.css({'font-weight' : ''});
		hdd.css({'font-weight' : ''});
		display.css({'font-weight' : ''});
		graphics.css({'font-weight' : ''});
		os.css({'font-weight' : ''});
		application.css({'font-weight' : ''});
		p_weight.css({'font-weight' : ''});
    extra.css({'font-weight' : ''});
    memory.css({'font-weight' : ''});
    //pages.css({'font-weight' : '','border':''});
		$(this).css({'font-weight' : 'bold'});
   	//Load content
		var graphics_value = this.id;
	//	param=pageNum.split("-");
		var targetUrl = "laptop_content.php?page=" +1 + "&tab=laptop_products&graphic="+graphics_value;
		var countUrl = "laptop_count.php?page=" +1 + "&tab=laptop_products&graphic="+graphics_value;
		window.scrollTo(0,0);
	$("#lap_content").load(targetUrl, finish);
	$("#pagination").load(countUrl);
  $('#laptopTabs').triggerTab(4);
 });	
 
 os.click(function(){ 
		//show the loading bar
		getoverlayfun();
		
		//Highlight current page number
		price.css({'font-weight' : ''});
		processor.css({'font-weight' : ''});
		hdd.css({'font-weight' : ''});
		display.css({'font-weight' : ''});
		graphics.css({'font-weight' : ''});
		os.css({'font-weight' : ''});
		application.css({'font-weight' : ''});
		p_weight.css({'font-weight' : ''});
    extra.css({'font-weight' : ''});
    memory.css({'font-weight' : ''});
    //pages.css({'font-weight' : '','border':''});
		$(this).css({'font-weight' : 'bold'});
   	//Load content
		var os_value = this.id;
	//	param=pageNum.split("-");
		var targetUrl = "laptop_content.php?page=" +1 + "&tab=laptop_products&os="+os_value;
		var countUrl = "laptop_count.php?page=" +1 + "&tab=laptop_products&os="+os_value;
	window.scrollTo(0,0);
	$("#lap_content").load(targetUrl, finish);
	$("#pagination").load(countUrl);
  $('#laptopTabs').triggerTab(4);
 });

 application.click(function(){ 
		//show the loading bar
		getoverlayfun();
		
		//Highlight current page number
		price.css({'font-weight' : ''});
		processor.css({'font-weight' : ''});
		hdd.css({'font-weight' : ''});
		display.css({'font-weight' : ''});
		graphics.css({'font-weight' : ''});
		os.css({'font-weight' : ''});
		application.css({'font-weight' : ''});
		p_weight.css({'font-weight' : ''});
    extra.css({'font-weight' : ''});
    memory.css({'font-weight' : ''});
    //pages.css({'font-weight' : '','border':''});
		$(this).css({'font-weight' : 'bold'});
   	//Load content
		var application_value = this.id;
	//	param=pageNum.split("-");
		var targetUrl = "laptop_content.php?page=" +1 + "&tab=laptop_products&application="+application_value;
		var countUrl = "laptop_count.php?page=" +1 + "&tab=laptop_products&application="+application_value;
	window.scrollTo(0,0);
	$("#lap_content").load(targetUrl, finish);
	$("#pagination").load(countUrl);
  $('#laptopTabs').triggerTab(4);
 });


p_weight.click(function(){ 
		//show the loading bar
		getoverlayfun();
		
		//Highlight current page number
		price.css({'font-weight' : ''});
		processor.css({'font-weight' : ''});
		hdd.css({'font-weight' : ''});
		display.css({'font-weight' : ''});
		graphics.css({'font-weight' : ''});
		os.css({'font-weight' : ''});
		application.css({'font-weight' : ''});
		p_weight.css({'font-weight' : ''});
    extra.css({'font-weight' : ''});
    memory.css({'font-weight' : ''});
    //pages.css({'font-weight' : '','border':''});
		$(this).css({'font-weight' : 'bold'});
   	//Load content
		var p_weight_value = this.id;
	//	param=pageNum.split("-");
		var targetUrl = "laptop_content.php?page=" +1 + "&tab=laptop_products&weights="+p_weight_value;
		var countUrl = "laptop_count.php?page=" +1 + "&tab=laptop_products&weights="+p_weight_value;
	window.scrollTo(0,0);
	$("#lap_content").load(targetUrl, finish);
	$("#pagination").load(countUrl);
  $('#laptopTabs').triggerTab(4);
 });

extra.click(function(){ 
		//show the loading bar
		getoverlayfun();
		
		//Highlight current page number
		price.css({'font-weight' : ''});
		processor.css({'font-weight' : ''});
		hdd.css({'font-weight' : ''});
		display.css({'font-weight' : ''});
		graphics.css({'font-weight' : ''});
		os.css({'font-weight' : ''});
		application.css({'font-weight' : ''});
		p_weight.css({'font-weight' : ''});
    extra.css({'font-weight' : ''});
    memory.css({'font-weight' : ''});
    //pages.css({'font-weight' : '','border':''});
		$(this).css({'font-weight' : 'bold'});
   	//Load content
		var extra_value = this.id;
	//	param=pageNum.split("-");
		var targetUrl = "laptop_content.php?page=" +1 + "&tab=laptop_products&extra="+extra_value;
		var countUrl = "laptop_count.php?page=" +1 + "&tab=laptop_products&extra="+extra_value;
	window.scrollTo(0,0);
	$("#lap_content").load(targetUrl, finish);
	$("#pagination").load(countUrl);
  $('#laptopTabs').triggerTab(4);
 });

	memory.click(function(){ 
		//show the loading bar
		getoverlayfun();
		
		//Highlight current page number
		price.css({'font-weight' : ''});
		processor.css({'font-weight' : ''});
		hdd.css({'font-weight' : ''});
		display.css({'font-weight' : ''});
		graphics.css({'font-weight' : ''});
		os.css({'font-weight' : ''});
		application.css({'font-weight' : ''});
		p_weight.css({'font-weight' : ''});
    extra.css({'font-weight' : ''});
    memory.css({'font-weight' : ''});
    //pages.css({'font-weight' : '','border':''});
		$(this).css({'font-weight' : 'bold'});
   	//Load content
		var memory_value = this.id;
	//	param=pageNum.split("-");
		var targetUrl = "laptop_content.php?page=" +1 + "&tab=laptop_products&memory="+memory_value;
		var countUrl = "laptop_count.php?page=" +1 + "&tab=laptop_products&memory="+memory_value;
	window.scrollTo(0,0);
	$("#lap_content").load(targetUrl, finish);
	$("#pagination").load(countUrl);
  $('#laptopTabs').triggerTab(4);
      
	
	});	
		pages.click(function(){
		//show the loading bar
	//	showLoading();
		getoverlayfun();
		//Highlight current page number
		pages.css({'font-weight' : '','border':''});
		$(this).css({'font-weight' : 'bold','border':'1px solid #8e8e8e'});

		//Load content
		var pageNum = this.id;
		param=pageNum.split("-");
		var targetUrl = "laptop_content.php?page=" +param[0] + "&tab=laptop_products";
	//	content.load(targetUrl, hideLoading);
	window.scrollTo(0,0);
	$("#laptops_content").load(targetUrl, finish);
	});
	
	pagessearch.click(function(){
	  getoverlayfun();
    pagessearch.css({'font-weight' : '','border':''});
		$(this).css({'font-weight' : 'bold','border':'1px solid #8e8e8e'});
		var param=$("#get_url").html();
    var request="laptop_content.php?pages=" + this.id+ "&tab=laptop_products&perpage=5&"+param;
    window.scrollTo(0,0);
    $("#laptop_content").load(request,finish);
    });
/*	  pages.click(function(){
		//show the loading bar
		showLoading();
		
		//Highlight current page number
		price.css({'font-weight' : ''});
		processor.css({'font-weight' : ''});
		hdd.css({'font-weight' : ''});
		display.css({'font-weight' : ''});
		graphics.css({'font-weight' : ''});
		os.css({'font-weight' : ''});
		application.css({'font-weight' : ''});
		p_weight.css({'font-weight' : ''});
    extra.css({'font-weight' : ''});
    memory.css({'font-weight' : ''});
    //pages.css({'font-weight' : '','border':''});
		$(this).css({'font-weight' : 'bold','border':'1px solid #8e8e8e'});

		//Load content
		var pageNum = this.id;
		param=pageNum.split("-");
		var targetUrl = "laptop_content.php?page=" + param[1]+"&tab=laptop_products";
	//	var targetUrl = "laptop_count.php?page=" +param[1] + "&tab=laptop_products&price=&brand=&processor=&memory=";
		$("#all_lap_content").load(targetUrl);
	});
	*/
	//show loading bar
	function showLoading(){
		loading
			.css({visibility:"visible"})
			.css({opacity:"1"})
			.css({display:"block"})
		;
	}
	//hide loading bar
	function hideLoading(){
		loading.fadeTo(1000, 0);
	};
	
function getoverlayfun(){
//$('body').append('<div id="jquery-overlay"></div>');
var arrPageSizes = getPageSize1();
			// Style overlay and show it
			$('#jquery-overlay').css({
				backgroundColor:	'#000',
				opacity:			'0.2',
				width:				arrPageSizes[0],
				height:				arrPageSizes[1]
			}).fadeIn();
}

		function getPageSize1() {
			var xScroll, yScroll;
			if (window.innerHeight && window.scrollMaxY) {	
				xScroll = window.innerWidth + window.scrollMaxX;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			var windowWidth, windowHeight;
			if (self.innerHeight) {	// all except Explorer
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth; 
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) { // other Explorers
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}	
			// for small pages with total height less then height of the viewport
			if(yScroll < windowHeight){
				pageHeight = windowHeight;
			} else { 
				pageHeight = yScroll;
			}
			// for small pages with total width less then width of the viewport
			if(xScroll < windowWidth){	
				pageWidth = xScroll;		
			} else {
				pageWidth = windowWidth;
			}
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
			return arrayPageSize;
		};

function finish() {
		//	$('#jquery-overlay').fadeTo(1000, 0);
		var arrPageSizes = getPageSize1();
		$('#jquery-overlay').css("background-position", "top center");
			// Style overlay and show it
		$('#jquery-overlay').hide();
			}
	//Manage click events

	//default - 1st page
/*	$("#laptop_products-1").css({'font-weight' : 'bold','border':'1px solid #8e8e8e'});
//	var targetUrl = "content.php?page=1&" + $("#myForm").serialize() + " #content";
var targetUrl = "laptop_content.php?page=" +1 + "&tab=laptop_products"+"&brand="+extra1+"&price="+extra2+"&processor="+extra3+"&memory="+extra4;
	showLoading();
	content.load(targetUrl, hideLoading);*/
});
function ajaxPaging(pagess) {
getoverlayfun();
 var mysplit=pagess.split("-");
	if(temp!='')$("#"+temp).css({'font-weight' : '','border':''});
	 $("#1-"+mysplit[1]+'-'+mysplit[2]).css({'font-weight' : '','border':''});
	$("#"+pagess).css({'font-weight' : 'bold','border':'1px solid #8e8e8e'});
temp=pagess;

var targetUrl = "laptop_content.php?page=" + mysplit[0]+ "&tab=laptop_products&brand=";
//		var targetUrl = "laptop_content.php?page=" + mysplit1[0] + "&tab=laptop_products&brand=&price="+mysplit1[1]+"&processor=&memory=";
if(mysplit[1]=="processor"){
 targetUrl+="&processor="+mysplit[2];
 }else{
 targetUrl+="&processor=";
 }
 if(mysplit[1]=="price"){
 targetUrl+="&price="+mysplit[2];
 }else{
 targetUrl+="&price=";
 }
 if(mysplit[1]=="memory"){
 targetUrl+="&memory="+mysplit[2];
 }else{
 targetUrl+="&memory=";
 }
 if(mysplit[1]=="harddrive"){
 targetUrl+="&harddrive="+mysplit[2];
 }else{
 targetUrl+="&harddrive=";
 }
 if(mysplit[1]=="display"){
 targetUrl+="&display="+mysplit[2];
 }else{
 targetUrl+="&display=";
 }
 if(mysplit[1]=="graphic"){
 targetUrl+="&graphic="+mysplit[2];
 }else{
 targetUrl+="&graphic=";
 }
 if(mysplit[1]=="graphics"){
 targetUrl+="&graphics="+mysplit[2];
 }else{
 targetUrl+="&graphics=";
 }
 if(mysplit[1]=="os"){
 targetUrl+="&os="+mysplit[2];
 }else{
 targetUrl+="&os=";
 }
 if(mysplit[1]=="application"){
 targetUrl+="&application="+mysplit[2];
 }else{
 targetUrl+="&application=";
 }
 if(mysplit[1]=="weight"){
 targetUrl+="&weights="+mysplit[2];
 }else{
 targetUrl+="&weights=";
 }
 if(mysplit[1]=="extra"){
 targetUrl+="&extra="+mysplit[2];
 }else{
 targetUrl+="&extra=";
 }
 if(mysplit[1]=="perpage"){
 targetUrl+="&perpage="+mysplit[2];
 		$("#laptops_content").load(targetUrl);
 }
 else{
	//	var targetUrl = "laptop_content.php?page=" + mysplit[0] + "&tab=laptop_products&brand=&price=&processor=&memory=";
	window.scrollTo(0,0);
		$("#lap_content").load(targetUrl,finish());
//		 $('#Laptop-searchTab').tabs(3);
 $('#laptopTabs').triggerTab(4);
 }
	}
	
	function ajaxPaging1(pag) {
	getoverlayfun();
	$("#laptop-1").css({'font-weight' : '','border':''});
	if(temp1!='')$("#"+temp1).css({'font-weight' : '','border':''});
	else $("#laptop-1").css({'font-weight' : '','border':''});
	var spliter=pag.split("-");
  $("#"+pag).css({'font-weight' : 'bold','border':'1px solid #8e8e8e'});
temp1=pag;
	var targetUrls = "laptop_content.php?tab=laptop_products&mainpage=" +spliter[1];
//		var countUrl = "laptop_count.php?page=" +1 + "&tab=laptop_products";
  	window.scrollTo(0,0);
	$("#all_lap_content").load(targetUrls,finish());
	}
function getoverlayfun(){
//$('body').append('<div id="jquery-overlay"></div>');
var arrPageSizes = getPageSize1();
			// Style overlay and show it
			$('#jquery-overlay').css({
				backgroundColor:	'#000',
				opacity:			'0.2',
				width:				arrPageSizes[0],
				height:				arrPageSizes[1]
			}).fadeIn();
}

		function getPageSize1() {
			var xScroll, yScroll;
			if (window.innerHeight && window.scrollMaxY) {	
				xScroll = window.innerWidth + window.scrollMaxX;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			var windowWidth, windowHeight;
			if (self.innerHeight) {	// all except Explorer
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth; 
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) { // other Explorers
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}	
			// for small pages with total height less then height of the viewport
			if(yScroll < windowHeight){
				pageHeight = windowHeight;
			} else { 
				pageHeight = yScroll;
			}
			// for small pages with total width less then width of the viewport
			if(xScroll < windowWidth){	
				pageWidth = xScroll;		
			} else {
				pageWidth = windowWidth;
			}
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
			return arrayPageSize;
		};

function finish() {
		//	$('#jquery-overlay').fadeTo(1000, 0);
		var arrPageSizes = getPageSize1();
		$('#jquery-overlay').css("background-position", "top center");
			// Style overlay and show it
		$('#jquery-overlay').hide();
			}