if (this.name = '')
	this.name='shEAMainWnd';
	
this.focus();

function imagePopUp(urlToOpen) {
		var x = (screen.width-800)/2, y = (screen.height-800)/2;
	  OpenWin = this.open(urlToOpen, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes, screenX="+x+", screenY="+y+", left="+x+", top="+y);
}

function printerFriendly(urlToOpen) {
		var x = (screen.width-600)/2, y = (screen.height-400)/2;
	  OpenWin = this.open(urlToOpen, "CtrlWindow", "width=600,height=400,toolbar=no,menubar=yes,location=no,scrollbars=yes,resizable=no, screenX="+x+", screenY="+y+", left="+x+", top="+y);
}

function recommend(urlRecommandForThisArticle) {
		var x = (screen.width-400)/2, y = (screen.height-260)/2;
	  OpenWin = this.open(urlRecommandForThisArticle, "CtrlWindow", "width=400,height=260,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no, screenX="+x+", screenY="+y+", left="+x+", top="+y);
}

function printPage(URLToPrint) {
	var x = (screen.width-545)/2, y = (screen.height-500)/2;	
	URLToPrint = URLToPrint.replace(/\@/gi,"/");
	URLToPrint = URLToPrint.replace(/\*/gi,"_");
	URLToPrint += "&printSitePage=1";
  OpenWin = this.open(URLToPrint, "CtrlWindow", "width=545,height=500,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no, screenX="+x+", screenY="+y+", left="+x+", top="+y);
}



function getElementPosition(elem) {
    var offsetTrail = elem;
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return {left:offsetLeft, top:offsetTop};
	}


function SetJSCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

function ReadCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}


function FixFlash(){

var objects = document.getElementsByTagName('object');
	for (var i=0; i<objects.length; i++) {
		 var o = objects[i];
		 var h = o.outerHTML;
		if(h){
			var params = "";
			for (var j = 0; j<o.childNodes.length; j++) {
			 var p = o.childNodes[j];
			 if (p.tagName == "PARAM"){		
			   params += p.outerHTML;
			 }
			}
			
			//The generated "params" string is spliced into the outerHTML code:
			
			var tag = h.split(">")[0] + ">";
			var newObject = tag + params + o.innerHTML + " </OBJECT>";
			
			//And, finally, the new generated HTML replaces the original:
			
			o.outerHTML = newObject; 
		}
	}
}

function showPrevious(){
		 var noImages = aHpImages.length;
		 lastHPKey--;
		 if(lastHPKey < 0)
		 	lastHPKey = aHpImages.length - 1;
		 el = document.getElementById('imageReceiver');
		 el.src = aHpImages[lastHPKey][0];
		 
		 el.onclick = function(){
 				if(aHpImages[lastHPKey][2] > 0)
 					window.location = document.getElementsByTagName('base')[0].href + 'index.html/articles?articleID=' + aHpImages[lastHPKey][2];
 				else
 					window.location = aHpImages[lastHPKey][1];
 				};
 		el.style.cursor = "pointer"; 

		if(aHpImages[lastHPKey][4]){
			gE('headlineTeaserBackground').innerHTML = aHpImages[lastHPKey][4];
			gE('headlineTeaser').innerHTML = aHpImages[lastHPKey][4];
			gE('headlineTeaserBackground').style.display = '';
			gE('headlineTeaser').style.display = '';
		}
		else{
				gE('headlineTeaserBackground').style.display = 'none';
				gE('headlineTeaser').style.display = 'none';
			}
		
		if(aHpImages[lastHPKey][2] > 0)
			gE('hrefReceiver').href = document.getElementsByTagName('base')[0].href + 'index.html/articles?articleID=' + aHpImages[lastHPKey][2];
		else
			gE('hrefReceiver').href = aHpImages[lastHPKey][1];
		
		gE('hrefReceiver').innerHTML = "<strong>" + aHpImages[lastHPKey][3] + "</strong>";
	}
	
