﻿/// <reference path="jquery.intellisense.js"/>

$(document).ready(function() {

    // Rollovers for side navigation
    $("#navigation li").mouseover(function() {
        // add the selected class on rollover
        $(this).attr("class", "selected");
    });
    $("#navigation li").mouseout(function() {
        // remove the selected class, but not for the current page link (with id = "selected")
        if ($(this).attr("id") != "selected") {
            $(this).attr("class", "");
        }
    });

//    $(".paynow").click(function() {
//        $(this).attr("disabled", true);
//    });

    // Form validation - change css class of inputs that are required but have no chosen values
    $('.RegisterButton').click(function() {
        var valid = true;
        $(".required").each(function() {
            var myobj = $(this);
            // if it's empty or -1, then it's invalid (-1 means no choice in a dropdown)
            if (myobj.val() == '' || myobj.val() == '-1') {
                //alert("adding invalid!");
                myobj.addClass("invalid");
                valid = false;
            }
            else {
                //alert("removing invalid!");
                myobj.removeClass("invalid");
            }
        });
        return valid;
    });
});

// This function is called from document.ready (above) but also from within the 
// UpdatePanel on the Cart page to rebind the events after a partial page update
// See here for an explanation: 
// http://asimsajjad.blogspot.com/2009/01/jquery-ajax-update-panel-problem-and.html
function BindEvents()
{
    $('.RegisterButton').click(function()
    {
        $(".required").each(function() {
            var myobj = $(this);
            // if it's empty or -1, then it's invalid (-1 means no choice in a dropdown)
            if (myobj.val() == '' || myobj.val() == '-1') {
                //alert("adding invalid!");
                myobj.addClass("invalid");
            }
            else {
                 //alert("removing invalid!");
                 myobj.removeClass("invalid");        
            }
       });
   });
}

// Lightbox links setup
$(function() {
	$('.lightbox').lightBox();
});

// Javascript popup window for Email A Friend
//<!-- Idea by:  Nic Wolfe -->
//<!-- This script and many more are available free online at -->
//<!-- The JavaScript Source!! http://javascript.internet.com -->

//<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=732,height=515,left = 390,top = 262');");
}
// End -->
