function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function MM_showHideLayers() { //v6.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    	obj.visibility=v; }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function Aktualisieren(url) {
  url = url + '&category=' + escape(getSelectValue('category'));
  url = url + '&OrtFilter=' + escape(getSelectValue('OrtFilter'));
  url = url + '&SeminarFilter=' + escape(getSelectValue('SeminarFilter'));
  document.location.href=url;
}

function getSelectValue(feldname) {
  wert='';
	for(i=0;i<document.Filter[feldname].length;++i)
    if(document.Filter[feldname].options[i].selected == true)
      wert=document.Filter[feldname].options[i].value;
	return(wert);
}

function CheckSearchField(text) {
  if (document.SearchForm.Suchbegriffe.value == "")
  {
  	document.SearchForm.Suchbegriffe.style.textAlign="right";
    document.SearchForm.Suchbegriffe.value = text;
  }
}

function ClearSearchField() {
 	document.SearchForm.Suchbegriffe.value = "";
	document.all.Suchbegriffe.style.textAlign="left";
}

function CheckDictSearchField(text) {
  if (document.DictSearchForm.Suchbegriffe.value == "")
  {
  	document.DictSearchForm.Suchbegriffe.style.textAlign="left";
    document.DictSearchForm.Suchbegriffe.value = text;
  }
}
function CheckDictShortcutField(text) {
  if (document.ShortCutSearchForm.SuchShortcut.value == "")
  {
  	document.ShortCutSearchForm.SuchShortcut.style.textAlign="left";
    document.ShortCutSearchForm.SuchShortcut.value = text;
  }
}

function ClearDictSearchField() {
 	document.DictSearchForm.Suchbegriffe.value = "";
	document.DictSearchForm.Suchbegriffe.style.textAlign="left";
}
function ClearDictShortcutField() {
 	document.ShortCutSearchForm.SuchShortcut.value = "";
	document.ShortCutSearchForm.SuchShortcut.style.textAlign="left";
}

function Go(x) {
 	if(x == "nothing") {
   		document.forms[0].reset();
   		document.forms[0].elements[0].blur();
   		return;
 	}
	else
	{
		if (x.substring(0,2)=="XS")
		{
			x = x.replace(/^XS/,"");
			top.location.href = x;
		}
		else
		{

			if (x.substring(0,4)=="http")
				window.open(x,'','');
			else
				top.location.href = x;
		}
	}
}

function FormSubmit()
{
	//if(chkFormular() == true)
	 document.Formular.submit();
}

function getString(myColouredStyle)
{
	var str;
	if (document.selection) // fuer IE
	{
	  str = document.selection.createRange().text;
 	}
	else if(document.getSelection())
		{   //fuer Mozilla, etc.
			str = document.getSelection();
  		}
	else
	{  //falls anderer Browser
  	}
	//PopUp wird geoeffnet
  	glossary = window.open(MyDocumentRoot+"popup.php?action=glossary&MyColoredStyle="+myColouredStyle+"&term="+str, "Glossary", "width=620,height=350,scrollbars=yes,resizable=no,");
  	glossary.focus(); //Fokus auf PopUp setzen
}

function CheckFlash()
{
	if (navigator.plugins && navigator.plugins.length)
	{

		x = navigator.plugins["Shockwave Flash"];
		if (x)
		{

			flashinstalled = 2;
			if (x.description)
			{

				y = x.description;
				if(isNaN(y.charAt(y.indexOf('.')-2)))
					flashversion = y.charAt(y.indexOf('.')-1);
				else
					flashversion = y.charAt(y.indexOf('.')-2)+''+y.charAt(y.indexOf('.')-1);

				//flashversion = y.charAt(y.indexOf('.')-2);
			}
		}
		else
			flashinstalled = 1;
		if (navigator.plugins["Shockwave Flash 2.0"])
		{

			flashinstalled = 2;
			flashversion = 2;
		}
	}
	else if (navigator.mimeTypes && navigator.mimeTypes.length)
	{

		x = navigator.mimeTypes['application/x-shockwave-flash'];
		if (x && x.enabledPlugin)
			flashinstalled = 2;
		else
			flashinstalled = 1;
	}
	else
	{
		MSDetect = "true";
	}

	//alert("flashinstalled="+flashinstalled+", flashversion="+flashversion);
}
function CheckMyCostCentre(input,incentivekey)
{
	if(navigator.appName=="Microsoft Internet Explorer")
		var einblendtyp = "block";
	else
		var einblendtyp = "table-row";
	if(input.value == incentivekey)
	{
		if (document.getElementById("ordernumber"))
			document.getElementById("ordernumber").style.display=einblendtyp;
		if (document.getElementById("incentivetype"))
			document.getElementById("incentivetype").style.display=einblendtyp;
		if (document.getElementById("customer"))
			document.getElementById("customer").style.display=einblendtyp;
	}
	else
	{
		if (document.getElementById("ordernumber"))
			document.getElementById("ordernumber").style.display="none";
		if (document.getElementById("incentivetype"))
			document.getElementById("incentivetype").style.display="none";
		if (document.getElementById("customer"))
			document.getElementById("customer").style.display="none";
	}
}
function CheckMyCostCentreOnPageReLoad(incentivekey)
{
	//if (document.getElementById("costcentre"))
		//alert(document.getElementById("costcentre").value);

	if(navigator.appName=="Microsoft Internet Explorer")
		var einblendtyp = "block";
	else
		var einblendtyp = "table-row";

	if (document.getElementById("costcentre"))
	{

		if(document.getElementById("costcentre").value == incentivekey)
		{
			if (document.getElementById("ordernumber"))
				document.getElementById("ordernumber").style.display=einblendtyp;
			if (document.getElementById("incentivetype"))
				document.getElementById("incentivetype").style.display=einblendtyp;
			if (document.getElementById("customer"))
				document.getElementById("customer").style.display=einblendtyp;
		}
		else
		{
			if (document.getElementById("ordernumber"))
				document.getElementById("ordernumber").style.display="none";
			if (document.getElementById("incentivetype"))
				document.getElementById("incentivetype").style.display="none";
			if (document.getElementById("customer"))
				document.getElementById("customer").style.display="none";
		}
	}
}
function CheckECatalogWindow(url)
{
	if (document.getElementById("ecatsearch"))
	{
		if (document.getElementById("ecatsearch").checked==true)
			 window.open(url);
	}
}

