function incFontSize()
{

  fsize = getStyle('fontSize') || getStyle('font-size');

  if(fsize.indexOf('%') != -1)
    newFsize = (parseInt(fsize) + 10) + '%'; 
  else if(fsize.indexOf('em') != -1)
    newFsize = (parseFloat(fsize) + 0.1) + 'em';
  else
    newFsize = (parseInt(fsize) + 2) + 'px';

  document.body.style.fontSize = newFsize;

}

function decFontSize()
{
  //alert(getStyle('fontSize'));
  fsize = getStyle('fontSize') || getStyle('font-size');

  //if((parseInt(fsize) - 10) <= 5 ) return 0;
  if(fsize.indexOf('%') != -1)
    newFsize = (parseInt(fsize) - 10) + '%'; 
  else if(fsize.indexOf('em') != -1) {
   // num=fsize.substr(0,(fsize.length-2));
    newFsize = ((parseFloat(fsize) - 0.1)  )+ 'em';
  }
  else
    newFsize = (parseInt(fsize) - 2) + 'px';

  if (parseFloat(newFsize )>0)
	  document.body.style.fontSize = newFsize;
 
}

function getStyle(styleProp) 
{ 
   var x = document.body; 
   if (x.currentStyle) 
      var y = x.currentStyle[styleProp]; 
   else if (window.getComputedStyle) 
      var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp); 
   return y; 
} 

//checks formular 
// need var requiredarray=new Array('form_vorname','form_nachname','form_email');
// need fromularname = subcriberform
// need div id="name" around the fields

 function checkRequired() {
             	
             	var result=true;
             	for(i=0;i<requiredarray.length;i++) {
             		//set back of styles
            		 document.getElementById(requiredarray[i]).style.border='';
            		 var lastChild=document.getElementById(requiredarray[i]).parentNode.lastChild;            		 
            		 if (lastChild.nodeName=='SPAN') 
            		  	document.getElementById(requiredarray[i]).parentNode.removeChild(lastChild);
            		//check each element, if empty mark it
								 if (document.getElementById(requiredarray[i]).value=='') {
								   result=false;
								   //append the image:
								   	var newNode = document.createElement('span');								   	
										newNode.setAttribute('class','red');
  									newNode.innerHTML='<img src="fileadmin/templates/pluradent/images/icons/error.gif" /> <span class="red">Fehler</span>';
								   document.getElementById(requiredarray[i]).parentNode.appendChild(newNode);
								   document.getElementById(requiredarray[i]).style.border = 'solid red 1px';
								 }
							}
							if (result) {
							 document.subscriberform.submit();
							}
							else {
							  alert('Bitte füllen Sie alle benötigten Felder aus!');
							  return false;
							}
             }
             
     /* hides the divs with name hide_container
        and shows id shows_container
        
       also modify hidden value with id actualbox
       
       also swaps the links and changes linkclass so that user sees active and inactive
      */
     function switchSearchFilter(show,hide,force) {
             if (document.getElementById('actualsearchfilter')) {
             		//set hiddenvar to know actual filter	             
		              var act=document.getElementById('actualsearchfilter').value;
		              var actarray=act.split(",");		            
		              var newa=new Array();
		              var drin=false;
		              for (i=0; i<actarray.length;i++) {		              
										if (show==actarray[i])
											drin=true;	
										if (hide != actarray[i])
											newa.push(actarray[i]);
		              }
		              if (!drin || force) {
		              	//show war nicht drin, also ein wechsel
		              	newa.push(show);
		              	if (document.getElementById(show+'_linkcontainer') && document.getElementById(hide+'_linkcontainer')) {
	             				swapElementChilds(show+'_linkcontainer',hide+'_linkcontainer');
	             			//	setClassToFirstChild(show+'_linkcontainer','active');
	             			//	setClassToFirstChild(hide+'_linkcontainer','inactive');
	             				switchElements(show+'_container',hide+'_container');
	             			}
	             			else {
	             				alert('could not change the links: linkcontainer missing');
	             			}
             			}
             			else {
             			// alert('drin');
             			}
             			document.getElementById('actualsearchfilter').value=newa.join(",");
             }
             else {
             	alert('switchSearchFilter error: actualsearchfilter missing');
             }
	           return false;
}
/*
show> item wich is shown by default
hide> item which is hidden by default.

Function checks if hide should be shown (reads hiddenvar actualsearchfilter)

It also sets the classnames
*/
function initSearchFilter(show,hide) {
 
 		if (document.getElementById('actualsearchfilter')) {
 								//test if hide should be shown:
  								var act=document.getElementById('actualsearchfilter').value;
		              var actarray=act.split(",");
		              var newa=new Array();
		              var drin=false;
		              for (i=0; i<actarray.length;i++) {
										if (hide==actarray[i])
											drin=true;
		              }
		     					document.getElementById('actualsearchfilter').value='';
		              if (drin) {
		              //	alert('drin');
		              	switchSearchFilter(hide,show);
		              }
		              else {
		              //	setClassToFirstChild(show+'_linkcontainer','active');
		              //	setClassToFirstChild(hide+'_linkcontainer','inactive');
		              }
		 }
}

function initSearchFilterNew(show, hide) {
    if (document.getElementById('actualsearchfilter')) {
        var actualSearchFilter = document.getElementById('actualsearchfilter').value;
        var actualSearchFilterArray = actualSearchFilter.split(",");
        var isHideActualSearchFilter = false;

        for (i=0; i<actualSearchFilterArray.length;i++) {
            if (hide==actualSearchFilterArray[i])
                isHideActualSearchFilter = true;
        }

        if(isHideActualSearchFilter)  switchSearchFilterNew(hide,show);
    }
}

function switchSearchFilterNew(show,hide) {
    if (document.getElementById('actualsearchfilter')) {
        document.getElementById('actualsearchfilter').value = show;
        swapElementChilds(show+'_linkcontainer',hide+'_linkcontainer');
        switchElements(show+'_container',hide+'_container');
    }
}

function setClassToFirstChild(elemid,nclass) {
if (document.getElementById(elemid)) {
		if (document.getElementById(elemid).firstChild) {
			document.getElementById(elemid).firstChild.className=nclass;
		}
	}
	else {
		alert('could not change classname for '+elemid);
	}
	
}

/* swaps the first child of the two elemnets
*/
function swapElementChilds(one,two) {
	if (document.getElementById(one).firstChild) {
		sone = document.getElementById(one).firstChild;
 		oneclone = sone.cloneNode(true);
 		if (document.getElementById(two).firstChild) {
 			stwo = document.getElementById(two).firstChild;
 			twoclone = stwo.cloneNode(true); 			
 			document.getElementById(one).replaceChild(twoclone, sone);
 			document.getElementById(two).replaceChild(oneclone,stwo);
 		}
 	}
}
        
function switchElements(show,hide) {
		if (document.getElementById(show))
	              document.getElementById(show).style.display='block';
		if (document.getElementById(hide))
	              document.getElementById(hide).style.display='none';
	         return false;

}
