//Function added on request from José Ignacio Hernández
function OpenMicrositeEs(url, category){
	//var windowsetting="'width=870px,height=472px,left=80,top=100,resizable=no,status=1,scrollbars=1'";	
	var windowsetting="width=870px,height=472px,left=80,top=100,resizable=no,status=1,scrollbars=1";
	url = "http://www.univadis.es/PortalTemplates/JumpPage.jsp?category="+category+"&toURL=http://www.univadis.es/commonauth/out?r=http%3A%2F%2Fwww2.univadis.net%2FcomAuth%2FRoutingController%26rememberMe%3Don%26request_url%3D" + url;
	var	newWindow = window.open(url,"NewPage",windowsetting);
}

//Functions moved from PopulateCategories.jsp start
function Category(name,catId,flag,isJavascript,slpCatId) {
				this.name = name;
				this.catId = catId;
				this.flag = flag;
				this.isJavascript = isJavascript;
				this.slpCatId = slpCatId;
			}

			function populateMedicalContentDropdown() {
				var medDD = document.getElementById("MedicalCats");
                medDD.options.length=0;

                medDD.options.length ++;
                medDD.options[0].value = "0";
                medDD.options[0].text = addMediContent;

                var j=0;

                i = groupIndex["Medical"];
                while ( i < categoryList.length && categoryList[i].name != "##DUMMY-CATEGORY##" ) {
                    if ( (categoryList[i].flag == "0") || (categoryList[i].flag == "2") ) {
                        j++;

                        medDD.options.length ++;
                        medDD.options[j].value = categoryList[i].catId;
                        medDD.options[j].text = categoryList[i].name;
                    }
                    i++;
                }
            }

            function handleMedicalMouseClick() {
                var x=document.getElementById("MedicalCats");
                var selid = x.options[x.selectedIndex].value;
                if( selid != 0) {
                    document.AddMedicalContent.submit();
                }
            }

            function handleMedicalKeyPress(event) {
                var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
                if( keyCode == 13 ) {
                    document.AddMedicalContent.submit();
                }
            }
			function populateMoreContentDropdown() {

				var moreDD = document.getElementById("MoreCats");
                moreDD.options.length=0;

                moreDD.options.length ++;
                moreDD.options[0].value = "0";
                moreDD.options[0].text = addMoreContent;

                var j=0;

                i = groupIndex["More"];
                while ( i < categoryList.length && categoryList[i].name != "##DUMMY-CATEGORY##" ) {
                    if ( (categoryList[i].flag == "0") || (categoryList[i].flag == "2") ) {
                        j++;
                        moreDD.options.length ++;

                        moreDD.options[j].value = categoryList[i].catId;
                        moreDD.options[j].text = categoryList[i].name;
                    }
                    i++;
                }
            }

            function handleMoreMouseClick() {
                var x=document.getElementById("MoreCats");
                var selid = x.options[x.selectedIndex].value;
                if( selid != 0) {
                    document.AddMoreContent.submit();
                }
            }

            function handleMoreKeyPress(event) {
                var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
                if( keyCode == 13 ) {
                    document.AddMoreContent.submit();
                }
            }
			function displayMedicalContentDropdown(elementID) {
				var listName = "Medical";
				var html = '';
				selectedID = '';
				var selectedValue = "this.value";

				html += "<form name='AddMedicalContent' action='/personalization/CategoryAdd.jsp' method='POST'><input type='hidden' value=" + UserName + " name='UserName' /><input type='hidden' value='4' name='paneid' /><input type='hidden' value='1' name='medical_addtop' /><input type='hidden' value=" + PageName + " name='PageName' /><input type='hidden' value=" + servletURL + " name='RedirectURL' /><select id='MedicalCats' class='' name='Category' onMouseover=\"Javascript:document.getElementById('MedicalCats').focus();\" onFocus='Javascript:populateMedicalContentDropdown();' onKeyPress='Javascript:handleMedicalKeyPress(event)' onclick='Javascript:handleMedicalMouseClick();'><option>"+ addMediContent + "</option></select>";				
				document.getElementById(elementID).innerHTML = html;
			}

			function displayMoreContentDropdown(elementID) {
				var listName = "More";
				var html = '';
				selectedID = '';
				var selectedValue = "this.value";

				html += "<form name='AddMoreContent' action='/personalization/CategoryAdd.jsp' method='POST'><input type='hidden' value=" + UserName + " name='UserName' /><input type='hidden' value='1' name='more_addtop' /><input type='hidden' value='5' name='paneid' /><input type='hidden' value=" + PageName + " name='PageName' /><input type='hidden' value=" + servletURL + " name='RedirectURL' /><select id='MoreCats' class='' name='Category' onMouseover=\"Javascript:document.getElementById('MoreCats').focus();\" onFocus='Javascript:populateMoreContentDropdown();' onKeyPress='Javascript:handleMoreKeyPress(event)' onclick='Javascript:handleMoreMouseClick();'><option>"+ addMoreContent +"</option></select>";

				document.getElementById(elementID).innerHTML = html;
            }