function Check_KeyAndSubmitForm(name)
{
	key = window.event.keyCode;
	if(key == 13)
      document.forms[name].submit();
}

// RSS Javascript functions
//=======================================================================================================
function display_rss_newsdetail(v,anzahl,rss)
{
	var d_alt, d_neu, image_neu;

	if (document.getElementById("rssnews_"+rss+"_"+v))
		d_alt=document.getElementById("rssnews_"+rss+"_"+v).style.display;

	for (i=0;i<=anzahl;i++)
	{
		if (document.getElementById("rssnews_"+rss+"_"+i))
			document.getElementById("rssnews_"+rss+"_"+i).style.display = 'none';
		if (document.getElementById("icon_"+rss+"_"+i))
			document.images["icon_"+rss+"_"+i].src=MyDocumentRoot+'icons/plus.gif';
	}
	if (document.getElementById("rssnews_"+rss+"_"+v))
	{
		if(d_alt=='block')
		{
			d_neu='none';
			image_neu=MyDocumentRoot+'icons/plus.gif';
		}
		else
		{
			d_neu='block';
			image_neu=MyDocumentRoot+'icons/minus.gif';
		}
		document.getElementById("rssnews_"+rss+"_"+v).style.display = d_neu;
		if (document.getElementById("icon_"+rss+"_"+v))
			document.images["icon_"+rss+"_"+v].src=image_neu;
	}

}

function display_all_rss_newsdetail(anzahl,rss)
{
	for (i=0;i<=anzahl;i++)
	{
		if (document.getElementById("rssnews_"+rss+"_"+i))
			document.getElementById("rssnews_"+rss+"_"+i).style.display = 'block';
		if (document.getElementById("icon_"+rss+"_"+i))
			document.images["icon_"+rss+"_"+i].src=MyDocumentRoot+'icons/minus.gif';

	}
}

function close_all_rss_newsdetail(anzahl,rss)
{
	for (i=0;i<=anzahl;i++)
	{
		if (document.getElementById("rssnews_"+rss+"_"+i))
			document.getElementById("rssnews_"+rss+"_"+i).style.display = 'none';
		if (document.getElementById("icon_"+rss+"_"+i))
			document.images["icon_"+rss+"_"+i].src=MyDocumentRoot+'icons/plus.gif';
	}
}

function displayDiv(id)
{
	var d;
	if(d=document.getElementById(id))
		d.style.display='block';
}
function hideDiv(id)
{
	var d;
	if(d=document.getElementById(id))
		d.style.display='none';
}
function formatZahl(zahl, k, fix)
{
    if(!k) k = 0;
    var neu = '';
    // Runden
    var f = Math.pow(10, k);
    zahl = '' + parseInt( zahl * f + (.5 * (zahl > 0 ? 1 : -1)) ) / f ;
    // Komma ermittlen
    var idx = zahl.indexOf('.');
    // fehlende Nullen einfügen
    if(fix)
    {
         zahl += (idx == -1 ? '.' : '' )
         + f.toString().substring(1);
    }
    // Nachkommastellen ermittlen
    idx = zahl.indexOf('.');
    if( idx == -1) idx = zahl.length;
    else neu = ',' + zahl.substr(idx + 1, k);

    // Tausendertrennzeichen
    while(idx > 0)
    {
        if(idx - 3 > 0)
        neu = '.' + zahl.substring( idx - 3, idx) + neu;
        else
        neu = zahl.substring(0, idx) + neu;
        idx -= 3;
    }
    return neu;
}

function AddToShoppingCart(postyp,productid)
{
	var f=document.getElementById('AddToShoppingcartForm'+productid);
	f.AddToShoppingCartTyp.value=postyp;
	f.submit();
}

