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 = "";
	if(document.all==undefined)
		document.SearchForm.Suchbegriffe.style.textAlign="left";
	else
		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 ShowMySpecialCostcentresByCompanyNumber(input,mycostcentreincentive,keys,companynumber,systemtext)
{
	if(navigator.appName=="Microsoft Internet Explorer")
		var einblendtyp = "block";
	else
		var einblendtyp = "table-row";
		
	var incentivekeys=keys.split(",");
	
	if(input.value == mycostcentreincentive)
	{
		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;
		GetOrdernumberByCostcentre(mycostcentreincentive,systemtext);	
	}
	else
	{
		if(incentivekeys.length>0)
		{
			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";
			for (var i = 0; i < incentivekeys.length; i++) {
			
				if(input.value == incentivekeys[i])
				{
					if (document.getElementById("ordernumber"))
						document.getElementById("ordernumber").style.display=einblendtyp;
					if (document.getElementById("incentivetype"))
						document.getElementById("incentivetype").style.display="none";
					if (document.getElementById("customer"))
						document.getElementById("customer").style.display="none";
						if (document.getElementById("stern"))
						document.getElementById("stern").style.display="none";	
					GetOrdernumberByCostcentre(incentivekeys[i],systemtext);
				}
			}	
		}
		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 ShowMyCostcentresByCompanyNumber(input,incentivekey,companynumber)
{
	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";
	}
	
	GetCostcentresByCompanyNumber(companynumber);
}

function GetCostcentresByCompanyNumber(company_number)
{					    
    var val = company_number;	
    if (val != 0) {    
        $.ajax({
           type: "GET",
           url: "ajax.php?action=getCostcentreByCompanyNumber&nothml=true&company_number="+val,
           data: "data",
           success: function(data){			
           		data=data.split(" ");
           		$("#costcentre").autocomplete(data);
           }
         });
    } 
}

function GetOrdernumberByCostcentre(costcentre,systemtext)
{	
	
	var val = costcentre;
    var captionselect = systemtext;
    if (val != 0) {    
        $.ajax({
           type: "GET",
           url: "ajax.php?action=getOrdernumberByCostcentre&costcentre="+val+"&captionselect="+encodeURI(captionselect),
           data: "data",
           success: function(data){		
           		$("#ordernumberfield").html(data);
           }
         });
    } 
}


function CheckMyCostCentreOnPageReLoad(incentivekey,keys)
{
	//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)
{
	$.ajax({
		url: slu,
		type:'get',
		data: {
			id:navid,
			action:'CampaignActionDisplayPage'
		},
		success: function(data) {
			//alert(data);
		}
	});

	//	$.get(slu, { id: navid, action: "CampaignActionDisplayPage" , success:function(msg) { alert(msg);}});

}

function HideMandatoryMessage(pageId,previewMode) {
	var urlSuffix='';

	if(previewMode)
		urlSuffix='?preview='+previewMode;
	var url=MyDocumentRoot+'ajax.php'+urlSuffix;	
	$.ajax( {
		url: url,
		type:'post',
		data: {
			pageId:pageId,
			ajaxaction:'hideMandatoryMessage'		
		},
		success: function(data) {
				tb_remove();
		}
	});
}
function toogleSlideContent(number, id, controlId, controlClass, contentClass, controlClassClosed, openonlyone) {
//	$("#"+id+" h3").slideToggle();
//	$("#"+id+" table").slideToggle();
//	$("#"+id+" div").slideToggle();

	if(openonlyone)
		toggleCollapseAllContent(contentClass, controlClass, controlClassClosed);
	$("#"+id+" > *").slideToggle();
	$("#"+controlId).toggleClass(controlClass);
}

function initToogleSlideContent(contentClass, controlClass, controlClassClosed, controlIdOpen) {
	$("."+contentClass+" > *").css("display","none");
	$("."+controlClass).toggleClass(controlClassClosed);
	if(controlIdOpen) {
		$("."+contentClass+":first > *").css("display","block");
		$("#"+controlIdOpen).toggleClass(controlClassClosed);
	}
}
function toggleCollapseAllContent(contentClass, controlClass, controlClassClosed) {
	$("."+contentClass+" > *").slideUp();
	$("."+controlClassClosed.substr(0,controlClassClosed.length-"Closed".length)).addClass(controlClassClosed);
	$("."+controlClass).addClass(controlClass);
	$("."+controlClass).addClass(controlClassClosed);
}
function toggleExpandAllContent(contentClass, controlClass, controlClassClosed) {
	$("."+contentClass+" > *").slideDown();
	
	$("."+controlClass).removeClass(controlClassClosed);
}
function toggleAllToggleSlideContent(contentClass, controlClass, controlClassClosed) {
	var isOneOpen = 0;
	$("."+contentClass).each(function (content) {
		$("."+contentClass+':eq('+content+')>*:first').each(function (i) {
			if($(this).css("display")=='block' || $(this).css("display")=='table')
				isOneOpen += 1;
		});
	});
	if(isOneOpen>1) {
		// close All
		$("."+contentClass+" > *").slideUp();
		
		$("."+controlClass).addClass(controlClass);
		$("."+controlClass).addClass(controlClassClosed);
	}
	else {
		// open All
		$("."+contentClass+" > *").slideDown();
		$("."+controlClass).removeClass(controlClassClosed);
	}
}

//function toggleAllContentClass(contentClass, controlClass, controlClassToggle) {
function toggleAllContentClass(contentClass, controlClass, controlClassToggle) {
	var obj = $("."+contentClass);
	var display = obj.css("display");
	
	if(display=='table-row'||display=='block')
		obj.css("display","none");
	else {
		if(IE6)
			obj.css("display","block");
		else
			obj.css("display","table-row");
	}
	$("#"+controlClass).toggleClass(controlClassToggle);
}

function initAccordion(uHeader, uContent, expandindex, colorArrows, fileextention, collapseprev, headerclasscollapse, headerclassexpand, colorArrowAlternative,expandedIcon,collapseIcon) {
	if(uHeader)
		headerclass = uHeader;
	if(uContent)
		contentclass = uContent;
	if(!colorArrows)
		colorArrows = 'lightgrey';
	if(!colorArrowAlternative)
		colorArrowAlternative = colorArrows;
	if(!fileextention)
		fileextention = 'gif';
	if(collapseprev!=false)
		collapseprev = true;
	if(!headerclasscollapse)
		headerclasscollapse="";
	if(!headerclassexpand)
		headerclassexpand="";
	
	if(!expandedIcon)
		expandedIcon = "<img src='"+MyDocumentRoot+"icons/arrow_right_"+colorArrows+"."+fileextention+"' class='statusicon' />";
	else
		expandedIcon = "<img src='"+MyDocumentRoot+"icons/"+expandedIcon+"' class='statusicon' />";
	if(!collapseIcon)
		collapseIcon = "<img src='"+MyDocumentRoot+"icons/arrow_down_"+colorArrowAlternative+"."+fileextention+"' class='statusicon' />";
	else
		collapseIcon = "<img src='"+MyDocumentRoot+"icons/"+collapseIcon+"' class='statusicon' />";
	
	ddaccordion.init({
		headerclass: headerclass, //Shared CSS class name of headers group
		contentclass: contentclass, //Shared CSS class name of contents group
		revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
		mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
		collapseprev: collapseprev, //Collapse previous content (so only one open at any time)? true/false
		defaultexpanded: [expandindex], //index of content(s) open by default [index1, index2, etc] [] denotes no content
		onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
		animatedefault: true, //Should contents open by default be animated into view?
		persiststate: false, //persist state of opened contents within browser session?
		toggleclass: [headerclasscollapse, headerclassexpand], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
		togglehtml: ["suffix", expandedIcon, collapseIcon], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
		animatespeed: "normal", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
		oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
			//do nothing
		},
		onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
			//do nothing
		}
	});
}