//Functions from PopulateCategories.jsp ends

//Sidenavigation related functions start
	 //  This function checks for the request Url in the HashTable of urls, if it finds a match, 
	 //  uses it's key to get the <li> elementObject associated with that key, 
	 //  unhides all it's parent <ul> elements and child <ul> element, which were hidden by default. 
	function checkUrl(reqUrl) {
		var re = /hide/gi;
		for( i in urls) {
			var found = false;
			if(reqUrl == urls[i]) {
				found = true;
				var liNode = document.getElementById(i);
				while (liNode.className != 'level1') {
					var newClass = liNode.parentNode.className;
					newClass = newClass.replace(re,'');
					liNode.parentNode.className = newClass;
					liNode = liNode.parentNode;
				}
				liNode = document.getElementById(i);
				for( j = 0;j < liNode.childNodes.length;j++) {
					if(liNode.childNodes[j].className == 'level2 hide') {
						liNode.childNodes[j].className='level2';
					} else if(liNode.childNodes[j].className == 'level3 hide') {
						liNode.childNodes[j].className='level3';
					}
				}
				break;
			}
		}
		if(!found) {
			for(i in matchUrls) {
				var temp = new Array();
				temp = matchUrls[i].split('|||');
				var flag = false;
				for(index = 0;index < temp.length;index++) {
					if(reqUrl.startsWith(temp[index])) {
						var liNode = document.getElementById(i);
						while (liNode.className != 'level1') {
							var newClass = liNode.parentNode.className;
							newClass = newClass.replace(re,'');
							liNode.parentNode.className = newClass;
							liNode = liNode.parentNode;
						}
						liNode = document.getElementById(i);
						for( j = 0;j < liNode.childNodes.length;j++) {
							if(liNode.childNodes[j].className == 'level2 hide') {
								liNode.childNodes[j].className='level2';
							} else if(liNode.childNodes[j].className == 'level3 hide') {
								liNode.childNodes[j].className='level3';
							}
						}
						flag = true;
						break;
					}
				}
				if(flag) {
					break;
				}
			}
		}
	}

	// This function gets <li> element's ID as the input parameter and 
	// gets it's corresponding Url from Hashtable, and opens that page.
	function gotoUrl(url_id) {
		var reqURL = urls[url_id];
		var regExp = /\'/gi;
		reqURL = reqURL.replace(regExp,"\'");
		var reqURLTop = encodeURIComponent(reqURL);
		reqURL = escape(reqURL);
		if( (PageName == 'News' || PageName == 'Search' || PageName == 'Home' || PageName == 'Services' || PageName == 'TrainTheBrain_Detail') && (reqURL.indexOf("MicrositeWindow")==-1) ) {
			window.location.href = '/PortalTemplates/JumpPage.jsp?category=' + PageName + '_sidenavigation&toURL=' + reqURLTop;
		}else {
			reqURL = unescape(reqURL);
			window.location.href = reqURL;
		}
	}
	String.prototype.startsWith = function(sStart) {
		return (this.substr(0,sStart.length)==sStart);
	}
	// This function checks the reqUrl in Hastable of MatchUrls and if it finds one, 
	// uses it's key to get <li> element's Id, changes it's class to "selected".
	// If reqUrl is found more than once in the hashtable,child entry takes precedence over parent entry.
	// If reqUrl is not found in Hashtable of MatchUrls search for reqUrl in Hashtable of urls
	// and get <li> element's Id and change it's class to "selected".
	function makeLinkActiveMatch(reqUrl) {
		var flag = false;
		var selNode = '';
		for( i in matchUrls) {
			var temp = new Array();
			temp = matchUrls[i].split('|||');
			for(index = 0;index < temp.length;index++) {
				if(reqUrl.startsWith(temp[index])) {
					if (!flag) {
						selNode = i;
						flag = true;
					}
					else {
						var t2 = selNode.split("_");
						var tnew = i.split("_");
						if (t2.length < tnew.length) {
							selNode = i;
						}
					}
				}
			}
		}
		if(selNode!=''){
			var liElement = document.getElementById(selNode);
			if(liElement!=null){
				liElement.className = liElement.className + ' selected';
			}
		}

		if(!flag) {
			makeLinkActiveActual(reqUrl);
		}
	}
	function makeLinkActiveActual(reqUrl) {
		for( j in urls) {
			if(reqUrl == urls[j]) {
				var liNode = document.getElementById(j);
				liNode.className = liNode.className + ' selected';
				break;
			} 
		}
	}
	function removeBorder(id) {
		if(document.getElementById(id) != null) {
			var level1Li = document.getElementById(id).lastChild;
			level1Li.className = 'noborder';
			id = id.replace('1','2');
			if(document.getElementById(id) != null) {
				var level2Li = document.getElementById(id).lastChild;
				level2Li.className = 'noborder';
				id = id.replace('2','3');
				if(document.getElementById(id) != null) {
					var level3Ul = document.getElementById(id);
					for(j =0;j < level3Ul.childNodes.length;j++) {
						level3Ul.childNodes[j].className = 'noborder';
					}
				}
			}
		}
	}

	function isChildExist() {
		for(childId in childExist) {
			var liNodeObject = document.getElementById(childId);
			var last_li = 0;
			var subchild = childId + "_";
			var flagHide = true;
			for ( xy = 0;xy < 5 ;xy++ )	{
				var id_subchild = subchild + xy;
				if(document.getElementById(id_subchild) != null) {
					flagHide = false;
					last_li = xy;
				}
			}
			if(flagHide) {
				liNodeObject.className = "hide";
			}else{
				document.getElementById(subchild+last_li).className=document.getElementById(subchild+last_li).className + ' noborder';
			}
		}
	}
