﻿$(document).ready(function() {
    $('.vAlign').VerticalAlign();




    /* stretch you might also like */
    $('.bubbleStretch').each(function(i) {
        $(this).css('height', $(this).parent().height() + 'px');
    });



    /* how to mix navigation */
    var panelIndex = 1;
    var animTimeMs = 400;

    while ($("#htmMain_" + panelIndex).length) {

        $("#htmMain_" + panelIndex).click(function() {
            var currentIndex = this.id.substring(this.id.lastIndexOf('_') + 1);
            $("#htmSub_" + currentIndex).animate({
                left: "0px"
            }, animTimeMs);
            $("#htmMain").animate({
                left: "-320px"
            }, animTimeMs);
            this.blur();
            return false;
        });

        $("#htmMain_" + panelIndex + "_back").click(function() {
            var currentIndex = this.id.substring(this.id.indexOf('_') + 1, this.id.lastIndexOf('_'));
            $("#htmSub_" + currentIndex).animate({
                left: "320px"
            }, animTimeMs);
            $("#htmMain").animate({
                left: "0px"
            }, animTimeMs);
            this.blur();
            return false;
        });

        panelIndex++;
    }


    /* pop ingredient window */
    $('#ingredientPop').css({ 'display': 'none' });
    $(".drinkInfo #ingredientLinks A").click(function(e) {

        $('.sharePopHolder').css({ 'display': 'none' }); //Close sharePop - only one pop open at a time

        $('#ingredientPop') .css({'top': (this.offsetTop -14)+'px', 'left': '113px'});
        //$('#ingredientPop') .css({'top': (e.pageY - 302 )+'px'});
        toggleInfoPop(this.href);
        return false;
    });
    
    $(".drinkInfo A.methodLink").click(function(e){
		
		$('.sharePopHolder').css({'display': 'none'}); //Close sharePop - only one pop open at a time
		
		$('#ingredientPop') .css({'top': (this.offsetTop -14)+'px', 'left': (this.offsetLeft + 30)+'px'});
		//$('#ingredientPop') .css({'top': (e.pageY - 302 )+'px'});
		toggleInfoPop(this.href);
		return false;
	});	
	
	$(".drinkInfo A.toolLink").click(function(e){
		
		$('.sharePopHolder').css({'display': 'none'}); //Close sharePop - only one pop open at a time
		
		//$('#ingredientPop') .css({'top': (this.offsetTop -14)+'px'});
		$('#ingredientPop') .css({'top': (e.pageY - 302 )+'px', 'left': '113px'});
		toggleInfoPop(this.href);
		return false;
	});	


    /* pop share window */
    $('.sharePopHolder').css({ 'display': 'none' });
    $("#ButtonShare").click(function(e) {

        $('#ingredientPop').css({ 'display': 'none' });  //Close ingredientPop - only one pop open at a time

        $('.sharePopHolder').css({ 'top': (this.offsetTop + 150) + 'px' });
        $('.sharePop').css({ 'margin-left': (this.offsetLeft + 10) + 'px' });

        //alert(this.offsetLeft);
        toggleSharePop();
        return false;
    });


    



    /* Served Right Now */
    var countryID = 'world';
	var selectCountry = '/templates/ServedRightNow.aspx?countryID=' + countryID;
	$('.servedRightNow').load(selectCountry, null, function(result) {
		$('.servedRightNow').html(result);
	});
	
	$(".servedRightNowSelect SELECT").change(onSelectChange);
    
    



    /* drink list */
	$(document).ready(function() {
	    var tasteUrl = '';
	    var skillUrl = '';

	    $(".selectTaste").change(onSelectChangeTaste);
	    $(".selectSkill").change(onSelectChangeSkill);
	});




    /* Set Carousel default */
    carouselSelect();
    
    
    
    
    
    /* Image Carousel */
	$(".teaserCarousel .carousel").jCarouselLite({
		visible: 1,
		auto: 4000,
		speed:400
	});
	
	
	
	
	/* Autofill */
	$('.searchField').autofill({
		value: 'You can search on Drinks, Ingredients, and BASE SPIRITS.',
		defaultTextColor: '#b8b8b8',
		activeTextColor: '#000'
	});
	
//	$('#shareMailName').autofill({
//		value: 'Your Name',
//		defaultTextColor: '#666',
//		activeTextColor: '#000'
//	});
//	
//	$('#shareMailAddress').autofill({
//		value: 'Your friends E-mail',
//		defaultTextColor: '#666',
//		activeTextColor: '#000'
//	});
	
	
	
	/* Resize Page Not Found*/
	$('.pageNotFound') .css({'height': (($(window).height()) - 272)+'px'});
	$(window).resize(function(){
		$('.pageNotFound') .css({'height': (($(window).height()) - 272)+'px'});
		//alert('resized');
	});
	






	
	/* Show carousel thumbs, noFlash and sharePop */
	$('.noFlash') .css({'visibility': 'visible'});
	$('.noFlashLinks') .css({'visibility': 'visible'});
	$('.sharePop') .css({'visibility': 'visible'});
	$('.carouselNavi li A') .css({'visibility': 'visible'});
	$('.carouselNavi A.prev') .css({'visibility': 'visible'});
	$('.carouselNavi A.next') .css({'visibility': 'visible'});
	
});