function showNext(){
		 var noImages = aHpImages.length;
		 lastHPKey++;
		 if(lastHPKey > aHpImages.length - 1)
		 	lastHPKey = 0;
		 el = document.getElementById('imageReceiver');
		 el.src = aHpImages[lastHPKey][0];
		 

 		el.onclick = function(){
 				if(aHpImages[lastHPKey][2] > 0)
 					window.location = document.getElementsByTagName('base')[0].href + 'index.html/articles?articleID=' + aHpImages[lastHPKey][2];
 				else
 					window.location = aHpImages[lastHPKey][1];
 				};
 		el.style.cursor = "pointer"; 

		if(aHpImages[lastHPKey][4]){
			gE('headlineTeaserBackground').innerHTML = aHpImages[lastHPKey][4];
			gE('headlineTeaser').innerHTML = aHpImages[lastHPKey][4];
			gE('headlineTeaserBackground').style.display = '';
			gE('headlineTeaser').style.display = '';
		}
		else{
				gE('headlineTeaserBackground').style.display = 'none';
				gE('headlineTeaser').style.display = 'none';
			}
		
		if(aHpImages[lastHPKey][2] > 0)
			gE('hrefReceiver').href = document.getElementsByTagName('base')[0].href + 'index.html/articles?articleID=' + aHpImages[lastHPKey][2];
		else
			gE('hrefReceiver').href = aHpImages[lastHPKey][1];
		
		gE('hrefReceiver').innerHTML = "<strong>" + aHpImages[lastHPKey][3] + "</strong>";
	}
	
function gE(el) {
		return document.getElementById(el);
}

function loadSubMenu(articleID){
		document.getElementById('menuTable['+articleID+']').style.display = '';
		document.getElementById('menuTableTrigger['+articleID+']').className = 'active';
		for (i in aMenus)
				if(i != articleID){
					document.getElementById('menuTable['+i+']').style.display = 'none';
					document.getElementById('menuTableTrigger['+i+']').className = '';
				}	
	}

function openReferences(referenceID) {
		var x = (screen.width-750)/2, y = (screen.height-500)/2;
		baseHref = document.getElementsByTagName('base')[0].href;
		urlToOpen = baseHref+"index.html/references|details?referenceID="+referenceID;
	  OpenWin = this.open(urlToOpen, "CtrlWindow", "width=750,height=500,toolbar=no,menubar=yes,location=no,scrollbars=yes,resizable=no, screenX="+x+", screenY="+y+", left="+x+", top="+y);
}

var aMenusVisible = new Array();
function showMenu(sectionID){
		var defaultPosition = getElementPositionID('trigger_menuItems[1]');
		var aux = defaultPosition.top + 15;

		var leftPosPx = gE('trigger_menuItems['+sectionID+']').offsetLeft + 5;
		if(document.all){
			leftPosPx	+= 300;
		}

		
		gE('menuItems['+sectionID+']').style.left = leftPosPx + "px";
		gE('menuItems['+sectionID+']').style.top = aux + "px";
		gE('menuItems['+sectionID+']').style.display = 'block';
//		alert(aux);
		aMenusVisible[sectionID] = 1;
	}

function hideMenu(sectionID){
		aMenusVisible[sectionID] = 0;
		setTimeout('doHideMenu('+sectionID+');', 30);
		
		
	}	
function doHideMenu(sectionID){
		if(!aMenusVisible[sectionID])
			gE('menuItems['+sectionID+']').style.display = 'none';
	}


function getElementPositionID(elemID) {
    var offsetTrail = document.getElementById(elemID);
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return {left:offsetLeft, top:offsetTop};
	}
	
	


function slideITFade(direction){
		el = gE('pozaAcasa01');
		if(direction == 'down'){
			el.style.opacity = parseFloat(el.style.opacity) - 0.1;
				if(el.style.opacity > 0)
					setTimeout('slideITFade(\'down\')', 100);
				else{
						runSwap();
						setTimeout('slideITFade(\'up\')', 2000);;
					}
			}
		else{
			el.style.opacity = parseFloat(el.style.opacity) + 0.1;

			if(el.style.opacity < 1){
				setTimeout('slideITFade(\'up\')', 100);
			}
			else
				setTimeout('slideITFade(\'down\')', 5000);
			}
	}	

function runSwap(){
		el = gE('pozaAcasa01');
		if(akey > aSlideShow.length-1)
			akey = 0;
		el.style.backgroundImage = 'url('+aSlideShow[akey]+')';	
		akey++;
 }
 
function slideITFadeFIE(direction){
		el = gE('pozaAcasa01');
		
		if(direction == 'down'){		
				el.filters[0].opacity = parseInt(el.filters[0].opacity) - 10;
				if(parseInt(el.filters[0].opacity) > 0){
					setTimeout('slideITFadeFIE(\'down\')', 100);
				}
				else{
						runSwap();
//						slideITFadeFIE('up');
						setTimeout('slideITFadeFIE(\'up\')', 2000);;
					}
			}
		else{
			el.filters[0].opacity = parseInt(el.filters[0].opacity) + 10;

			if(parseInt(el.filters[0].opacity) < 100){
				setTimeout('slideITFadeFIE(\'up\')', 100);
			}
			else
				setTimeout('slideITFadeFIE(\'down\')', 5000);
			}
	}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;

  // IE/Win
  obj.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+ opacity + ");";

  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;

  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;

  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}		