var NS4=false;
var flashinstalled = 0;
var flashversion = 0;
var subnavArray=new Object();
var subnavInitId=0;
MSDetect = "false";

if(navigator.appName=='Netscape')
	if(navigator.appVersion.substring(0,1) == "4")
		NS4=true;

CheckFlash();

subnavIsEffect=false;
function subnavSetInnerHTML(navid,html,subnavworld,left,subnavwidth)
{
	var div2=document.getElementById("subnav2");
	//alert("html="+html);
	div2.innerHTML=html;
	if (subnavworld) {
		subnavIsEffect = true;
		subnavEffectNavid=navid;
		subnavMove(subnavworld, left, subnavwidth);
	}
}

function subnavSetInnerHTMLNav(navid,subnavworld,left,subnavwidth)
{
	var loaded=false;
	var snd;
	if(snd=document.getElementById("subnavdiv"+navid))
		subnavSetInnerHTML(navid,snd.innerHTML,subnavworld,left,subnavwidth);
	else
	{
		//alert("AJAX-Nachladen");
		subnavLoad(MyDocumentRoot+'ajax.php',navid,subnavworld,left,subnavwidth)
	}
}
function subnavLoad(slu,navid,subnavworld,left,subnavwidth)
{
	$.get(slu, { id: navid, activeid: MyNavigationId, MyIsPreview: MyIsPreview?'Y':'', action: "GetIpodNavigationDiv" },
  function(data){
		subnavSetInnerHTML(navid,data,subnavworld,left,subnavwidth);
  });

}
function subnavSetBreadcrumbs(navid)
{
	var divbc1=document.getElementById('breadcrumbs');
	var divbc2=document.getElementById('breadcrumbs'+navid);
	if(divbc2)
		if(divbc1)
			divbc1.innerHTML=divbc2.innerHTML;
}
function subnavEffectFinished()
{
	var div1=document.getElementById("subnav1");
	var div3=document.getElementById("subnav3");
	div1.innerHTML='&nbsp;';
	div3.innerHTML='&nbsp;';
	subnavSetBreadcrumbs(subnavEffectNavid);
	subnavIsEffect=false;
	if(typeof SetContentHeight == 'function')
		SetContentHeight();
}
function subnavdown(navid)
{
	if(subnavIsEffect)
		return;
	var subnavworld=document.getElementById("subnavworld");
	var div1=document.getElementById("subnav1");
	var div2=document.getElementById("subnav2");
	div1.innerHTML=div2.innerHTML;
	var left=0;
	subnavworld.style.left=left+'px';
	subnavSetInnerHTMLNav(navid,subnavworld,left,subnavwidth);
}
function subnavup(navid)
{
	if(subnavIsEffect)
		return;
	var subnavworld=document.getElementById("subnavworld");
	var div3=document.getElementById("subnav3");
	var div2=document.getElementById("subnav2");
	div3.innerHTML=div2.innerHTML;
	var left=(-2*subnavwidth);
	subnavworld.style.left=left+'px';
	subnavSetInnerHTMLNav(navid,subnavworld,left,subnavwidth);
}
function subnavInit()
{
	var sndiv;
	if(subnavInitId)
	{	if(sndiv=document.getElementById("subnavaussen"))
		{	var wdiv=document.getElementById("subnavwindow");
			subnavwidth=wdiv.style.width.replace('px','');
			subnavSetInnerHTMLNav(subnavInitId,false,0,0);
			sndivu=document.getElementById("subnavunten")
			sndiv.style.display='block';
			sndivu.style.display='block';
		}
	}
}
function subnavgoto(link)
{
	location.href=link;
}
function switchDIVsOLS(anz,selecteddiv)
{
	var showdiv=selecteddiv;
    for(i=1;i<=anz;i++)
    	if(document.getElementById("newshome"+i))
			document.getElementById("newshome"+i).style.display="none";
	if(showdiv)
		k = showdiv;
	else
		k = (Math.floor(Math.random()*anz)+1);

	if(document.getElementById("newshome"+k))
	{
		Effect.Appear("newshome"+k, { duration: 2.0 });
		if(document.getElementById("imagenewshome"+k))
			Effect.Appear("imagenewshome"+k, { duration: 6.0 });
	}
		//	document.getElementById("newshome"+k).style.display="block";
 }
function ForwardAndCloseWindow(url)
{
	
	opener.parent.location.href = url;
	window.close();
}
function ReloadMainWindow(url){
	opener.parent.location.href=url;
}

function DisplayCompanyRegistrationNumber(occupations)
{
	var o=document.getElementById('occupation_id');
	var z=document.getElementById('company_registration_number_row');
	if(in_array(o.options[o.selectedIndex].value,occupations))
		z.style.display='block';
	else
		z.style.display='none';
}

function in_array(item,arr) {
	for(p=0;p<arr.length;p++)
		if (item == arr[p])
			return true;
	return false;
}

function CampaignActionDisplayPage(slu,navid,cugid)
{
	$.get(slu, { id: navid, cugid: cugid, action: "CampaignActionDisplayPage" });

}