//sidenavigation related functions end

function Get_Cookie(name){
  var start = document.cookie.indexOf(name+"=");
  var len = start+name.length+1;
  if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
  if (start == -1) return null;
  var end = document.cookie.indexOf(";",len);
  if (end == -1) end = document.cookie.length;
  return unescape(document.cookie.substring(len,end));
}
function Set_Cookie(name,value,expires,path,domain,secure){
	var date = new Date();
	//date.setTime(date.getTime()+(expires*24*60*60*1000));
	if(expires){
		document.cookie = name + "=" +escape(value) + ";expires=" + expires.toGMTString() +
		( (path) ? ";path=" + path : "") + 
		( (domain) ? ";domain=" + domain : "") +
		( (secure) ? ";secure" : "");
	}
	else{
	date.setTime(date.getTime()+(expires*24*60*60*1000));
	document.cookie = name + "=" +escape(value) + ";expires=" + date.toGMTString() +
    ( (path) ? ";path=" + path : "") + 
    ( (domain) ? ";domain=" + domain : "") +
    ( (secure) ? ";secure" : "");
	}
}
function Del_Cookie(name) {
  var e=new Date();
  e.setDate(e.getDate()-1);
  Set_Cookie(name,"",e,"","","");
}
function replaceSubstring(inputString, fromString, toString) {
   // Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
	  var midStringSize=midStrings.length;
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStringSize; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStringSize + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;  
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function 
function rs(n,u,w,h) {
	var remote = window.open(u, n, 'width=' + w + ',height=' + h +',resizable=yes,scrollbars=yes');
	if (remote != null) {
		if (remote.opener == null)
		Remote.opener = self;
		window.name = 'myYahooRoot';
		remote.location.href = u;
	}
}
function enablelanguage(country) {
		document.cookie="CH_Login"+"="+country+"; expires=Monday, 04-Apr-2010 05:00:00 GMT"+";path=/";
}
function goToStart(locale){
	if(locale.length<1) return;
	location.replace("/medical_and_more/"+locale+"_Login");
}
//The following fucntion is an advanced version of Get_Cookie, especially used for DeepLinking
function getCookie(NameOfCookie){
    if (document.cookie.length > 0){
    begin = document.cookie.indexOf(NameOfCookie+"=");
        if (begin != -1){
        begin += NameOfCookie.length+1;
        end = document.cookie.indexOf(";", begin);
                if (end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(begin, end));
        }
    }
    return null;
}
//The following fucntion is an advanced version of Set_Cookie, especially used for DeepLinking
function setCookie(NameOfCookie, value, expiredays){
    var ExpireDate = new Date ();
    var path = "/";
    ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
    document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()) + ((path) ? "; path=" + path : "");
}
//The following fucntion is an advanced version of Del_Cookie, especially used for DeepLinking
function delCookie(NameOfCookie){
    if (getCookie(NameOfCookie)) {
    setCookie(NameOfCookie,"",-1);
    }
}