function activate(element,vorbelegung) {  //Diese Funktion benötigt zwei Angaben: Die erste (element) dient dazu, auf das entsprechende Formularfeld zuzugreifen. Hier ist im Formular immer this anzugeben (siehe Formular). Die zweite (vorbelegung) enthält den gleichen Text, der auch bei dem jeweiligen <input>-Feld unter value=\"\" bzw. bei <textarea> zwischen <textarea> und </textarea> angegeben ist.
  if (element.value == vorbelegung) {  //Hier wird überprüft, ob der derzeitige Inhalt der Vorbelegung entspricht.
    element.value = '';  //Ist das der Fall, dann wird der Inhalt gelöscht und
    //element.className = 'normal';  //wieder normal dargestellt (die Klasse des Feldes wird auf 'normal' geändert).
  }
}
function leave(element,vorbelegung) {  //Diese Funktion benötigt die gleichen Angaben wie activate().
  if (element.value == '') {  //Hier wird überprüft, ob das Feld bereits durch den User ausgefüllt wurde.
    element.value = vorbelegung;  //Wenn nicht, dann wird die Vorbelegung wiederhergestellt und
    //element.className = 'vorbelegung';  //der Text wieder grau und kursiv dargestellt (erneute Änderung der Klasse).
  }
}

//Var definitions
var deviceIphone = "iphone";
var deviceIpod = "ipod";
var deviceS60 = "series60";
var deviceSymbian = "symbian";
var engineWebKit = "webkit";
var deviceAndroid = "android";
var deviceWinMob = "windows ce";
var deviceBB = "blackberry";
var devicePalm = "palm";
							
