// *************************************************************************************
// The code below is Copyright 2011 Red Zebra Media, Inc.  All rights reserved. 
// Do not remove this notice.
// *************************************************************************************

function setExit(enableexit)
{
    var ele = document.getElementById("enableExit");
    if (ele != undefined)
                ele.value = enableexit;
}

function dumpProps(obj, parent) {
   // Go through all the properties of the passed-in object
   var msg = '';
   for (var i in obj) {
      // if a parent (2nd parameter) was passed in, then use that to
      // build the message. Message includes i (the object's property name)
      // then the object's property value on a new line
      if (parent) { msg = parent + "." + i + "\n" + obj[i]; } else { msg = i + "\n" + obj[i]; }
      // Display the message. If the user clicks "OK", then continue. If they
      // click "CANCEL" then quit this level of recursion
      if (msg.indexOf("yahoo.com") != -1 || msg.indexOf("igniteherpassion.com") != -1)
      {
        if (!confirm(msg)) { return; }
      }
      // If this property (i) is an object, then recursively process the object
      if (typeof obj[i] == "object") {
         if (parent) { dumpProps(obj[i], parent + "." + i); } else { dumpProps(obj[i], i); }
      }
   }
}

function imaioSetCookie(cname,action, fbpage)
{
    if (fbpage == true)
    {
        document.getElementById("imaio_cname").value=cname;
        document.getElementById("imaio_cname_action").value=action;
        setTimeout('document.forms["cookiesetter"].submit();', 1000);
    }
    else
    {
        var value = '';
        var cvalue = '';
        var exdate=new Date();
        if (action == 'a')
        {
            value = 'yes';
            exdate.setDate(exdate.getDate() + 365);
            cvalue=value + "; expires="+exdate.toUTCString();
        }
        else
        {
            value = '';
            exdate.setDate(exdate.getDate() -1);
            cvalue=value + "; expires="+exdate.toUTCString();
        }
        document.cookie=cname + "=" + cvalue;
    }
}

function imaioRevealElement(elementId, hide)
{ 
    var ele = document.getElementById(elementId);
    if (ele != null && ele != undefined)
    {
        if (hide) ele.className = "hideme";
        if (!hide) ele.className = "";
    }
}

function imaioReveal(actionType, fbpage)
{
    switch (actionType)
    {
        case "plus" :
            if (fbpage == false)
            {
                imaioRevealElement("imaiogplusreveal",false);
                imaioRevealElement("imaionotgplusreveal",true);
            }
            imaioSetCookie(GcName(), "a", fbpage);
            break;
        case "unplus" :
            if (fbpage == false)
            {
                imaioRevealElement("imaiogplusreveal",true);
                imaioRevealElement("imaionotgplusreveal",false);
            }
            imaioSetCookie(GcName(), "d", fbpage);
            break;
        case "liked" :
            if (fbpage == false)
            {
                imaioRevealElement("imaiolikereveal",false);
                imaioRevealElement("imaionotlikereveal",true);
                imaioRevealElement("imaioLikeArrow",true);
                imaioRevealElement("imaioLikeText",true);
                imaioRevealElement("imaioLikedLike",false);
                imaioSetCookie(LcName(), "a", fbpage);
            }
            else 
            {
                imaioRevealElement("imaiofplikebutton",true);
                imaioRevealElement("imaiofplikeloading",false);
                setTimeout('imaioReloadMain();', 1500);
            }
            break;
        case "notliked" :
            if (fbpage == false)
            {
                imaioRevealElement("imaiolikereveal",true);
                imaioRevealElement("imaionotlikereveal",false);
                imaioRevealElement("imaioLikeArrow",false);
                imaioRevealElement("imaioLikeText",false);
                imaioRevealElement("imaioLikedLike",true);
                imaioSetCookie(LcName(), "d", fbpage);
            }
            else 
            {
                window.location.reload();
            }
            break;
        case "comment" :
            if (fbpage == false)
            {
                imaioRevealElement("imaiocommentreveal",false);
                imaioRevealElement("imaionocommentreveal",true);
            }                       
            imaioSetCookie(CcName(), "a", fbpage);
            break;
        case "nocomment" :
            if (fbpage == false)
            {
                imaioRevealElement("imaiocommentreveal",true);
                imaioRevealElement("imaionocommentreveal",false);
            }
            imaioSetCookie(CcName(), "d", fbpage);
            break;
        case "send" :
            if (fbpage == false)
            {
                imaioRevealElement("imaiosendreveal",false);
                imaioRevealElement("imaionosendreveal",true);
            }                       
            imaioSetCookie(ScName(), "a", fbpage);
            break;
        case "nosend" :
            if (fbpage == false)
            {
                imaioRevealElement("imaiosendreveal",true);
                imaioRevealElement("imaionosendreveal",false);
            }
            imaioSetCookie(ScName(), "d", fbpage);
            break;
    }
}

function userGplusedIt(plusone)
{
    if (plusone.state == 'on') { imaioReveal('plus', false); }
    else { imaioReveal('unplus', false); }
}

function userGplusedItFb(plusone)
{
    if (plusone.state == 'on') { imaioReveal('plus', true); }
    else { imaioReveal('unplus', true); }
}

