﻿Error.raise = function() {}

var _curElementId = -1;
var _browser;
if (navigator.userAgent.indexOf("MSIE ") != -1) {
	_browser = "ie";
}
else {
	_browser = "moz";
}

function OpenSendToFriendDialog(id)
{    
   //var id = GetIdFromElement(oEl);
      
        try
        {
            window.open("/destination/catalog/sendtofriend.aspx?pid="+id, "SendToFriend", "width=350px,height=200px");
         } 
         catch(e)
         {
          //don't expand 
         }
}

function SwapButton(oEl, e)
{   
   try
   {
        if (oEl.src.lastIndexOf('/') !=-1)
        {
            var firstpos=oEl.src.lastIndexOf('/')+1;

            var lastpos=oEl.src.length;
            var buttonPath =  oEl.src.substring(0,firstpos);
            var buttonName=oEl.src.substring(firstpos,lastpos);                
            var buttonExt = buttonName.replace(/\w+\.(\w+)/, "$1");  
            buttonName = buttonName.replace(/(\w+)\.\w+/, "$1"); 
           
           if(buttonName.indexOf("over")>=0 && e.type =="mouseout")
           {
            buttonName = buttonName.replace(/(\w+)_\w+/, "$1"); 
           } 
           else if(e.type =="mouseover")
           {
            buttonName = buttonName + "_over";
           }
           var fullButtonSrc = buttonPath + buttonName + "." +buttonExt;

        }

        oEl.src=fullButtonSrc;
    }
    catch(e)
    {
        //make no change on fail
    }
}   


    
 /**
 * Function get id [content id] from element
 * 
 * @param oEl element making the call
 * @return string of id [content id] from element
 * @author Greg O'Byrne<grego@zango.com>
 */
function GetIdFromElement(oEl)
{
    try
   { 
        return oEl.id.replace(/\w+_(-*\d+)/gi,"$1");
    }
   catch(e)
   {
        return -1;
   } 
        
}

/**
 * Function get element-type [content display type] from element
 * 
 * @param oEl element making the call
 * @return string of element type [content display type]
 * @author Greg O'Byrne<grego@zango.com>
 */
function GetElementTypeFromElement(oEl)
{
    try
   { 
        return oEl.id.replace(/(\w+)_\d+/gi,"$1");
    }
   catch(e)
   {
        return "";
   }  
}

 /**
 * Function check for child element as contained in a parent
 * ...in other words did I move into a child element
 * 
 * @param oEl element making the call
 * @param e event making the call
 * @return bool
 * @author Greg O'Byrne<grego@zango.com>
 */
function containsElement(oEl, e) 
{
	if(_browser=="moz")
	{
		var toElement = e.relatedTarget;

		while (toElement.parentNode)
		{
			if ((toElement = toElement.parentNode) == oEl)
			{		
				return true;
			}
		}
	}
	else
	{
	    if(oEl.contains(e.toElement))
	    {
	        return true;
	    }
	}
	return false;
}	

function toggleDisplay (divId, flag) {

	if (flag) {
		document.getElementById ( divId ).style.display = "block";

	} else {
		document.getElementById ( divId ).style.display = "none";
	}

}


function showLIHover(cTitle, cDesc, cImg) {
    document.getElementById ( "cTitle" ).innerHTML = cTitle;
    document.getElementById ( "cDesc" ).innerHTML = cDesc;
    //document.getElementById ( "moreLinkz" ).onClick = "alert('here')";
    document.getElementById ( "cImg" ).src = cImg;
    document.getElementById ( "moreLinkz" ).style.display = "block";
}

function hideLIHover() {
    document.getElementById ( "moreLinkz" ).style.display = "none";
}

function getMouse(e){     // set mouse coordinates

    e=e||window.event;
    de=document.documentElement;b=document.body;

    xMouse=e.clientX+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||0);
    yMouse=e.clientY+(de.scrollTop||b.scrollTop) - (de.clientTop||0);

    while (xMouse>630) {
        xMouse-=20;
    }

    var hoverDiv = document.getElementById( "moreLinkz" );
    if(hoverDiv)
    {
        hoverDiv.style.top = ( yMouse - 80 ) +'px';
        hoverDiv.style.left = ( xMouse + 20 ) + 'px';
    }

} // move popup away from right edge    

function popGEC (url) {
    if (!ZCUtils.domReady) {
        window.onload = function () { gec_open(url);}
    } else {
        gec_open(url);
    }
}