function ShowHideElement(elementID)
{
    if (document.getElementById(elementID).style.display=='none')
    {
        document.getElementById(elementID).style.display='';
    }
    else
    {
        document.getElementById(elementID).style.display='none';
    }
}

function enlargeImage(imgPath,name)
{
    $.facebox('<img src="'+imgPath+'" title="'+name+'" alt="'+name+'"><br><br><h3>'+name+'</h3>');
    return;
    
    var win = window.open('','preview','width=50,height=50,left=0,top=0,screenX=0,screenY=0,resizable=1,scrollbar=0,status=0');
    
    var winDoc = win.document;
    var content = '<html><head><title>' + name + '</title>' +
    			  '<style>body{overflow: hidden;margin:0;}img{border:0;}</style>' +
    			  '</head><body><a href="javascript:self.close()">' +
    			  '<img alt="' + name + '" title="'+ name +'" id="image" src="' + imgPath + '" /></a></body></html>'
    win.document.write(content);
    
    winDoc.body.onload = function() {
    	var obj = winDoc.getElementById('image');
    	var w = obj.width, h = obj.height;
    	var iHeight= document.body.clientHeight, iWidth = self.innerWidth;
    	
    	var left = (self.opera ? iWidth : screen.availWidth)/2 - w/2;
    	var top =  (self.opera ? iHeight : screen.availHeight)/2 - h/2;
    	win.resizeTo(w+10, h+26);
    	win.moveTo(left, top);
    }
    
    win.onload = winDoc.body.onload;
    
    win.document.close();
    win.focus();
}


function rand()
{
    var now=new Date()
    var num=(now.getSeconds())%10
    var num=num+1
    return num;
}

function refreshFormCode()
{
    if (document.getElementById('form_code_image'))
    {
        document.getElementById('form_code_image').src="/project/templates/public_default/images/heart.png";
        setTimeout('document.getElementById(\'form_code_image\').src="/project/form_code.php?hash='+rand()+'";', 300); 
    }
}


function openPopup(href,w,h)
{
    var left = (self.opera ? iWidth : screen.availWidth)/2 - w/2;
    var top =  (self.opera ? iHeight : screen.availHeight)/2 - h/2;
    var w=window.open(href,"_blank",'width='+w+',height='+h+',left='+left+',top='+top+',screenX=0,screenY=0,location=no,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=yes');
    w.focus();
}


function getElementPosition(elemId)
{
    var elem = document.getElementById(elemId);
	
    var w = elem.offsetWidth;
    var h = elem.offsetHeight;
	
    var l = 0;
    var t = 0;
	
    while (elem)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return {"left":l, "top":t, "width": w, "height":h};
}

function showHelpQuestion(symbol_code)
{
    $.facebox(function() {
        $.get('/help_question.html?symbol_code='+symbol_code, function(data) {
            jQuery.facebox(data)
        })
    });
}