//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();
							
// Detects if the current device is an iPhone.
function DetectIphone()
{
	if (uagent.search(deviceIphone) > -1)
	      return true;
	else
	      return false;
}
							
// Detects if the current device is an iPod Touch.
function DetectIpod()
{
   if (uagent.search(deviceIpod) > -1)
	      return true;
   else
	      return false;
}
							
// Detects if the current device is an iPhone or iPod Touch.
function DetectIphoneOrIpod()
{
	if (DetectIphone())
		return true;
	else if (DetectIpod())
	    return true;
	else
	    return false;
}
							
// Detects if the current browser is the S60 Open Source Browser.
// Screen out older devices and the old WML browser.
function DetectS60OssBrowser()
{
	if (uagent.search(engineWebKit) > -1)
	{
		if ((uagent.search(deviceS60) > -1 || 
			uagent.search(deviceSymbian) > -1))
			return true;
		else
		    return false;
    }
	else
	      return false;
}
							
// Detects if the current device is an Android OS-based device.
function DetectAndroid()
{
	if (uagent.search(deviceAndroid) > -1)
		return true;
	else
		return false;
}
							
// Detects if the current device is an Android OS-based device and
//   the browser is based on WebKit.
function DetectAndroidWebKit()
{
   if (DetectAndroid())
   {
	     if (DetectWebkit())
	        return true;
	     else
		    return false;
	}
	else
	     return false;
}
							 
// Detects if the current browser is a Windows Mobile device.
function DetectWindowsMobile()
{
   if (uagent.search(deviceWinMob) > -1)
	     return true;
   else
	     return false;
}
							
// Detects if the current browser is a BlackBerry of some sort.
function DetectBlackBerry()
{
	if (uagent.search(deviceBB) > -1)
		return true;
	else
		return false;
}
							 
// Detects if the current browser is on a PalmOS device.
function DetectPalmOS()
{
	if (uagent.search(devicePalm) > -1)
		return true;
	else
		return false;
}
			
function IsMobileDevice()
{							
	var is_mobile_device=false;
	
	if(DetectIphoneOrIpod())
		is_mobile_device=true;
	else if(DetectS60OssBrowser())
		is_mobile_device=true;
	else if(DetectAndroidWebKit())
		is_mobile_device=true;
	else if(DetectWindowsMobile())
		is_mobile_device=true;
	else if(DetectBlackBerry())
		is_mobile_device=true;
	else if(DetectPalmOS())
		is_mobile_device=true;
		
	return(is_mobile_device);	
}										

function checkStuffFormular(formid,alertMsg) {
	var cbs = $('#'+formid+' input:checkbox[checked]');
	if(cbs.length>0)
		return true;
	else {
		alert(alertMsg);
		return false;
	}
}

function bindStuffFormularInputCheck(formid, prefixCB, prefixCount) {
	// input text name = menge12
	// input select name = menge361
	// input cb name = checkbox12
	if(!prefixCB)
		prefixCB = 'checkbox';
	if(!prefixCount)
		prefixCount = 'menge';
	
	var cbs = $('#'+formid+' input:checkbox');
	jQuery.each(cbs,function() {
		var actCb = $(this);
		var attrNameValue = actCb.attr('name')
		if(attrNameValue.indexOf('checkbox')>=0) {
			var cbId = attrNameValue.substr(8);
			if($('#'+formid+' input:text[name='+prefixCount+cbId+']').length>0) {
				// input type=text
				$('#'+formid+' input:text[name='+prefixCount+cbId+']').bind("blur",function() {
					if($.trim($(this).attr('value'))+0 > 0)
						actCb.attr('checked','checked');
					else
						actCb.attr('checked','');		
				});
			}
			if($('#'+formid+' select[name='+prefixCount+cbId+']').length>0) {
				// select
				$('#'+formid+' select[name='+prefixCount+cbId+']').bind("change",function() {
					if($.trim($(this).attr('value'))+0 > 0)
						actCb.attr('checked','checked');
					else
						actCb.attr('checked','');
				});
			}
		}
	});
}