// The following function opens a new window as popup
function OpenNewWindow(url,scrolling,resize,wdth,hght,windowname){
	if(url.indexOf("toURL") > 0){
		var urlArray = url.split("toURL=");
		var encodedUrl=encodeURIComponent(urlArray[1]);
		url = urlArray[0] + "toURL=" + encodedUrl;
	}
	var newWindow;
	var windowsetting="'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+scrolling+",resizable="+resize+",left=250,top=210,width="+wdth+",height="+hght+"'";
	if(windowname =="")
		newWindow = window.open(url,"univadis", windowsetting);
	else
		newWindow = window.open(url,windowname, windowsetting);
	
}
//  The following function is used for print page
function printPage(url) {
	url="http://"+portal_url+url.substr(url.indexOf("/medical_and_more"));
	url = url+"&dummy=yes";
	url = escape(url);
	window.open("/medical_and_more/Print?url="+url+"&locale="+UserLocale,"Preview","width=670px,height=657px,resizable=no,scrollbars=yes");
	return false;
}

function goToHelpCenter(id) {
	var url = "/PortalTemplates/HelpCenter.jsp?helpCenterID=1002000";
	if(id != null) {
		url = "/PortalTemplates/HelpCenter.jsp?helpCenterID=" + id;
	}		
	window.open(url,"HelpCenter","width=740px,height=472px,left=150,top=100,resizable=no,status=1,scrollbars=1");
}
function goToContextHelp(id) {
	if(getCookie("TIBCOSessionID") != null){
	window.open("/medical_and_more/ContextualHelpPopUp?helpCenterID="+id+"&logged=yes","ContextualHelp","width=511px,height=280px,left=250,top=210,resizable=no,status=0,scrollbars=1");
	}
	else{
	window.open("/medical_and_more/ContextualHelpPopUp?helpCenterID="+id+"&logged=no","ContextualHelp","width=511px,height=280px,left=250,top=210,resizable=no,status=0,scrollbars=1");
	}
}

function goToCMSHelpCenter(id,locale) { 
	var url = ""+CMS_ContentServer+"/univadis/helpCentre/en_GB/univadis/about-the-site.html";
	if(id != null) {
		if(locale == "fr_FR")
		{
			url = ""+CMS_ContentServer+"/univadis/helpCentre/"+locale+"/" + id;
		}
		else
		{ 
		url = ""+CMS_ContentServer+"/univadis/helpCentre/"+locale+"/" + id + "?MEACountry=" + Country;
		}
	}		
	window.open(url,"HelpCenter","width=740px,height=472px,left=150,top=100,resizable=no,status=1,scrollbars=1");
	
}


//function goToCMSContextHelp(id,locale) { 

// window.open(""+CMS_ContentServer+"/univadis/helpCentre/"+locale+"/quick-help/"+id+"","ContextualHelp","width=511px,height=280px,left=250,top=210,resizable=no,status=0,scrollbars=1");	 
//}

function whichBrs() {
			var agt=navigator.userAgent.toLowerCase();
			if (agt.indexOf("opera") != -1) return 'Opera';
			if (agt.indexOf("staroffice") != -1) return 'Star Office';
			if (agt.indexOf("webtv") != -1) return 'WebTV';
			if (agt.indexOf("beonex") != -1) return 'Beonex';
			if (agt.indexOf("chimera") != -1) return 'Chimera';
			if (agt.indexOf("netpositive") != -1) return 'NetPositive';
			if (agt.indexOf("phoenix") != -1) return 'Phoenix';
			if (agt.indexOf("firefox") != -1) return 'Firefox';
			if (agt.indexOf("safari") != -1) return 'Safari';
			if (agt.indexOf("skipstone") != -1) return 'SkipStone';
			if (agt.indexOf("msie") != -1) return 'Internet Explorer';
			if (agt.indexOf("netscape") != -1) return 'Netscape';
			if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
			if (agt.indexOf('\/') != -1) {
			if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
			return navigator.userAgent.substr(0,agt.indexOf('\/'));}
			else return 'Netscape';} else if (agt.indexOf(' ') != -1)
			return navigator.userAgent.substr(0,agt.indexOf(' '));
			else return navigator.userAgent;
}


function goToCMSContextHelp(id,locale) {

 var url = "" + window.location.href;
 var index = url.lastIndexOf('=');
 var urlLocale = url.substring(index+1, url.length);
 var queryString = "?MEACountry=" + Country;
 
 if(whichBrs()=='Firefox'||whichBrs()=='Safari'){
 window.open(""+CMS_ContentServer+"/univadis/helpCentre/"+locale+"/quick-help/"+id+ queryString + "","ContextualHelp","width=493px,height=280px,left=250,top=210,resizable=no,status=0,scrollbars=1");
 }
 else{
 window.open(""+CMS_ContentServer+"/univadis/helpCentre/"+locale+"/quick-help/"+id+ queryString + "","ContextualHelp","width=511px,height=280px,left=250,top=210,resizable=no,status=0,scrollbars=1");
 }
}



