﻿$(document).ready(function() {

    
    
    /*
    
    //Clear email field on click
    $(".input_field_username").focus(function() {
        if ($(".input_field_username").val() == "email") $(".input_field_username").val("");
    });
    $(".input_field_username").blur(function() {
        if ($(".input_field_username").val() == "") $(".input_field_username").val("email");
    });

    //Clear password field on click
    $(".input_field_password").focus(function() {
        if ($(".input_field_password").val() == "password") $(".input_field_password").val("");
    });
    $(".input_field_password").blur(function() {
        if ($(".input_field_password").val() == "") $(".input_field_password").val("password");
    });
    
    */

    $(".accordion .toggle").click(function() {
        //$(".search_input_field")
        $(this).toggleClass("toggle_open");
        $(this).next().slideToggle();
    });


    $(".myaccount .items a").click(function() {

        $(this).toggleClass("open");
        $(this).parent().parent().next().slideToggle();
    });


    $(".payments a.toggle").click(function() {

        $(this).toggleClass("toggle_open");
        $(this).next().slideToggle();
    });



    $('#photos').galleryView({
        panel_width: 456,
        panel_height: 232,
        frame_width: 63,
        frame_height: 50
    });


    // Reset Font Size
    var originalFontSize = $('body').css('font-size');

    //alert(originalFontSize);

    $(".textSizeSmall").click(function() {
        $('body').css('font-size', 10);
        removeSizeSelected();
        $(this).addClass("selected");
    });

    // Medium
    $(".textSizeMedium").click(function() {
        var newFontSize = 10 * 1.1;
        $('body').css('font-size', newFontSize);
        removeSizeSelected();
        $(this).addClass("selected");
        return false;
    });

    // LARGE
    $(".textSizeLarge").click(function() {
        var newFontSize = 10 * 1.2;
        $('body').css('font-size', newFontSize);
        removeSizeSelected();
        $(this).addClass("selected");
        return false;
    });


/*
    //Homepage slider
    $(".homepage .splash").easySlider({
        auto: true,
        continuous: true,
        speed: 800,
        pause: 4000
    });
*/

});

function removeSizeSelected() {
    $(".textSizeSmall").removeClass("selected");
    $(".textSizeMedium").removeClass("selected");
    $(".textSizeLarge").removeClass("selected");
}

function CharacterCountdown(x) {
    var remaining = 120 - x.value.length;
    if (remaining < 0) {
        alert("You have entered too many characters");
        x.value = x.value.substring(0, 120);
    }
    else
        $("#CharactersRemaining").html("(" + remaining + " characters remaining)");
}

function SearchBoxTip(box,focus) {
    
    /*
    if(focus && box.value == "Search")
        box.value = "";
    else if(box.value == "")
    {
        box.value = "Search";
    } 
    */       
}

function Search(boxId)
{
    var box = document.getElementById(boxId);
    if(box && box.value != "" && box.value != "Search")
    {
        document.location.href= '/search.aspx?key='+ box.value; 
    }
    else alert("Please enter a search term and try again");
    
    return false;
}

function Translate(babelfishurl,listId)
{
    var list = document.getElementById(listId);
    if(list && list.selectedIndex > 0)
    {            
        document.location.href = babelfishurl.replace("[lang]",list.options[list.selectedIndex].value);
    }
    else alert('Please select a language to translate to.');
    return false;
}