﻿// JScript File

function openproduct(param){
//window.open('/Recipes/RateRecipe.aspx?QueryString','emailwindow','width=400,height=450,toolbar=no,menubar=no,location=no,directories=no,status=yes,scrollbars=yes'
    window.open('ProductView.aspx?id=' + param, 'ProductWindow' , 'width=800,height=500,toolbar=no,menubar=no,location=no,directories=no,status=yes,scrollbars=no')
}

//function openwindow(url){
//    window.open(url, 'NutritionInfo' , 'width=800,height=500,toolbar=no,menubar=no,location=no,directories=no,status=yes,scrollbars=no')

//}
var forcedRefresh = true;
var alreadyopen = new Array();
var newwin = new Array();

function openCenteredWindow(uri, name, features, width, height){

  var winl = parseInt((screen.width - width - 10) / 2),
      wint = parseInt((screen.height - height - 29) / 2);
  openWindow(uri, name, features + (features ? ',' : '') + 'height=' + height + ',width=' + width + ',top=' + wint + ',left=' + winl);
}

function openWindow(uri, name, features){

  if(!forcedRefresh && alreadyopen[name] && !newwin[name].closed){
    newwin[name].focus();
  }
  else{
    alreadyopen[name] = true;
    newwin[name] = window.open(uri, name, features);
    //newwin[name].focus();
  }
}


function showBag(i) {
    $("prodDiscription").style.display = "block";
    var burst = 'imgBurst' + i.toString();
    //var desc = 'imgDesc' + i.toString();

    //$("videoHolder").style.display = "none";
    //$("videoPlayer").innerHTML = "";

    $$('.imgBurst').each(function(s) { s.hide(); });
    //$(burst).css('display', 'block');
    $(burst).show();


    //$$('.imgDesc').each(function(s) { s.hide(); });
    //$(desc).show();
}

function watchAds() {

    $$('.imgBurst').each(function(s) { s.hide(); });
    $("videoHolder").style.display = "block";
    loadVideo(currentAd);

}

function loadVideo(id) {
    var videoUrl = "";
    currentAd = id;
    switch (id) {
        case 1:
            videoUrl = "http://chexsnacks.s3.amazonaws.com/Decoy.flv";
            break;
        case 2:
            videoUrl = "http://chexsnacks.s3.amazonaws.com/bbq_15_ntsc.flv";
            break;
        //                case 3: 
        //                    videoUrl = "3"; 
        //                    break; 
    }

    $j('.videoLink').css("color", "#AA444F")
    $j('#videoLink' + id.toString()).css("color", "#000000")

    $("videoPlayer").innerHTML = "";
    // <![CDATA[
    var so = new SWFObject("video_player.swf", "jmVideo", "525", "295", "8", "#000000");
    so.addParam("scale", "noscale");
    so.addVariable("video", videoUrl);
    so.write("videoPlayer");
    // ]]>
}

function pupupNutrition(id) {
    openCenteredWindow('http://www.generalmills.com/ColorBoxImage.aspx?ImageId=' + id.toString(), 'Nutrition', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes', '714', '755');
}


function showThanks() {

    //Get the A tag  
    var id = '#thanks';

    //Get the screen height and width  
    var maskHeight = $j(document).height();
    var maskWidth = $j(window).width();

    //Set height and width to mask to fill up the whole screen  
    $j('#mask').css({ 'width': maskWidth, 'height': maskHeight });

    //transition effect       
    $j('#mask').fadeIn(1000);
    $j('#mask').fadeTo("slow", 0.8);

    //Get the window height and width  
    var winH = $j(window).height();
    var winW = $j(window).width();

    //Set the popup window to center  
    $j(id).css('top', winH / 2 - $j(id).height() / 2);
    $j(id).css('left', winW / 2 - $j(id).width() / 2);

    //transition effect  
    $j(id).fadeIn(2000);


    //if close button is clicked  
    $j('.window .close').click(function(e) {
        //Cancel the link behavior  
        e.preventDefault();
        $j('#mask, .window').hide();
    });

    //if mask is clicked  
    $j('#mask').click(function() {
        $j(this).hide();
        $j('.window').hide();
    });   	
}

function showDoubleClickLanding() {
    var axel = Math.random()+ "";
    var a = axel * 10000000000000;
    document.write('<IFRAME SRC=\"http://fls.doubleclick.net/activityi;src=1869704;type=snack771;cat=snach668;ord=1;num='+ a + '?\" WIDTH=1 HEIGHT=1 FRAMEBORDER=0></IFRAME>');
    }
    
function showDoubleClickThanks() {
    var axel = Math.random()+ "";
    var a = axel * 10000000000000;
    document.write('<IFRAME SRC=\"http://fls.doubleclick.net/activityi;src=1869704;type=snack771;cat=snach693;ord=1;num='+ a + '?\" WIDTH=1 HEIGHT=1 FRAMEBORDER=0></IFRAME>');
}