function goToMEACMSContextHelp(id,locale) {

 var url = "" + window.location.href;
 var index = url.lastIndexOf('=');
 var urlLocale = url.substring(index+1, url.length);
 var queryString = "?MEACountry=" + urlLocale;

 window.open(""+CMS_ContentServer+"/univadis/helpCentre/"+locale+"/quick-help/"+id+ queryString + "","ContextualHelp","width=511px,height=280px,left=250,top=210,resizable=no,status=0,scrollbars=1");
}

function openHCLink(url,type,height){
        if(type == 1){
                window.location.href=url;
        }
        else if(type == 2){
                window.opener.location.href = url;
                window.opener.focus();
        }
        else if(type == 3) {
                window.open(url,"NewPage");

        }
        else {
              if(height != ""){
                window.open(url,"Contactunivadis","width=495px,height="+height+",left=250,top=210,resizable=no,status=1,scrollbars=0");
			  }else{
				window.open(url,"Contactunivadis","width=495px,height=422px,left=250,top=210,resizable=no,status=1,scrollbars=0");
			  } 
        }
}
function goToContextHelp(id,locale) { 
 window.open("/medical_and_more/ContextualHelpPopUp?helpCenterID="+id+"&logged=no&locale="+locale+"","ContextualHelp","width=511px,height=280px,left=250,top=210,resizable=no,status=0,scrollbars=1");	 
}
function getUnivadisDate(timeinsec){
 
	timeinsec = timeinsec * 1000;

    var now,str,tz,end,beg,year,date,time;

	ie = (document.all)?true:false;
	now = new Date(timeinsec);
	tz = "";
	if (ie) {
 		str=now.toString();
  		end=str.lastIndexOf(" ");
  		beg=str.lastIndexOf(" ",end-1)+1;
  		if (ie&&end-beg==3) {
    		tz=" "+str.charAt(beg)+"T";
  		}
	}
	date = now.getDate();
	date = (date > 9)?date:"0"+date;
	if (document.all){
 		year = now.getYear();
	}
	else {
 		year = now.getYear() + 1900;
	}
	var month = now.getMonth();
	month =  month +1;
	month = (month > 9)?month:"0"+month;
	year = year%1000;
	year = (year > 9)?year:"0"+year;

	time=date+"/"+month+"/"+year;

	return time;
}

//	The folliwng function changes the image of an icon
function changeIcon(img,fileName) {
	
	img.src = "/RI/icons/"+fileName;
}

//The following function makes the focus on Username field when the login page loads for each country
function Usernamefocus(){
	try{
		document.forms[0].Username.focus();
	}
	catch(e){
		try{
			enableMoveContent();
		}
		catch(e){
		}
	}
}

