

function UnCryptMailto(s) {
	var n=0;
	var r="";
	for(var i=0; i < s.length; i++) {
		n=s.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(2));
	}
	return r;
}


function linkTo_UnCryptMailto(s) {
	location.href = UnCryptMailto(s);
}


sendlostpassword = function(state) {	
	$("fmr00001").style.display = 'none';
	$("lostpassword").style.display = 'block';
	$("lostpassword").getElementsByTagName("p")[0].innerHTML = '';
	

	if(state) {
	
		$("btslp").value = 'Bitte warten Sie...';
	
	
		new Ajax.Request('/srv/lostpassword.cfm',
		  {
			method:'post',
			parameters: {
				_username:$('lsjusername').value
			},
			
			onSuccess: function(transport, json) {
				returnVal = eval(transport.responseText);
				state = returnVal[0];
				
			
				if(state == 'pwnotfound') {
					$("lostpassword").getElementsByTagName("p")[0].innerHTML = 'Der Benutzername wurde nicht gefunden';
					$("btslp").value = '>>';
				} else {
					$("lostpassword").getElementsByTagName("p")[0].innerHTML = 'Ihr Passwort wurde an die angegebene Email-Addresse gesendet';
				}
			
				
				if(returnVal[0] == 'pwfound') {
					$("btslp").style.display = 'none';
					window.setTimeout("showdefaultloginform()", 4000);
				}
			},
			onFailure: function(){ }
		  });
		}
};