function downloadStuffToStep(step) {
	if(step==1)
		$("form[name=StuffFormular] input[name=aktion]").remove();
	if(step==2)
		$("form[name=StuffFormular] input[name=aktion]").attr('value','order');
	
	$("form[name=StuffFormular] input[name=save]").remove();
	$("form[name=StuffFormular] input[name=save2]").remove();
	document.StuffFormular.submit();
}
function literatureToStep() {
	$("form[name=Formular] input[name=save]").remove();
	$("form[name=Formular] input[name=save2]").remove();
	document.Formular.submit();
}
function shoppingCartToStep(step) {
	if(step==1)
		$("form[name=Formular] input[name=ChangeCartSave]").remove();
	if(step==2)
		$("form[name=Formular] input[name=ChangeCartSave]").attr('value','Y');
	
	$("form[name=Formular] input[name=send]").remove();
	$("form[name=Formular] input[name=send2]").remove();
	document.Formular.submit();
}
function bindFAQThemeSelector(selectClass) {
	$("."+selectClass).bind("click", function() {
		var contentId = $(this).attr("relID");
		var contentClass = $(this).attr("relClass");
		$("."+contentClass).hide();
		$("#"+contentId).show();
		var boxes = $("#"+contentId).find(".downloadTableBox > div");
		var oneIsOpen=false;
		$.each(boxes,function() {
			if($(this).css("display")=="block")
				oneIsOpen=true;
		});
		if(!oneIsOpen)
			$("#"+contentId).find(".boxheaderContentSwitch:first").click();
	});
}

function GenerateActivationCode(softwareid,softwareversion,softwarecompanyname,softwarecountry,justregistered){
					
    var sid	= softwareid;
    var svs	= softwareversion;
    var scn = softwarecompanyname;
    var sc	= softwarecountry;
    var jr  = justregistered;
  
    if (sid && svs && scn && sc) {    
        $.ajax({
           type: "GET",
           url: MyDocumentRoot+"ajax.php?action=GetActivationCodeId&ThisIsTheActivationCodeGeneration=true&softwareversion="+escape(svs)+"&softwareid="+escape(sid)+"&softwarecompanyname="+escape(scn)+"&softwarecountry="+escape(sc)+"&justregistered="+escape(jr),
           success: function(data){	          
           		$('#ActivationCodeButton').css("display","none");
           		$('#ActivationCodeDislpay').html(data);	           		
           }
         
         });
    } 
}

function CUG_HistoryInsert(actionid)
{
	
	var cugactionid = actionid;
	 if (cugactionid) {    
        $.ajax({
           type: "POST",
           url: MyDocumentRoot+"ajax.php?action=CugHistoryInsert&cugactionid="+escape(cugactionid),
           success: function(data){ }
         });
    } 
}
	
function GenerateActivationCodeForCugUser(){
  var sid	    = $("#SoftwareId").val();
  var svs	    = $("#SofwareVersion").val();
  var scn		= $("#SofwareCompanyname").val();
  var sc	= $("#SoftwareCountry").val();
  var currentid	= $("#CurrentId").val();
  var cuguser	= $("#CugUser").val();
  var cuguserid	= $("#CugUserId").val();
  var cuguseremail	= $("#CugUserEmail").val();
  //alert("Company:"+scn+"Country:"+sc+"UserId:"+cuguserid+"User:"+cuguser);
  if (sid && svs && scn && sc) {    
	        $.ajax({
	           type: "POST",
	           url: MyDocumentRoot+"ajax.php",
	           data: "action=GetActivationCodeId&ThisIsTheActivationCodeGeneration=true&actioncomesfromhageruser=true&cuguser="+escape(cuguser)+"&cuguserid="+escape(cuguserid)+"&cuguseremail="+escape(cuguseremail)+"&softwareversion="+escape(svs)+"&softwareid="+escape(sid)+"&softwarecompanyname="+escape(scn)+"&softwarecountry="+escape(sc)+"&currentid="+escape(currentid),
               success: function(data){	  
	           		$('#ActivationCodeDislpay').html(data);
	           		//$('#ActivationCodePage').html(data);	  	           		
	           }
	         
	         });
	    } 
}

function CookieSave(name, value, days)
{
	if (typeof days != 'undefined') {
		var date = new Date();
		date.setTime(date.getTime() + (days*24*60*60*1000));
		var expires = "; expires=" + date.toGMTString();
	} else {
		var expires = "";
	}
	document.cookie = name + "=" + value + expires + "; path=/";
}

function CookieGet(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') {
				c = c.substring(1,c.length);
			}
			if (c.indexOf(nameEQ) == 0) {
				return c.substring(nameEQ.length,c.length);
			}
	}
	return null;
}

function redirectOppositeURL(text,url) {
	var oppositeRedirect = confirm(text);
	if(oppositeRedirect) {
		document.location.href = url;
	}
	else {
		hideOppositeHint();
	}
}
function hideOppositeHint() {
	CookieSave("hideOppositeHint","Y");
	return false;
}