//The following function is to get the groupid for more news, epgr and events
function getGroupValue(con_subgrpid,type){
	var grpidvalactual ='';
	if (type=='review'){

		var grpid_epgr = new Array('Audio','Hardware','Software','Mobile Devices','Photography','Electronic Textbooks','PC Review Special','General Software','Photography and Video','Medical Books','Non-Fiction','Fiction');
		var grpidval_epgr = new Array('audio','hardware','software','mobile_devices','photography','electronic_textbooks','review_special','general_software','photography_video','book_review_medical_books','book_review_non_fiction','book_review_fiction');
		for (var i=0;i<12;i++){
			if (grpid_epgr[i] == con_subgrpid){
				grpidvalactual = grpidval_epgr[i];
				break;
			}
		}
	}else if (type=='more'){

		var grpid_morenews = new Array('1','2','3','4','5','6','7','8','9','10','11','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','31','32','33','34','39','40','41','38','50','48','49','51','52','53','54','55','56','57','42','43','44','45','46');
		var grpidval_morenews = new Array('more_news_local','more_news_world','more_news_financial','more_news_sport','more_news_health','more_news_tennisspecial','more_news_footballspecial','more_dunya_haberleri','more_spor_haberleri','more_news_high_tech','es_cultura','be_practicemanagement','be_health_politics','be_financial','be_sports','be_entertainment','de_praxisradar','de_local','de_world','de_sports','de_economics','de_spec_med','de_practicemgmt','de_arzte_zeitung_medizin','de_arzte_zeitung_kultur','de_arzte_zeitung_medcon_gesun','anp_sports','anp_local','anp_world','anp_financial','tt_inrikes','tt_internationellt','tt_ekonomi','tt_sport','more_news_national','business_news','health_news','sports_news','world_news','nouvelles_santes','nouvelles_financieres','nouvelles_internationales','nouvelles_regionales','nouvelles_sportives','world_more_news','local_more_news','financial_more_news','sports_more_news','top_stories_more_news');
		for (var i=0;i<grpid_morenews.length;i++){
			if (grpid_morenews[i] == con_subgrpid){
				grpidvalactual = grpidval_morenews[i];
				break;
			}
		}
	}else if (type=='events'){
		var grpid_aoi = new Array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24');
		var grpidval_aoi = new Array('events_allergy','events_cardiology','events_dermatology','events_diabetes','events_endocrinology','events_gastroenterology','events_infectious','events_general_primary','events_nephrology_urology','events_neurology','events_oncology','events_ophthalmology','events_orthopaedics','events_pain','events_pediatrics','events_pulmonology','events_rheumatology','events_surgery','events_womans_health','events_mental_health','events_emergency_trauma','events_sports_medicine','events_gerontology','events_orl');
		for (var i=0;i<24;i++){
			if (grpid_aoi[i] == con_subgrpid){
				grpidvalactual = grpidval_aoi[i];
				break;
			}
		}
	}else if (type=='medical'){
		var grpid_aoi = new Array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24');
		var grpidval_aoi = new Array('allergy_news','cardiology_news','dermatology_news','diabetes_news','endocrinology_news','gastroenterology_news','infectious_news','general_primary_news','nephrology_urology_news','neurology_news','oncology_news','ophthalmology_news','orthopaedics_news','pain_news','pediatrics_news','pulmonology_news','rheumatology_news','surgery_news','womans_health_news','mental_health_news','emergency_trauma_news','sports_medicine_news','gerontology_news','orl_news');
		for (var i=0;i<24;i++){
			if (grpid_aoi[i] == con_subgrpid){
				grpidvalactual = grpidval_aoi[i];
				break;
			}
		}
	}else if (type=='firstview'){
		var grpid_aoi = new Array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24');
		var grpidval_aoi = new Array('elsevier_first_view_allergy','elsevier_first_view_cardiology','elsevier_first_view_dermatology','elsevier_first_view_diabetes','elsevier_first_view_endocrinology','elsevier_first_view_gastroenterology','elsevier_first_view_infectious','elsevier_first_view_general_primary','elsevier_first_view_nephrology_urology','elsevier_first_view_neurology','elsevier_first_view_oncology','elsevier_first_view_ophthalmology','elsevier_first_view_orthopaedics','elsevier_first_view_pain','elsevier_first_view_pediatrics','elsevier_first_view_pulmonology','elsevier_first_view_rheumatology','elsevier_first_view_surgery','elsevier_first_view_womans_health','elsevier_first_view_mental_health','elsevier_first_view_emergency_trauma','elsevier_first_view_sports_medicine','elsevier_first_view_gerontology','elsevier_first_view_orl');
		for (var i=0;i<23;i++){
			if (grpid_aoi[i] == con_subgrpid){
				grpidvalactual = grpidval_aoi[i];
				break;
			}
		}
	}else if(type=='DEmore'){
		var grpid_aoi = new Array('20','21','22','23','24');
		var grpidval_aoi = new Array('deutschland','international','sport','wirtschaft','gesundheit');
		for(i=0;i<5;i++){
			if (grpid_aoi[i] == con_subgrpid){
				grpidvalactual = grpidval_aoi[i];
				break;
			}
		}
	}
	return grpidvalactual;
}
/************************************************************
These two functions are used in UK forums passthrough category. 
Added by suresh on 25/4/2006
*************************************************************/
function openASK(targetval){
	targetURL = 'http://www.univadis.co.uk/PortalTemplates/JumpPage.jsp?category=discussion_forums&link=forums_ask_univadis&toURL=' +
	escape(targetval + '&univadisid=' + UserName + '&specialty=' +Speciality + '&zipcode=' +ZipCode+'&eml=' +Email);				
	window.open(targetURL, 'ASK', 'width=800,height=600,toolbar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');
}
function open2ND(targetval){
	targetURL = 'http://www.univadis.co.uk/PortalTemplates/JumpPage.jsp?category=discussion_forums&link=forums_2nd_opinion&toURL=' + 			
	escape(targetval + '&univadisid=' + UserName + '&specialty=' +Speciality + '&zipcode=' +ZipCode+'&eml=' +Email);
	window.open(targetURL, '2ND',  'width=800,height=600,toolbar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');
}
function openAll(targetval){
	targetURL = 'http://www.univadis.co.uk/PortalTemplates/JumpPage.jsp?category=discussion_forums&link=listall&toURL=' +
	escape(targetval + '&univadisid=' + UserName + '&specialty=' +Speciality + '&zipcode=' +ZipCode +'&eml=' +Email);				
	window.open(targetURL, 'Webcast', 'width=800,height=600,toolbar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');
}
//Added for UK Podcasts and Webcast portlets.....
function openpod(targetval){
	targetURL = 'http://www.univadis.co.uk/PortalTemplates/JumpPage.jsp?category=webcast&link=radio_univadis&toURL=' +
	escape(targetval + '&univadisid=' + UserName + '&specialty=' +Speciality + '&zipcode=' +ZipCode +'&eml=' +Email);				
	window.open(targetURL, 'Podcast', 'width=800,height=600,toolbar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');
}
function podcastAll(targetval){
	targetURL = 'http://www.univadis.co.uk/PortalTemplates/JumpPage.jsp?category=webcast&link=radio_univadis&toURL=' +
	escape(targetval + '&univadisid=' + UserName + '&specialty=' +Speciality + '&zipcode=' +ZipCode +'&eml=' +Email);				
	window.open(targetURL, 'Podcast', 'width=800,height=600,toolbar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');
}
function openwebcast(targetval){
	targetURL = 'http://www.univadis.co.uk/PortalTemplates/JumpPage.jsp?category=webcast&link=univadis_tv&toURL=' +
	escape(targetval + '&univadisid=' + UserName + '&specialty=' +Speciality + '&zipcode=' +ZipCode +'&eml=' +Email);				
	window.open(targetURL, 'Webcast', 'width=800,height=600,toolbar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');
}
function webcastAll(targetval){
	targetURL = 'http://www.univadis.co.uk/PortalTemplates/JumpPage.jsp?category=webcast&link=univadis_tv&toURL=' +
	escape(targetval + '&univadisid=' + UserName + '&specialty=' +Speciality + '&zipcode=' +ZipCode +'&eml=' +Email);				
	window.open(targetURL, 'Webcast', 'width=800,height=600,toolbar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');
}

