/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

String.prototype.trim=function(){
    return this.replace(/^\s+|\s+$/g,'');
}

$(document).ready(function(){
    $('label.in').each(function(){
        var x=$('#'+$(this).attr('for'));
        if(x.val()=='')x.val($(this).html().trim()).addClass('il');
        $(this).hide();
    });
    $('.il').focus(function(){
        $(this).filter('.il').val('').removeClass('il');
    });
    $('.il').blur(function(){
        if($(this).val()==''){
            $(this).addClass('il').val($('label.in[for='+$(this).attr('id')+']').html().trim())
            }
        });
    $("#popup").addClass("hidden");
    /*
    $("img.productThumb")
        .mouseover( function(){ 
            var src_old = $(this).attr("src");
            var src_new = $("#mainImage").attr("src");
            $(this).attr("src", src_new.replace('info_images','thumbnail_images') );
            $("#mainImage").attr("src",src_old.replace('thumbnail_images','info_images'));
        } )
        .mouseout( function(){ 
            // alert("haha");
        } );
    */
});

function popupWindow(link){
    alert(link);
}

function showImage(link){
    var image = link.getAttribute("src");
    image = image.replace('info_images','popup_images');
    image = image.replace('thumbnail_images','popup_images');

    img = document.createElement("img");
    img.setAttribute("src",image);
    img.setAttribute("class","rounded");
    div = document.getElementById("popup");
    div.innerHTML = "";
    div.appendChild(img);

    $("#page_margins").css("opacity", "0.3");
    $("#popup").addClass("visible").removeClass("hidden").css("opacity", "1");
    $("#popup").click( function(){
        $("#page_margins").css("opacity", "1");
        $("#popup").addClass("hidden").removeClass("visible").css("opacity", "0");
    } );
    return false;
}