function Hide_AnyDivLayer(hide)
{					    
    var val = hide;
    	
    if (val != 0) {    
        $.ajax({
           type: "GET",
           url: "ajax.php?action=HideAnyDivLayer&hide="+val,
           data: "data",
           success: function(data){			
           		// nothing
           }
         });
    } 
}

function CUG_HistoryInsertXml(cugaction,xml)
{					    
    var val = cugaction;	
    var details = xml;
    if (val != 0) {    
        $.ajax({
           type: "GET",
           url: "ajax.php?action=CugHistoryInsert&cugaction="+val+"&details"+details,
           data: "data",
           success: function(data){			
           		// nothing
           }
         });
    } 
}

var mmFancy;
function showFancyBox(id) {
	
	$('#'+id).fancybox({
		'width' : 800,
		'height' : 480,
		'autoScale' : false,
		'type' : 'iframe',
		'transitionIn' : 'elastic',
		'transitionOut' : 'elastic',
		'overlayOpacity' : 0.75,
		'overlayColor' : '#fff',
		'padding' : 1,
		'margin' : 5,
		'centerOnScroll' : false,
		onComplete : function() {},
		onStart: function() {},
		onCleanup: function () {}
	});
	$('#'+id).click();
	mmFancy = $('#'+id).fancybox
}

function showFancyBoxAjax(classname) {
	$('.'+classname).fancybox({
		'type' : 'ajax',
		'overlayOpacity' : 0.75,
		'overlayColor' : '#fff',
		'titleShow' : false,
		'transitionIn' : 'none', // nicht faden, wegen ie
		'transitionOut' : 'none' // nicht faden, wegen ie
	});
}

function ShowWaitingDiv(parentElement,targetId,options,classname) {
	$('.ac_results').hide();	//versteckt die autocomplete-Liste
	$(parentElement).css('position','relative').append("<div id='"+targetId+"' class='"+classname+"'></div>");
	if(options && options!=undefined && is_object(options))
		var opts=options;
	else
		var opts = {
		  lines: 8, // The number of lines to draw
		  length: 5	, // The length of each line
		  width: 3, // The line thickness
		  radius: 4, // The radius of the inner circle
		  color: '#000', // #rgb or #rrggbb
		  speed: 1, // Rounds per second
		  trail: 54, // Afterglow percentage
		  shadow: false // Whether to render a shadow
		};
	//var target+{targetId} = document.getElementById(targetId);
	eval("var target" + str_replace('-','',targetId) + "=document.getElementById(targetId);");
	//var spinner+{targetId} = new Spinner(opts).spin(target+{targetId});
	eval("var spinner" + str_replace('-','',targetId) + "=new Spinner(opts).spin(target" + str_replace('-','',targetId) + ");");
}

function ShowDisableDiv(parentElementObj,classname) {
	$(parentElementObj).each(function() {
		if($(this).find('#extendedsearch-waiting-div').length < 1)
			$(this).css('position','relative').append("<div class='"+classname+"'></div>");
	});
	/*if($(parentElementObj).find('#extendedsearch-waiting-div').length < 1)
		$(parentElementObj).css('position','relative').append("<div class='"+classname+"'></div>");*/
}

function is_object(input){
	return typeof(input)=='object';
}

function str_replace(search, replace, subject) {
	return subject.split(search).join(replace);
}

function rotate(idname){
	var active_elem = $("#"+idname+" div.homepagecontent:visible");
    if (active_elem.length != 1 ||
        $(active_elem).next("div.homepagecontent").length == 0) {
        active_elem = $("#"+idname+" div.homepagecontent:first");
    } else {
        active_elem = $(active_elem).next("div.homepagecontent");
    }
    
    $("#"+idname+" div.homepagecontent:visible").hide("slow",function() {
    	$(active_elem).fadeIn("slow");
    });
    
   	   
    
}

function setHeadlinePosition(blocknumber,notempty) {
	eval("var targetHeadline = document.getElementById('DisplayBoxWithHeadlineOutsideHeader"+blocknumber+"');");
	eval("var targetContent = document.getElementById('DisplayBoxWithHeadlineOutsideContent"+blocknumber+"');");
	if(notempty) {
		if(targetHeadline) {
			var heightHeader = targetHeadline.offsetHeight-20 ;
			if(targetContent) {
				targetContent.style.top = heightHeader + "px";
				targetContent.style.paddingBottom = heightHeader + 5 + "px";
			}
		}
	}
	else {
		if(targetContent) {
			targetContent.style.paddingTop = "5px";
		}
	}
}

