// Once document is loaded
$(document).ready(function () {
    /******* Login Block *************/
	$("#login").expandable();

	$("#loginItem").click(function() {
		if ($(this).hasClass('opened')) {
            closeLogin();
			$(this).removeClass('opened');
		} else {
			openLogin();
			$(this).addClass('opened');
		}
	});

	function openLogin() {
        $("#login").removeClass('hidden');
		$("#login").expandable("open");
	}

	function closeLogin() {
		$("#login").expandable("close");
        $("#login").addClass('hidden');
	}
    /******* Login Block ************/

    /******* left panel special offers *******/
//	$("#offers_home_expandable").expandable();
//
//	$("#offers_home_switch").click(function() {
//		if ($(this).hasClass('opened')) {
//			$("#offers_home_expandable").expandable("close");
//            $(this).removeClass('opened');
//		} else {
//			$("#offers_home_expandable").expandable("open");
//            $(this).addClass('opened');
//		}
//	});
    /******* left panel special offers *******/

    /******* Header Block ************/
//    $(".header a").each(function () {
//        var browser=navigator.appName;
//        if (browser != "Microsoft Internet Explorer") {
//            $(this).focus(function () {
//                blur();
//            });
//        }
//    });
    /******* Header Block ************/

//    /******* Offers Home Block *************/
//
//    var allOffers = $("#offers_home_block");
//    var firstOffer = $(".offer_item:first", allOffers);
//    var count = $(allOffers).children('.offer_item').length;
//    var currentOffer = firstOffer;
//    var index = 1;
//
//    $("#offers_home_block .offer_item").each(function() {
//        $(this).hide();
//    });
//
//    $(currentOffer).show('slow');
//
//	//alert($("#offers_home_block .offer_item").length);
//    var offerTimerId = setInterval(animate, 5000);
//
//    function animate() {
//        $(currentOffer).hide('slow');
//
//        index++;
//        if(index > count) {
//            index = 1;
//            currentOffer = firstOffer;
//        } else {
//            currentOffer = $(currentOffer).next();
//        }
//
//        $(currentOffer).show('slow');
//    }
//
//    /******* Offers Home Block ************/

	/********* Tooltip **************/
//	$(".prediction a").tooltip({
//		bodyHandler: function() {
//			return $($(this).parent().find("span.hidden")).html();
//		},
//		showURL: false,
//		fade: 550,
//		opacity: 0.3
//	});
	/********* Customized Services Tooltip **************/
	$(".customized table table").tooltip({
		bodyHandler: function() {
			return $($(this).find("span.hidden")).html();
		},
		showURL: false
	});
//	$(".customized table img").tooltip({
//		bodyHandler: function() {
////            alert("in");
//			return $($(this).parent("table").find("table span.hidden")).html();
//		},
//		showURL: false,
//        opacity: 0.99
//	});
	/********* Inner Customized Services Tooltip **************/
	$(".inner_customized table table").tooltip({
		bodyHandler: function() {
			return $($(this).find("span.hidden")).html();
		},
		showURL: false
	});
});