showdefaultloginform = function() {	
	$("fmr00001").style.display = 'block';
	$("lostpassword").style.display = 'none';
	$("lostpassword").getElementsByTagName("p")[0].innerHTML = '';
	$("btslp").style.display = 'block';
	$("btslp").value = '>>';
};
		
		

	processlogin = function(showProgress, usernamefield, passwordfield, logintarget) {
	
		try {
			$("fmr00001").style.display = 'none';
		} catch( ex1 ) {
		}
		
		if (typeof showProgress == "undefined")
			showProgress= true;
			
		if (typeof usernamefield == "undefined")
			usernamefield= 'jusername';
			
		if (typeof passwordfield == "undefined")
			passwordfield= 'jpassword';
			
		if (typeof logintarget == "undefined")
			logintarget= 'index';
		
		var plp = showAjaxPreloader(0);
		
		try {
			if (showProgress)
				$("frmLogin").appendChild(plp);
		} catch( ex2 ) {
		}
		
		new Ajax.Request('/srv/login.cfm',
			  {
				method:'post',
				parameters: {
					_username:$(usernamefield).value,
					_password:$(passwordfield).value,
					_target:logintarget
				},
				
				onSuccess: function(transport, json) {
				
					returnVal = eval(transport.responseText);
				
					if(returnVal[0] == true) {
						document.location.href = "/" + returnVal[1];
					} else {
						try {
							if (showProgress)
								$("frmLogin").removeChild($("frmLogin").getElementsByTagName("img")[0]);
							
							
							document.getElementById('loginerror_jm').style.display= '';
							document.getElementById('loginerror_ms').style.display= '';
						} catch( ex3 ) {
						}
					}
				},
				onFailure: function(){ alert('') }
			  });
			  
			  return false;
		};
	
	
	
	function showAjaxPreloader(id) {
		var preloader = new Image();
		preloader.src = '/images/ajaxload' + id + '.gif';
		return preloader;
	}
			
			
	function submittoMeddrugs() {
		isCenter = true;	  
		features  = "resizable=yes,menubar=yes,scrollbars=yes,location=yes,status=yes,toolbar=yes";
		myWidth	= (screen.width - 200);
		myHeight = (screen.height - 200);
		
		
			href = "http://www.med-drugs.ch/index.cfm?guid=&language=1&main=";
		
		mySearchtype = document.forms["stdform"].search_type.value;
			
		if(document.forms["stdform"].search_query.value!='HIER Suchbegriff eingeben'){ href += document.forms["stdform"].language.value + '/just-medical/search/zone/drugs/search_query/'+escape(document.forms["stdform"].search_query.value.replace(/\//, '%2F'));if(document.forms["stdform"].search_type.value)href += '/search_type/' + mySearchtype; href += '##best_result';  
				  if(window.screen)if(isCenter)if(isCenter=="true"){
					var myLeft = (screen.width-myWidth)/2;
					var myTop = (screen.height-myHeight)/2;
					features+=(features!='')?',':'';
					features+=',left='+myLeft+',top='+myTop;
				  }
									
				  mdwin = window.open(href,'Meddrugs',features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
				  mdwin.focus();
			  }
			return false;
		}
		
	function submittoMeddrugsDE() {
		isCenter = true;	  
		features  = "resizable=yes,menubar=yes,scrollbars=yes,location=yes,status=yes,toolbar=yes";
		myWidth	= (screen.width - 200);
		myHeight = (screen.height - 200);
		href = "http://www.med-drugs.de/index.cfm?main=";
		
		var	mySearchtype = document.forms["stdform"].search_type.value;
		var	myQuery = escape(document.forms["stdform"].search_query.value.replace(/\//, '%2F'));
		var sbstr = href + document.forms["stdform"].language.value;	
				
		if(myQuery != '') {
			switch(mySearchtype) {
				case "st_sequence":
					sbstr += "/drugs/search/query/" + myQuery + "/dstype/tradename";
					break;
				case "st_company":
					sbstr += "/drugs/search/query/" + myQuery + "/dstype/company";
					break;
				case "st_substance":
					sbstr += "/drugs/search/query/" + myQuery + "/dstype/substance";
					break;
			}			
			
			if(window.screen)if(isCenter)if(isCenter=="true"){
				var myLeft = (screen.width-myWidth)/2;
				var myTop = (screen.height-myHeight)/2;
				features+=(features!='')?',':'';
				features+=',left='+myLeft+',top='+myTop;
			  }
			
			mdwin = window.open(sbstr,'Meddrugs',features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
			mdwin.focus();
			
		  }
			return false;
		}
							
							
							
	function setPage(PageNr) {
			document.forms['frselect'].PageNr.value = PageNr;
			document.forms['frselect'].submit();
	}
	
			
	function resetDate() {
		if(document.forms['frselect'].date[0].checked) {
			document.getElementById("tsChlv").style.display = 'block';
			document.getElementById("tsChar").style.display = 'none';
		} else {
			document.getElementById("tsChar").style.display = 'block';
			document.getElementById("tsChlv").style.display = 'none';
		}
		
		document.forms['frselect'].FTTitlesearch.value = '';
		document.forms['frselect'].monthfrom.selectedIndex = 0;
		document.forms['frselect'].yearfrom.selectedIndex = 0;
		document.forms['frselect'].monthto.selectedIndex = 0;
		document.forms['frselect'].yearto.selectedIndex = 0;
		document.forms['frselect'].submit();
	}
	
													
	function resetform() {
		document.forms['frselect'].indication.selectedIndex = 0;
		document.forms['frselect'].country.selectedIndex = 0;
		//document.forms['frselect'].land.selectedIndex = 0;
		
		document.forms['frselect'].date[0].checked = true;
		document.forms['frselect'].FTTitlesearch.value = '';
		
		document.forms['frselect'].yearfrom.selectedIndex = 0;
		document.forms['frselect'].yearto.selectedIndex = 0;
		/*
		document.getElementById("yf1").selectedIndex = 0;
		document.getElementById("yt1").selectedIndex = 0;
		document.getElementById("yf2").selectedIndex = 0;
		document.getElementById("yt2").selectedIndex = 0;*/
		
		//document.forms['frselect'].kantons.selectedIndex = 0;
		//document.forms['frselect'].date[0].checked = true;
		//document.forms['frselect'].FTTitlesearch.value = '';
	}
	
	
	function getMouseXY(e) {
		if(IE) { 
			tempX = event.clientX + document.documentElement.scrollLeft;
			tempY = event.clientY + document.documentElement.scrollTop;
		  } else { 
			tempX = e.pageX;
			tempY = e.pageY;
		  }  

		  if (tempX < 0){tempX = 0}
		  if (tempY < 0){tempY = 0}  
		
		  return true;
	}

		function OpenWin(url, w, h, features) {
			var myLeft = (screen.width-w)/2;
			var myTop = (screen.height-h)/2;
			
			var win = window.open(url, 'bx', 'height=' + h + ',width='+ w + ',top=' + myTop + ',left=' + myLeft + ',' + features);
		}
	
			

	function TabMenu(visibleTabs, obj) {
		this.tabcount 	 = obj.getElementsByTagName('li').length; 
		this.TabsVisible = visibleTabs;		
		this.showTabs = function() {
			var a;
			for(i=1; i <= this.tabcount; i++) {
				document.getElementById("tabpos_" + i).style.display = 'none';	
			}
	
			
			for(i=0; i < this.TabsVisible.length; i++) {
				try {
					a= document.getElementsByName("tabname_" + this.TabsVisible[i]);
					if (a.length == 1) {
						a[0].style.display = 'inline';
					} else {
						document.getElementById("tabpos_" + this.TabsVisible[i]).style.display = 'inline';
					}
				} catch(e) {}
			}
		}
		
		this.EmphasizeActiveTab = function(row) {
			for(i=1; i <= this.tabcount; i++) {
				document.getElementById("tabpos_" + i).className = '';	
			}
			document.getElementById("tabpos_" + row).className = 'active';
		}
		
		this.setVisibleTags = function(arg) {
			this.TabsVisible = arg;
		}
		
		this.makeTabOrder = function(arg) {
			var isinPos = -1;
			
			for(i=0; i < this.TabsVisible.length; i++) {
				for(j=0; j < arg.length; j++) {
					if(this.TabsVisible[i] == arg[j]) {
						isinPos = i;
						break;
					}
				}
			}
			
			if(isinPos == -1) {
				this.TabsVisible = arg;
			}
		}
		
		this.MoveTabs = function(dir) {
			switch(dir) {
				case "back":
					if(this.TabsVisible[0] > 1) {
						for(i=0; i < this.TabsVisible.length; i++) {
							this.TabsVisible[i] = this.TabsVisible[i] - 1;
						}
					}
					break;
				case "foreward": 
					if(this.TabsVisible[0] <= (this.tabcount - this.TabsVisible.length)) {
						for(i=0; i < this.TabsVisible.length; i++) {
							this.TabsVisible[i] = this.TabsVisible[i] + 1;
						}
					}
					
				//	alert("" + this.TabsVisible[0] + this.TabsVisible[1] + this.TabsVisible[2] + this.TabsVisible[3]);
					break;
				}
				this.showTabs();
			}
		}