﻿$(document).ready(function(){
	if($.browser.msie && $.browser.version == 6){
		$(window).resize(function(){
			if($(document).width() > 1200){
				$('.wrapper').css({
					width: 1200
				})
			}
		});
		$(window).resize();
	}
	$('.price tr:nth-child(odd)').addClass('odd');
	
	$('.menu a').click(function(){
		if($(this).parent('li').is('.active')){
			$(this).parent('li').removeClass('active');
		}else{
			$(this).parent('li').siblings().removeClass('active');
			$(this).parent('li').addClass('active');
		}
		return false;
	})
	$(document).click(function(e){
		if (!$(e.target).parents('.popup').length){
			$('.menu li.active').removeClass('active');
		}
	});

	if ($("#swf1").length)
	{
		var att = { data:"/swf1.swf", width:"70", height:"57" };
		var par = {
			menu:"true",
			quality:"high",
			wmode:"transparent",
			bgcolor: "#000000"
		};
		var id = "swf1";
		var myObject = swfobject.createSWF(att, par, id);
	}
	
	if ($("#swf2").length)
	{
		var att = { data:"/swf2.swf", width:"70", height:"55" };
		var par = {
			menu:"true",
			quality:"high",
			wmode:"transparent",
			bgcolor: "#000000"
		};
		var id = "swf2";
		var myObject = swfobject.createSWF(att, par, id);
	}
	
	if ($("#swf3").length)
	{
		var att = { data:"/swf3.swf", width:"61", height:"54" };
		var par = {
			menu:"true",
			quality:"high",
			wmode:"transparent",
			bgcolor: "#000000"
		};
		var id = "swf3";
		var myObject = swfobject.createSWF(att, par, id);
	}
	
	calcReload = function()
	{
		// Config Calc
		var minPeople = 1;
		var minHour = 2;
		var hourPrice = 200;
		var carPrice = 350;
		
		// Data
		var peopleCount = $("#peopleCount").val();
		var hourCount = $("#hourCount").val();
		var car = $("#car").attr("checked");		
		
		// Check
		if (peopleCount<=(minPeople-1)) $("#peopleCount").val(minPeople);
		if (peopleCount>=minPeople) $("#peopleCount").val(parseInt(peopleCount));

		if (hourCount<=(minHour-1)) $("#hourCount").val(minHour);
		if (hourCount>=minHour) $("#hourCount").val(parseInt(hourCount));		
		
		// Calc
		peopleCount = $("#peopleCount").val();
		hourCount = $("#hourCount").val();
		
		if (car==true)
			totalPrice = (hourCount * carPrice) + (peopleCount * hourCount * hourPrice);
		else
			totalPrice = peopleCount * hourCount * hourPrice;
			
		$("#price").val(totalPrice);		
	}
	
	$("#orderButton").click(calcReload);	
});
