﻿function enlarge(flv, title)
{
	window.open("fullscreen.aspx?flv=" + flv + "&title=" + title, "recipe", "width=1000, height=650, location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=yes");
}

/*************** area toggling *******************/
function toggle(id, imgname) {
    var item = document.getElementById(id);
    //item.style.display = (item.style.display != 'none' ? 'none' : 'block' );

    if (item.style.display == "none")
    {
        item.style.display = "block";
        document[imgname].src = "/images/recipeHeaderArrowD.gif";
    } else {
        item.style.display = "none";
        document[imgname].src = "/images/recipeHeaderArrowU.gif";
    }
}

/*************** cooking 101 *******************/
function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return document.getElementById(movieName);
    }
    else {
        return document[movieName]
    }
}
/*
function start101(path, title) {	    
    thisMovie("swfFlashPlayer").start101(path, title);
}*/
function start101(path, title, icon, action)
{
    //alert("pak - start101");
    //thisMovie("swfFlashPlayer").start101(path, title, icon, action);
    thisMovie("swfFlashPlayer").cooking101("start", path, title, icon, action);
    //alert("pak - start101end");
}

function close101() {
    //alert("close101");
    //thisMovie("swfFlashPlayer").close101();
    thisMovie("swfFlashPlayer").cooking101("close");
    //alert("close101end");
}

//pkl - comments
/*
    - should get better browser/object detection
    - for some reason e.target.offsetTop for firefox is not the same as event.srcElement.offsetTop for IE **fixed with different sized offset

*/

//compare previous ingredient
var prev_id;

function ShowPopup(e, pTitle, description, videoURL, imageid){

    
    var ie = navigator.userAgent.indexOf("MSIE") > 0;
    var div = document.getElementById("div101");
    var header;
    var topHeight; 
    
    
    header = "<div id='header101'>" + "<a href='#' onclick='javascript:HidePopup();'><img src='/images/link.gif' width='20' height='20' align='right' hspace='4' border='0'></a>" + pTitle +  "</div>";
        
    div.innerHTML = header + "<div id='descr101'>" + description + "</div><a href=\"#\" onclick=\"javascript:start101('" + videoURL + "', '" + pTitle + "', '<%=SiteGlobal.ImagePath %>Category_1.jpg', 'category.aspx?catID=1');return false;\"><img src='/images/link.gif' width='320' height='30' border='0'></a>";
    
    topHeight = (ie ? e.srcElement.offsetParent.offsetTop -100 : e.target.offsetTop - 240);
    if (topHeight < 100) {
        topHeight = 200;
        }
    div.style.top = topHeight + "px";
    div.style.left = document.body.clientWidth/2 - 20 + "px";
    
    //(ie ? event.clientX : e.pageX) -50 ;  
    
    opacity('div101',0,100,500);
   
    
}
function HidePopup(){
    //alert("start hide");
    close101();
    opacity('div101',100,0,50);
    //alert("end hide");
   
}
function HidePopup101(){
    //HidePopup();
    //alert("hidepopup101");
    HidePopup();
    //alert("hidepopup101end");
    //setTimeout('', 3000);
}

function TogglePopup(e, id, title, imageid, videoURL)
{
    //alert("togglestart");
    description = document.getElementById(imageid).getAttribute("alt");
    
    if (document.getElementById("div101").style.opacity == 1)
    {
        
        if (id != prev_id)
        {
            ShowPopup(e, title, description, videoURL, imageid);
            prev_id = id;
        } else {
            HidePopup();
        }
            
        
    } else {
        ShowPopup(e, title, description, videoURL, imageid);
        prev_id = id;
    }
    //alert("toggleend");
}

function ShowEmail(e)
{
    var ie = navigator.userAgent.indexOf("MSIE") > 0;
    var div = document.getElementById("divEmail");
    
    div.style.left = document.body.clientWidth/2 - 35 + "px";
    div.style.top = (ie ? event.srcElement.offsetTop : e.target.offsetTop) + "px";
    opacity('divEmail',0,100,1000);
}
function HideEmail()
{
    opacity('divEmail',100,0,500);
}



if (document.getElementById && document.getElementsByTagName) {
if (window.addEventListener) window.addEventListener('load', initPopup, false);
else if (window.attachEvent) window.attachEvent('onload', initPopup);
}

function initPopup() {
    opacity('div101',100,0,1);
    opacity('divEmail',100,0,1);
    bkg = new Image(); 
    bkg.src = "/images/101PopupBkg.gif";
    bkg2 = new Image(); 
    bkg2.src = "/images/sendFriendBkg.gif";

}
