// JavaScript Document

function OperaFix(init) 
	{  //reloads the window if Opera resized
  if (init==true)
	{
	if (navigator.userAgent.indexOf('Opera')!=-1)
		{
		document.pgW=window.innerWidth; 
		document.pgH=window.innerHeight; 
		onresize=OperaFix;
		}
	}
  	else if (window.innerWidth!=document.pgW || window.innerHeight!=document.pgH) 
	location.reload(); 
}

OperaFix(true);


function verticalalign(node, parentheight) /*for win ie */
 	{
	var objheight = node.getAttribute ('height');
	if ((typeof(objheight) != "undefined") && (objheight != null))
		{		
		node.style.marginTop = parseInt((parentheight-objheight)/2) + 'px';
		}
	}
	
// for Presspictures:

var openPopUp = -1;


function togglePopUp (node, action)
	{
	if (action=='open')
		{
		if (openPopUp == -1)
			{
			node.parentNode.childNodes[2].style.display='block';
			openPopUp = node;
			}
		else
			{
			openPopUp.parentNode.childNodes[2].style.display='none';
			node.parentNode.childNodes[2].style.display='block';
			openPopUp = node;		
			}	
		}
	else
		{	
		node.parentNode.style.display='none';
		openPopUp = -1;
		}
	}


// Protect

if (window.jQuery)
	{
		$(document).ready(function() {
		$("a[href*=' '], a[href*='%20']").click(function() {
			var realemail = '';
			var email = $(this).attr("href");
			if (email.indexOf("mailto:") == -1)
				{
				if (email.indexOf(" ") != -1) 
				  {
				  var emailArray = email.split(" ");
				  }
				  else
				  {
				  var emailArray = email.split("%20");
				  }
				for (var i=emailArray.length; i>=0; i=i-1)
					{
						if (typeof emailArray[i] != 'undefined')
						{
							if (i==2)
							{
							realemail = realemail + emailArray[i] + '@';
							}
							else
							{
							realemail = realemail + emailArray[i] + '.';
							}
						}
					}
				realemail = realemail.substring(0, realemail.length -1);
				realemail = 'mailto:' + realemail;
				$(this).attr("href", realemail);
				//alert (realemail);
				}
			});
		});
	}
