﻿

jQuery(document).ready(function () {

    jQuery(".rollover").live('mouseover mouseout', function (event) {
        if (event.type == 'mouseover') {
            this.src = this.src.replace("_off", "_on");
        }
        else {
            this.src = this.src.replace("_on", "_off");
        }
    });

    if (getQuerystring('idC') != "") {
        //trocaMenu("Div" + getQuerystring('idC'));
    }

});


var lastDiv1 = "";
function trocaMenu(div) {
    if (lastDiv1 != div) {
        if (lastDiv1 != "") {
            $("#" + lastDiv1).hide();
            //$("#" + lastDiv1).slideUp(300);
            //$(".menuHorSelected").removeClass("menuHorSelected");
        }
        $("#" + div).show();
        //$("#" + div).slideDown(300);
        lastDiv1 = div;
       // $('#' + div + 'Menu').addClass("menuHorSelected");

    } else {
        $("#" + lastDiv1).hide();
       // $("#" + lastDiv1).slideUp(300);
        lastDiv1 = "";
       // $(".menuHorSelected").removeClass("menuHorSelected");


    }

}

var lastDiv = "";
function troca(div) {
    if (lastDiv != div) {
        if (lastDiv != "") {
            $("#" + lastDiv).slideUp(400);
        }
        $("#" + div).slideDown(400);
        lastDiv = div;
    } else {
        $("#" + lastDiv).slideUp(400);
        lastDiv = "";
    }
}

//Trocar a imagem principal dos produtos
function showImage(img, comment) {

    //$('#mainMedia').html("<img src='" + $(img).attr('src') + "'  width='640' height='382' alt='' />");
    $('#embedYoutube').hide();
    $('#mainImage').show();
    $('#mainImage').html("<img src='" + ($(img).attr('src')).replace("thumb/", "") + "'  width='640' height='382' alt='' />");
    if(comment!= "")
        $('#comment').html("Nota: " + comment);
    else
        $('#comment').html("");
}

function showYoutube(id, comment) {

    /*var str = '<object width="640" height="382">' +
              '<param name="movie" value="' + url + '?fs=1&amp;modestbranding=1&amp;rel=0"</param>' +
              '<param name="allowFullScreen" value="true"></param>' +
              '<param name="allowScriptAccess" value="always"></param>' +
              '<embed src="' + url + '?fs=1&amp;modestbranding=1&amp;rel=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="640" height="382">' +
              '</embed></object>';

    $('#mainMedia').html(str);*/

    if (comment != "")
        $('#comment').html("Nota: " + comment);
    else
        $('#comment').html("");

    $('#mainImage').hide();
    $('#embedYoutube').show();

    var params = { allowScriptAccess: "always" };
    var atts = { id: "embedYoutube" };
    swfobject.embedSWF("http://www.youtube.com/e/" + id + "?enablejsapi=1&playerapiid=ytplayer&rel=0",
                       "embedYoutube", "640", "382", "8", null, null, params, atts);

}

function getQuerystring(key, default_) {
    if (default_ == null) default_ = "";
    key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
    var qs = regex.exec(window.location.href);
    if (qs == null)
        return default_;
    else
        return qs[1];
}
