var z=4;

function showPlayer(url)
{
	var win = window.open(url, "rteplayer", "height=560,width=860,status=yes,toolbar=no,menubar=no,location=no");
	win.focus();
}

function iAppear(id)
{
	document.getElementById(id).style.visibility = "visible";
	z++;
	document.getElementById(id).style.zIndex = z;
}


function cAppear(id)
{
	document.getElementById(id).style.visibility = "visible";
	z++;
	document.getElementById(id).style.zIndex = z;

}


var url = "http://www.rte.ie/dynamic/rating/default.aspx?url=" + escape(location.href) + _getIdParamStr();

window.addEvent('domready', function() {
    new Ajax(url, {
        method: 'get',
        update: $('starRating')
    }).request();
});

function Vote(i)
{
    new Ajax(url + "&rating=" + i + "&service=7000000", {
        method: 'get',
        update: $('starRating')
    }).request();
}

function _getIdParamStr()
{
    var el = document.getElementsByName("DC.identifier");
    
    if(el.length > 0 && el[0].content)
    {
        el2 = el[0].content.split(":");
        if(el2.length == 3)
        {
        	return "&id=" + el2[2];
        }
    }
    
    return "";
}

function PrintPreview()
{
window.open(''+self.location+'?view=print'); 
}


//inject calculator into recipe page
window.addEvent('domready', function() {

		var el = $('RTE:Food:Ingredients');
		if(el)
		{
			el = el.getElement("h3");
			if(el)
			{
				
				var el3 = new Element('a').setProperty('href', 'javascript:print()').injectInside(el);
				el3.addClass("print_link");
				el3.setText("Print Recipe ");
				var el3 = new Element('img').setProperty('src', '/food//images/icons_print.gif').injectAfter(el3);
				
				
				var el1 = new Element('a').setProperty('href', 'javascript:share()').injectInside(el);
				el1.addClass("share_link");
				el1.setText("Share Recipe ");
				var el1 = new Element('img').setProperty('src', '/food//images/icons_share.gif').injectAfter(el1);
				
				
				var el2 = new Element('a').setProperty('href', 'javascript:openCalculator()').injectInside(el);
				el2.addClass("calc_link");
				el2.setText("Conversions ");
				var el2 = new Element('img').setProperty('src', '/food/images/calculator_icon.gif').injectAfter(el2);		
				

				
				
			}
		}
 });
 
function print()
{
	var win = PrintPreview();
}


function share()
{
	var win = MailToAFriend();
}



function openCalculator()
{
	var win = window.open("/food/conversion.html", "conversions", "height=560,width=690,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes");
	win.focus();
}
