/**
 * @author Web Dev
 */

 $(function(){
 	
	//---------- NAVIGATION FIX FOR MAIN NAVIGATION -------------
	
	$("#main_nav li[class='head_link']").css({
		'float' : 'left',
	    'margin-left' : '-1px',
	    'text-align' : 'center',
		'position' : 'relative',
		'display' : 'block'
	});
	
	$("#main_nav li[class='head_link']").hover(
	function(){
		$(this).find(".sub_nav").css('display', 'block');	
	},
	function(){
		$(this).find(".sub_nav").css('display', 'none');	
	});
	
	// -------- BIG IE BIG FIX / HACK TO MAKE NAVIGATION WORKABLE IN IE -----------
	
	var version = jQuery.browser.version;
	
	if(navigator.appName == "Microsoft Internet Explorer" && (version <= 7)){
		$(".sub_nav").css({
			'margin-top' : '60px',
			'margin-left' : '-155px'
		});
		$(".last_sub").css("margin-left","-185px");
		$("#content_image").css("margin-top","20px");
		$(".tab_text").css("margin-top","-190px");
		$(".tab_last").css("margin-top","-160px");
		$("#tab_1 li").css("margin", "0px 0px 0px 10px");
	}
	if(navigator.appName == "Microsoft Internet Explorer" && (version == 8)){
		$("#top_head blockquote").css({"margin-top":"50px","margin-left":"20px","width":"600px"});
	}
	if(navigator.appName == "Microsoft Internet Explorer"){
		$(".tabsmix img").css({"float":"none"});
	}
	//---------- THIS WORKS WITH ALL THE TABS ----------
	
	$("#tabs li").click(function(e){
		$(".tabsmix").hide();
		var link = $(this).find('a').attr("class");
		$("#"+link).show();
		$("#tabs li").removeClass("active");
		$(this).addClass("active");
		e.preventDefault();
	});
	
	$(".staff_sub li p").after("<a href='#'>Back To Top</a>");
	$("#pro_content tr:odd").css({"background":"#DAEAED"});
	$("#pro_content tr:even").css({"background":"#EEF4F6"});
	$("#pro_content tr").css({"border":"2px solid #ccc"});
	$("#pro_form input:radio").css({"margin":"0px 10px"});
	
	$("#dload_photo").colorbox();
	$("#price_photo").colorbox();
	$("#dload_calendar").colorbox();
	$("#price_calendar").colorbox();
	
	//--------- THIS WORKS WITH THE PRODUCTS PAGE -------
	$("#product_wrap .product_tip").hide();
	$(".product_box a").click(function(e){
		e.preventDefault();
		
		var nextIndex = $(this).next(".product_tip");	
		nextIndex.fadeIn();
		nextIndex.click(function(){
			$(this).fadeOut(100);
		});
	});
	
	//--------- PRO CATALOG PAGE AJAX AND VALADATION ----
	$("#btn_submit").click(function(e){
		e.preventDefault();
		
		if($(".req1").val() == "" || $(".req2").val() == "" || $(".req3").val() == "" || $(".req4").val() == "" || $(".req5").val() == ""){
			alert("All Required Fields (*) Need To Be Filled In!");
		}
		else{
			$.ajax({
				type: "POST",
				data: $("#pro_form").serialize(),
				url: "catalog.php",
				success: function(msg){
					alert(msg);
					$("form input:text").val("");
				}
			});
		}
	});
	
	//-------- INDEX PAGE SLIDESHOW ---------
	var count = 0;
	$("html").everyTime(3000, "slideshow", function(i){
		// increments the tab number
		if(count > 1){ 
			count = 0;
		}
		count++;
		
		// effect of tabs
		$(".tabsmix").fadeOut(300); 
	 	$("#tab_"+count).fadeIn(500);
		
		// makes the tab active
		$("#tabs li").removeClass("active");
		$(".tab_"+count).parent().addClass("active");
 	});
	$(".tabsmix").hover(function(){
		// on hover stop show
		$("html").stopTime("slideshow");
		
	},function(){
		$("html").everyTime(3000, "slideshow", function(i){
			// increments the tab number
			if(count > 1){
				count = 0;
			}
			count++;
			
			// effect of tabs
			$(".tabsmix").fadeOut(300);
		 	$("#tab_"+count).fadeIn(500);
			
			// makes the tab active
			$("#tabs li").removeClass("active");
			$(".tab_"+count).parent().addClass("active");
		});
	});
	//------- SLIDESHOW END ---------
		
 });