function webcast(targetval){
	targetURL = 'http://www.univadis.co.uk/PortalTemplates/JumpPage.jsp?category=webcast&link=univadis_tv&toURL=' +
        escape(targetval + '&univadisid=' + UserName + '&specialty=' +Speciality + '&zipcode=' +ZipCode +'&eml=' +Email);

	window.open(targetURL, 'Webcast', 'width=800,height=600,toolbar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');
}


//Added for FR ...
function openHCLink(url,type){
        if(type == 1){
                window.location.href=url;
        }
        else if(type == 2){
                window.opener.location.href = url;
                window.opener.focus();
        }
        else if(type == 3) {
                window.open(url,"NewPage");

        }
        else {
                window.open(url,"Contactunivadis","width=495px,height=542px,left=250,top=210,resizable=no,status=1,scrollbars=0");
        }
}

//Added for Speciality driven portlets
String.prototype.trim = function()
{
    var b=0,e=this.length -1;
    while(this.substr(b,1) == " ") b++;
    while(this.substr(e,1) == " ") e--;
    return this.substring(b,e+1);
}

function isAOIDriven(list_aoi,aoi1){
	var aoi_flag=false;
	if(list_aoi!="false"){
		var aoi_list = new Array();
		aoi_list = list_aoi.split('|');

		for(ia =0;ia < aoi_list.length;ia++) {
			var aoi_accepted = aoi_list[ia];
			aoi_accepted = aoi_accepted.trim();
			if(aoi_accepted == aoi1) {
				aoi_flag = true;
				break;
			}
		}
	}
	return aoi_flag;
}

function showCategory(list_aoi,list_speciality,checkPrimaryAOI,profileToCheck)
{
	if(list_aoi=="false" && list_speciality== "false") return;
	if(list_aoi!= "false"){
		var aoi_list = new Array();
		aoi_list = list_aoi.split('|');
		for(ia =0;ia < aoi_list.length;ia++) {
			var aoi_accepted = aoi_list[ia].trim();
			if( (checkPrimaryAOI.toLowerCase()=="yes" && aoi_accepted == profileAOI[1]) || (checkPrimaryAOI.toLowerCase()=="no" && profileToCheck.toLowerCase()!="all" && aoi_accepted == profileAOI[profileToCheck]) || (checkPrimaryAOI.toLowerCase()=="no" && profileToCheck.toLowerCase()=="all" && (aoi_accepted == profileAOI[1] || aoi_accepted == profileAOI[2] || aoi_accepted == profileAOI[3] || aoi_accepted == profileAOI[4] || aoi_accepted == profileAOI[5]) )  ){
				return;
			}
		}
	}
	else{
		var speciality_list = new Array();
		speciality_list = list_speciality.split('|');
		for(ia =0;ia < speciality_list.length;ia++) {
			if(speciality_list[ia].trim() == Speciality){
				return;
			}
		}
	}
	return "hide";

}

