﻿//-----
//----- start of jQuery exe
//-----
$(document).ready(function(){

	//
	// ie6's png-24 transparency
	//
	$('.rounder div').supersleight();
	$('.rounder2 div').supersleight();
	$('.rounder3 div').supersleight();
	$('#form_quote .fsSubmit input').supersleight();
	//$('.block01 p:last-child').css("padding-bottom:","1px");
	
	
	//
	// menu marking active
	//
	function markActiveLink(menuLink) {

		//Look through all the links in the sidebar
		menuLink.filter(function() {

			//Take the current URL and split it into chunks at each slash
			var currentURL = window.location.toString().split("/");

			//return true if the bit after the last slash is the current page name
			return $(this).attr("href") == currentURL[currentURL.length-1];

			//when the filter function is done, you're left with the links that match.
		}).addClass("active");

	}
	markActiveLink($(".menu1 a"));
	markActiveLink($(".menu2 a"));
	markActiveLink($(".menu3 a"));
	
	
	//
	// menu marking active parent
	//
	function markActiveParent(menuLink) {

		//Look through all the links in the sidebar
		menuLink.filter(function() {

			//Take the current URL and split it into chunks at each slash
			var currentURL = window.location.toString().split("/");

			//return true if the bit after the last slash is the current page name
			if (
				$(this).attr("href") == "local.html" ||
				$(this).attr("href") == "long-distance.html" ||
				$(this).attr("href") == "commercial.html" ||
				$(this).attr("href") == "military.html" ||
				$(this).attr("href") == "local.html" ||
				$(this).attr("href") == "international.html" ||
				$(this).attr("href") == "customs.html" ||
				$(this).attr("href") == "local.html" ||
				$(this).attr("href") == "insurance.html" ||
				$(this).attr("href") == "coverage.html" ||
				$(this).attr("href") == "local.html" ||
				$(this).attr("href") == "special.html" ||
				$(this).attr("href") == "piano.html" ||
				$(this).attr("href") == "art.html" ||
				$(this).attr("href") == "local.html" ||
				$(this).attr("href") == "eviction.html" ||
				$(this).attr("href") == "auto.html"
			) { 
				$(".menu1 a[href='moving.html']").addClass("active");
				$(".menu3 a[href='moving.html']").addClass("active");
			}
			
			else if (
				$(this).attr("href") == "storage-containers.html" ||
				$(this).attr("href") == "storage-piano.html"
			) { 
				$(".menu1 a[href='storage.html']").addClass("active");
				$(".menu3 a[href='storage.html']").addClass("active");
			}
			
			else if (
				$(this).attr("href") == "boxes.html" ||
				$(this).attr("href") == "box-kits.html"
			) { 
				$(".menu1 a[href='packing-and-crating.html']").addClass("active");
				$(".menu3 a[href='packing-and-crating.html']").addClass("active");
			}
			
			else if (
				$(this).attr("href") == "testimonials.html" ||
				$(this).attr("href") == "green.html" ||
				$(this).attr("href") == "promover.html"
			) { 
				$(".menu1 a[href='about-us.html']").addClass("active");
				$(".menu3 a[href='about-us.html']").addClass("active");
			}
			
			else if (
				$(this).attr("href") == "checklist.html" ||
				$(this).attr("href") == "links.html" ||
				$(this).attr("href") == "links-military.html" ||
				$(this).attr("href") == "children.html" ||
				$(this).attr("href") == "pets.html"
			) { 
				$(".menu1 a[href='moving-info.html']").addClass("active");
				$(".menu3 a[href='moving-info.html']").addClass("active");
			}
			
			else if (
				$(this).attr("href") == "contact.html" ||
				$(this).attr("href") == "promotions.html" ||
				$(this).attr("href") == "faqs.html" ||
				$(this).attr("href") == "estimate.html" ||
				$(this).attr("href") == "quote-moving.html" ||
				$(this).attr("href") == "quote-storage.html" ||
				$(this).attr("href") == "callback-request.html" ||
				$(this).attr("href") == "chat.html"
			) { 
				$(".menu1 a[href='customer-service.html']").addClass("active");
				$(".menu3 a[href='customer-service.html']").addClass("active");
			}
			
		})

	}
	markActiveParent($(".menu2 a"));
	if (!$(".menu1 a").hasClass("active")) { //this one is for index.html, when there is no index.html in URL
		$(".menu1 a[href='index.html']").addClass("active");
		$(".menu3 a[href='index.html']").addClass("active");
	}
	
	
	//
	// styling form quote
	//
	$("#form_quote input[type=text]").css('width','94%');//186px - (2px padding + 1px border)*2
	$("#form_quote input[type=text]").css("background-image","url(images/bg-form-input-text.png)");
	//callendar
	$("#form_quote .fsCalendarPickerLink").click( function() {
		$("#form_quote .fsCalendar").css('left','24px');
		$("#form_quote .fsCalendar").css('top','24px');
	});
	//hide button text
	$("#form_quote .fsSubmit input").attr("value","");
	
	
	//
	// quote-storage.html radio inputs show border in all IE versions
	//
	$("input[type=radio]").css({'border' : 'none', 'background' : 'none', 'margin-right' : '4px', 'padding' : '0'});
	
	
	//
	// main columns of equal height
	//
	function equalHeight() {
		heightMain = $(".container_main2").height() - 4;//4 is a padding-top
		var offset = $(".sidebar1 .block01:last").position();
		height = heightMain - offset.top - 24;
		//4px padding-top of .container_main2_inside, then 24 padding-top, 2 padding-bottom, 2 border of .sidebar1 .block01:last
		if ($.browser.msie && $.browser.version.substring(0,1) === '7') {height -= 3;}
		//if ($("#page_home #page_image")) {height = height - $("#page_home #page_image").height() - 3; }
		$(".sidebar1 .block01:last .block_border").css('height',height);
		
		var offset = $(".sidebar2 .block01:last").position();
		height = heightMain - offset.top - 24;
		//4px padding-top of .container_main2_inside, then 24 padding-top, 2 padding-bottom, 2 border of .sidebar1 .block01:last
		if ($.browser.msie && $.browser.version.substring(0,1) === '7') {height -= 3;}
		$(".sidebar2 .block01:last .block_border").css('height',height);
		
		var offset = $(".content .block01:last").position();
		height = heightMain - offset.top - 28;
		//18 padding-top, 12 padding-bottom, 2 border of .sidebar1 .block01:last
		if ($.browser.msie && $.browser.version.substring(0,1) === '7') {height -= 3;}
		//if ($("#page_home #page_image")) {height = height - $("#page_home #page_image").height() - 3; }
		$(".content .block01:last .block_border").css('height',height);
	}
	equalHeight();
	$("#form_quote input[type=submit]").click(function() {
		equalHeight();
		ieCorners();
	});
	
	//
	// bottom round corner for ie6
	//
	function ieCorners () {
		if ($.browser.msie && $.browser.version.substring(0,1) === '6') {
			$(".block01 .bl").each( function (i) {
				var blockHeight = $(this).parent().parent().parent().height();
				$(this).css('top',blockHeight - 11);//10 - 3 708px 719 717 10 
			});
			$(".block01 .br").each( function (i) {
				var blockHeight = $(this).parent().parent().parent().height();
				$(this).css('top',blockHeight - 11);//10 - 3 708px 719 717 10 
			});
		}
	}
	ieCorners();
	
	//
	// ie6. wierd height cutting on pages with form widget
	//
	if ($.browser.msie && $.browser.version.substring(0,1) === '6') {
		var blockHeight = $(".container_main2").height();
		$(".container_main2").css('height',blockHeight)
	}
	
	
	
	
});
//-----
//----- end of jQuery exe
//-----











