// JavaScript Document

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupTyreStatus=0;


//loading popup with jQuery magic!
function loadPopupTyre(){
	//loads popup only if it is disabled
	if(popupTyreStatus==0){
		$("#backgroundPopupTyre").css({
			"opacity": "0.7"
		});
		$("#backgroundPopupTyre").fadeIn("slow");
		$("#popupTyre").fadeIn("slow");
		popupTyreStatus = 1;
	}
		

}
//disabling popup with jQuery magic!
function disablePopupTyre(){
	//disables popup only if it is enabled
	if(popupTyreStatus==1){
		$("#backgroundPopupTyre").fadeOut("slow");
		$("#popupTyre").fadeOut("slow");
		popupTyreStatus = 0;
	}
		
}
//centering popup
function centerPopupTyre(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupTyre").height();
	var popupWidth = $("#popupTyre").width();
	//centering
	$("#popupTyre").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	$("#backgroundPopupTyre").css({
		"height": windowHeight
	});
		$("#backgroundPopupTyre").css({
		"height": windowHeight
	});
	
}

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupExhaustStatus=0;


//loading popup with jQuery magic!
function loadPopupExhaust(){
	//loads popup only if it is disabled
	if(popupExhaustStatus==0){
		$("#backgroundPopupExhaust").css({
			"opacity": "0.7"
		});
		$("#backgroundPopupExhaust").fadeIn("slow");
		$("#popupExhaust").fadeIn("slow");
		popupExhaustStatus = 1;
	}
		

}
//disabling popup with jQuery magic!
function disablePopupExhaust(){
	//disables popup only if it is enabled
	if(popupExhaustStatus==1){
		$("#backgroundPopupExhaust").fadeOut("slow");
		$("#popupExhaust").fadeOut("slow");
		popupExhaustStatus = 0;
	}
		
}
//centering popup
function centerPopupExhaust(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupExhaust").height();
	var popupWidth = $("#popupExhaust").width();
	//centering
	$("#popupExhaust").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	$("#backgroundPopupExhaust").css({
		"height": windowHeight
	});
		$("#backgroundPopupExhaust").css({
		"height": windowHeight
	});
	
}

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupBatteryStatus=0;


//loading popup with jQuery magic!
function loadPopupBattery(){
	//loads popup only if it is disabled
	if(popupBatteryStatus==0){
		$("#backgroundPopupBattery").css({
			"opacity": "0.7"
		});
		$("#backgroundPopupBattery").fadeIn("slow");
		$("#popupBattery").fadeIn("slow");
		popupBatteryStatus = 1;
	}
		

}
//disabling popup with jQuery magic!
function disablePopupBattery(){
	//disables popup only if it is enabled
	if(popupBatteryStatus==1){
		$("#backgroundPopupBattery").fadeOut("slow");
		$("#popupBattery").fadeOut("slow");
		popupBatteryStatus = 0;
	}
		
}
//centering popup
function centerPopupBattery(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupBattery").height();
	var popupWidth = $("#popupBattery").width();
	//centering
	$("#popupBattery").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	$("#backgroundPopupBattery").css({
		"height": windowHeight
	});
		$("#backgroundPopupBattery").css({
		"height": windowHeight
	});
	
}

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupBrakesStatus=0;


//loading popup with jQuery magic!
function loadPopupBrakes(){
	//loads popup only if it is disabled
	if(popupBrakesStatus==0){
		$("#backgroundPopupBrakes").css({
			"opacity": "0.7"
		});
		$("#backgroundPopupBrakes").fadeIn("slow");
		$("#popupBrakes").fadeIn("slow");
		popupBrakesStatus = 1;
	}
		

}
//disabling popup with jQuery magic!
function disablePopupBrakes(){
	//disables popup only if it is enabled
	if(popupBrakesStatus==1){
		$("#backgroundPopupBrakes").fadeOut("slow");
		$("#popupBrakes").fadeOut("slow");
		popupBrakesStatus = 0;
	}
		
}
//centering popup
function centerPopupBrakes(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupBrakes").height();
	var popupWidth = $("#popupBrakes").width();
	//centering
	$("#popupBrakes").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	$("#backgroundPopupBrakes").css({
		"height": windowHeight
	});
		$("#backgroundPopupBrakes").css({
		"height": windowHeight
	});
	
}



$(document).ready(function(){
//LOADING POPUP
	//Click the button event!
	$("#tyre").click(function(){
						
		//centering with css
		centerPopupTyre();
		//load popup
		loadPopupTyre("#popupTyre");
	});
		
	//CLOSING POPUP
	//Click the x event!
	$("#popupTyreClose").click(function(){
		disablePopupTyre();
	});
	//Click out event!
	$("#backgroundPopupTyre").click(function(){
		disablePopupTyre();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupTyre==1 ){
			disablePopupTyre();
		}
	});
	
	$("#Exhaust").click(function(){
						
		//centering with css
		centerPopupExhaust();
		//load popup
		loadPopupExhaust("#popupExhaust");
	});
		
	//CLOSING POPUP
	//Click the x event!
	$("#popupExhaustClose").click(function(){
		disablePopupExhaust();
	});
	//Click out event!
	$("#backgroundPopupExhaust").click(function(){
		disablePopupExhaust();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupExhaust==1 ){
			disablePopupExhaust();
		}
	});
	
		//Click the button event!
	$("#Battery").click(function(){
						
		//centering with css
		centerPopupBattery();
		//load popup
		loadPopupBattery("#popupBattery");
	});
		
	//CLOSING POPUP
	//Click the x event!
	$("#popupBatteryClose").click(function(){
		disablePopupBattery();
	});
	//Click out event!
	$("#backgroundPopupBattery").click(function(){
		disablePopupBattery();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupBattery==1 ){
			disablePopupBattery();
		}
	});
	
		//Click the button event!
	$("#Brakes").click(function(){
						
		//centering with css
		centerPopupBrakes();
		//load popup
		loadPopupBrakes("#popupBrakes");
	});
		
	//CLOSING POPUP
	//Click the x event!
	$("#popupBrakesClose").click(function(){
		disablePopupBrakes();
	});
	//Click out event!
	$("#backgroundPopupBrakes").click(function(){
		disablePopupBrakes();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupBrakes==1 ){
			disablePopupBrakes();
		}
	});
	
});