//Italy Specific Functions
function PopupWindow(url,windowname,fullscreen,toolbar,statusbar,menubar,addressbar,directoriesbar,scrolling,resize,wdth,hght){	
	var newWindow;
	var windowsetting="fullscreen,scrollbars";
	if(url.toUpperCase().indexOf("HTTP")==-1 && url.toUpperCase().indexOf("MEDICAL_AND_MORE")==-1)
	{
		urlstr =new String(url);
		if(urlstr.substr(urlstr.length-4,urlstr.length)==".pdf" || urlstr.substr(urlstr.length-4,urlstr.length)==".doc")
			url=media_path_app+"/it_IT/"+url;
		else
			url=img_path_app+"/it_IT/"+url;
	}
	if(fullscreen=='no')
	 windowsetting="'toolbar="+toolbar+",location="+addressbar+",directories="+directoriesbar+",status="+statusbar+",menubar="+menubar+",scrollbars="+scrolling+",resizable="+resize+",width="+wdth+",height="+hght+"'";
	if(windowname =="")
		newWindow = window.open(url,"univadis", windowsetting);
	else
		newWindow = window.open(url,windowname,windowsetting);
}
function OpenMicrositeWindow(url,windowname,wdth,hght,microsite,resizable){
	var windowsetting="'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable="+resizable+",width="+wdth+",height="+hght+"'";	
	if(PageName == 'News' || PageName == 'Search' || PageName == 'Home' || PageName == 'Services')
		url="/PortalTemplates/JumpPage.jsp?category="+PageName+"_"+windowname.toLowerCase()+"&toURL=/commonauth/out%3Fr%3Dhttp%3A//service.univadis.it/univadisit/RoutingController%26rememberMe%3Don%26request_url%3D/"+url
	else
		url="/commonauth/out%3Fr%3Dhttp%3A//service.univadis.it/univadisit/RoutingController%26rememberMe%3Don%26request_url%3D/"+url

	var	newWindow = window.open(url,windowname,windowsetting);
}
function xstooltip_findPosX(obj) 
{
  var curleft = 0;
  if (obj.offsetParent) 
  {
    while (obj.offsetParent) 
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}
function xstooltip_findPosY(obj) 
{
    var curtop = 0;
    if (obj.offsetParent) 
    {
        while (obj.offsetParent) 
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}
function disclaimerShow(obj)
{
    it = document.getElementById("disclaimer");   
	posX=0;
	posY=17;
	x = xstooltip_findPosX(obj) + posX;
	y = xstooltip_findPosY(obj) + posY;        
	it.style.top = y + 'px';
	it.style.left = x + 'px';
	it.style.visibility = 'visible'; 
}
function disclaimerHide()
{
    it = document.getElementById("disclaimer"); 
    it.style.visibility = 'hidden'; 
}
//Italy Specific Functions

//Functions specific to Spain added here ...
function openMicrosite(url) {
	window.open(url,"NewPage","width=870px,height=472px,left=80,top=100,resizable=no,status=1,scrollbars=1");
}
//End Spain Functions


//////////////////////////////
// BANNER CLICKED FUNCTION  //
//////////////////////////////

function openBannerNoMenus(url) {
    var params = params= "width=960px,height=700px,left=20,top=20,resizable=no,status=1,scrollbars=0";
    window.open(url,"PopUpWithoutMenus",params);
}

function bannerClicked(toUrl, newWindow, BannerName ){

  if(newWindow){
	if (toUrl.match('/PortalTemplates/RAC_Redirect.jsp') != null) {
		openBannerNoMenus(toUrl);	
	} else {
		win = window.open(toUrl,"windowName","");
	}
  }else{
    location=toUrl;
  }
}


//Function for Sherpa pop-up.

function openSherpa(url){

                window.open(url,"Sherpa","width=960px,height=560px,left=250,top=210,resizable=no,status=1,scrollbars=1");

}


 function OpenMeetingEs(url, category)
{
        var windowsetting="width=870px,height= 625 px,left=80,top=25,resizable=no,status=1,scrollbars=1";

        url ="http://www.univadis.es/PortalTemplates/JumpPage.jsp?category="+category+"&toURL=http://www.univadis.es/commonauth/out?r=http%3A%2F%2Fwww2.univadis.net%2FcomAuth%2FRoutingController%26rememberMe%3Don%26request_url%3D" + url;

        var     newWindow = window.open(url,"NewPage",windowsetting);
}

