/* $Id: microsite.js,v 1.8 2009-04-24 17:08:56 nwang Exp $ */
/* private JS for this microsite */
function swapImage(bigImageSrc, title, caption, thumbnailDiv){
    swapText(title, caption, thumbnailDiv);
    $('#watch_main_img').fadeOut('slow', function(){
            document.getElementById("watch_main_img").innerHTML =  "<img id=\"bigImage\" name=\"bigImage\" src=\"" + bigImageSrc + "\" width=\"288\" height=\"288\"><br>"; 
            $('#watch_main_img').fadeIn('slow');
        });

    return (false);
}

function swapVideo(videoSrc, title, caption, thumbnailDiv){
    swapText(title, caption, thumbnailDiv);
    $('#watch_main_img').fadeOut('slow', function(){
            document.getElementById("watch_main_img").innerHTML = "<object width=\"288\" height=\"288\"><param name=\"movie\" value=\"" + videoSrc + "\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"" + videoSrc + "\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"288\" height=\"288\"></embed></object>";
            $('#watch_main_img').fadeIn('slow');
        });
    return (false);
}

var lastThumbnailDiv = "thumbnailDiv_0";
function swapText(title, caption, thumbnailDiv){
    document.getElementById(lastThumbnailDiv).className = "thumbnail_border";
    lastThumbnailDiv = thumbnailDiv;
    document.getElementById(thumbnailDiv).className = "thumbnail_border_orange";
    document.getElementById("titleDiv").innerHTML = title;
    document.getElementById("captionDiv").innerHTML = "<p>" + caption + "</p>";
}

function refrig_on(selected_refrig, refrig_id){
    $('#refrig_a').attr("src","images/radio_off.gif");
    $('#refrig_b').attr("src","images/radio_off.gif");
    $('#refrig_c').attr("src","images/radio_off.gif");
    $(refrig_id).attr("src","images/radio_on.gif");
    $('#r').val(selected_refrig);
}

function cooktop_on(selected_cooktop, cooktop_id){
    $('#cooktop1').attr("src","images/radio_off.gif");
    $('#cooktop2').attr("src","images/radio_off.gif");
    $('#cooktop3').attr("src","images/radio_off.gif");
    $(cooktop_id).attr("src","images/radio_on.gif");
    $('#p').val(selected_cooktop);
}

// Apr 23, 2009 Neo Wang. No pre-selected product
/* Apr 4, 2009 Neo Wang. This functions is not being used anymore.*/
function submitVote(is_on_submit){
    var msg = "";
    if (document.getElementById("p").value.length == 0){
        msg = "Please select a faucet.\n\n";
    }
    if (document.getElementById("r").value.length == 0){
        msg += "Please select a sink.";
    }
    if (msg.length == 0){
        if (is_on_submit == 0){
            document.frmVote.submit();
        }
        return true;
    } else {
        alert(msg);
        return false;
    }
    
}

function submitSingleVote(p){
    document.frmVote.p.value = p;
    document.frmVote.submit();
}