 /** 
  * ------------------------------------
  * 
  *   JScript Functions for IIE GmbH
  *
  *  Copyright (C) 2008-2009 IIE GmbH
  *
  * ------------------------------------
  */


/**
  * Beschreibung: 
  * Checks if given value matches the "case" then remove it. 
  *   
  * @get, String s
  * @return void
  */
function clearField(s){
	switch (s) {
		case "Ihr Suchbegriff":
			document.psearch_form.psearch_input.value = "";
			break;
	}	
}



/**
 * Description: 
 * Checks user Y scroll position and moves an element (given by id)
 * up and down during scroll action.
 *   
 * @param, String id, name of the element (id) to be moved
 * @return Element element, the element moved
 * 
 */

function menuMove(id){
	// configuration
	var startScroll = 385; //174; 	// pixel y from content top
	var timeout = 25;		// in ms for refresh
	var speed = 3;			// x/speed in %, higher value -> smoother moving (D{ 1-oo,!0} )
	
	// some vars
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var element = document.getElementById?document.getElementById(id):document.all?document.all[id]:document.layers[id];
	var sy = 0;
	
	window[id + "_obj"] = element;
	if(document.layers)
		element.style = element;
	element.cy = element.sy = sy;
	element.sPos = function(y){
		this.style.top = y+"px";
	}


	element.move = function(){
		var userY;
		var maxed = 0;
		
		// get the scroll position from user interaction
		userY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
		
		// calculate the maximum pixel movement down
		maxed = document.getElementById('sub_handhelds').offsetHeight;
		maxed += document.getElementById('sub_ioproducts').offsetHeight;
		maxed += document.getElementById('sub_booksize').offsetHeight;
		maxed += document.getElementById('sub_kassen').offsetHeight;
		maxed += document.getElementById('sub_embeddedsolution').offsetHeight;
		maxed += document.getElementById('sub_afolux').offsetHeight;

		maxed += 10*28+20; // add height of main pgrp of menu

		fullHeight = document.getElementById('mainContainer').offsetHeight + 0;
				
		//alert(fullHeight);
		
		// moving between scrolling is > 350px AND scrolling is < fullheight of content div
		if(userY > startScroll && userY < fullHeight-maxed){
			this.cy += (userY-startScroll + this.sy - this.cy)/speed;
			this.sPos(this.cy);
			
		}
		else // snap to bottom
		if(userY > fullHeight-maxed){
			//this.cy = fullHeight-maxed-355;
			this.sPos(fullHeight-maxed-395); // 170
		}
	

		
		// snap to start pos when usr scrolling back to top 
		if(userY < startScroll){
			this.sPos(0);
			this.cy = 0;
		}
	
		
		setTimeout(this.id + "_obj.move()", timeout);
	}
	return element;
}

/**
 * Description:
 * This function switches the css style -> display:block|none.
 * 
 */
function switchlayer(Layer_Name){
	var GECKO = document.getElementById ? 1 : 0;
	var NS = document.layers ? 1 : 0;
	var IE = document.all ? 1 : 0;
	
	if(GECKO){
		document.getElementById(Layer_Name).style.display = (document.getElementById(Layer_Name).style.display == 'block') ? 'none' : 'block';
	}
	else 
		if(NS){
			document.layers[Layer_Name].display = (document.layers[Layer_Name].display == 'block') ? 'none' : 'block';
		}
		else 
			if(IE){
				document.all[Layer_Name].style.display = (document.all[Layer_Name].style.display == 'block') ? 'none' : 'block';
			}
}
