
	var imgid = 'image';
    // image dir set dynamically by asp.net
	var imgdir = '';
	var imgext = '.jpg';
	var thumbid = 'thumbs';
	var auto = true;
	var autodelay = 3;

	$(document).ready(function() {

	    try {


	        $('.colapsable').each(function(i, o) {
	            //alert('index: ' + i + ' object id: ' + o.id);

	            var $div = $('#search' + o.id);
	            var $link = $('#' + o.id);
	            var width = $div.width();
	            $div.hide().css({ width: 705, opacity: 1 });

	            var header = $('#headerBanner');

	            $('#' + o.id).click(function() {
	                if ($div.is(':visible')) {
	                    //$div.animate({width: 705, opacity: 0 }, { duration: 400, complete: function () {
	                    $div.hide();
	                    $div.removeClass('expanded');
	                    $link.removeClass('active');
	                    header.show();
	                    //} });
	                } else {
	                    //$('.expanded').animate({width: 705, opacity: 0 }, { duration: 400, complete: function () {
	                    $('.expanded').hide();
	                    $('.expanded').removeClass('expanded');
	                    $('.active').removeClass('active');
	                    //} });
	                    //$div.show().animate({width :705, opacity: 1 }, { duration: 400, complete: function(){
	                    $div.show();
	                    $div.addClass('expanded');
	                    $link.addClass('active');
	                    //} });
	                    header.hide();
	                }

	                return false;
	            });
	        });

	        $("#newsletter span").click(function() {
	            $("#newsletter span").css('visibility', 'hidden');
	        });


	        $('.showPrices').each(function(i, o) {
	            //alert('index: ' + i + ' object id: ' + o.id);

	            var $priceBox = $('#priceBox' + o.id);
	            var $priceLink = $('#' + o.id);
	            var height = $priceBox.height();
	            $priceBox.hide().css({ height: 0, opacity: 0.4 });

	            $('#' + o.id).click(function() {
	                if ($priceBox.is(':visible')) {
	                    $priceBox.animate({ height: 0, opacity: 0.4 }, { duration: 500, complete: function() {
	                        $priceBox.hide();
	                        $priceBox.removeClass('expanded');
	                        $priceLink.removeClass('active');
	                    }
	                    });
	                } else {
	                    $('.expanded').animate({ height: 0, opacity: 0.4 }, { duration: 200, complete: function() {
	                        $('.expanded').hide();
	                        $('.expanded').removeClass('expanded');
	                        $('.active').removeClass('active');
	                    }
	                    });
	                    $priceBox.show().animate({ height: 250, opacity: 1 }, { duration: 500, complete: function() {
	                        $priceBox.addClass('expanded');
	                        $priceLink.addClass('active');
	                    }
	                    });

	                }

	                return false;
	            });
	        });


	        lastBlock = $("#a1");
	        maxWidth = 420;
	        minWidth = 25;

	        $("div.month").click(
      function() {
          $(lastBlock).animate({ width: minWidth + "px" }, { queue: false, duration: 400 });
          $(this).animate({ width: maxWidth + "px" }, { queue: false, duration: 400 });
          lastBlock = this;
      }
    );

	        showWelcomeBox();

	    }
	    catch (e) { }

	});

	function showWelcomeBox() {
	    if ($.cookie("NewsletterPopupShown") == null) {
	        $("#welcome-box-wrapper").show();

	        $("#welcomeBoxSubmit").click(function() {
	            var email = $("#welcomeBoxTxtEmail")[0].value;
	            var postalCode = $("#welcomeBoxTxtPostalCode")[0].value;
	            //
	            var isValid = true;
	            //
	            if (email.length == 0) {
	                $("#welcomeBoxReqEmail").show();
	                isValid = false;
	            }
	            else {
	                $("#welcomeBoxReqEmail").hide();
	            }
	            //
	            if (postalCode.length == 0) {
	                $("#welcomeBoxReqPostalCode").show();
	                isValid = false;
	            }
	            else {
	                $("#welcomeBoxReqPostalCode").hide();
	            }
	            //
	            var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	            if (email.length != 0 && reg.test(email) == false) {
	                $("#welcomeBoxIsEmail").show();
	                isValid = false;
	            }
	            else {
	                $("#welcomeBoxIsEmail").hide();
	            }
	            //
	            if (postalCode.length != 0 && (postalCode.length < 4 || postalCode.length > 5)) {
	                $("#welcomeBoxIsCodePostal").show();
	                isValid = false;
	            }
	            else {
	                $("#welcomeBoxIsCodePostal").hide();
	            }
	            if (isValid) {
	                try {
	                    $.ajax({
	                        type: "POST",
	                        url: "AJAX.aspx/SaveWelcomeBoxData",
	                        data: "{'email':'" + email + "', 'code':'" + postalCode + "'}",
	                        contentType: "application/json; charset=utf-8",
	                        dataType: "json",
	                        error: function(xhr, status, errorThrown) {
	                            $("#welcome-box-wrapper").hide();
	                            $.cookie("NewsletterPopupShown", "true");
	                        },
	                        success: function(msg) {
	                            $("#welcome-box-wrapper").hide();
	                        }
	                    });
	                }
	                catch (exc) {
	                    $("#welcome-box-wrapper").hide();
	                }
	            }
	            return false;
	        });

	    }

	}
	
	function isNumberKey(evt) {
	    var charCode = (evt.which) ? evt.which : window.event.keyCode
	    if (charCode > 31 && (charCode < 48 || charCode > 57))
	        return false;
	    return true;
	}

	function goToWelcomePage() {
	    $(document).ready(function() {
	        try {
	            var pathName = window.location.pathname;
	            //
	            if (pathName.toLowerCase().indexOf("admin") == -1 && $.cookie("NewsletterPopupShown") == null) {
	                //
	                window.location = baseUrl + '/welcome.html?back=' + pathName;
	            }

	        }
	        catch (e) {

	        }
	    });
	    
	}
