// JavaScript Document

function sendform(){
	document.contactform.submit();	
}
function changeframe(h){
	top.document.getElementById("frameInf").height=h;
}
function seeRoll(object, className){
	//img="/templates/Img/flags/"+flagAc+"_r.gif";
	//document.images["flag"].src=img;
	//document.getElementById("divlang").style.visibility="visible";
	object.className = className;	
	document.getElementById("divlang").style.visibility="visible";
}
function seeNeu(object, className){
	//this.style.className = 
	//img="/templates/Img/flags/"+flagAc+"_n.gif";
	//document.images["flag"].src=img;
	object.className = className;	
	document.getElementById("divlang").style.visibility="hidden";
}

var scrollStep=1;
var timer="";
function scrollDivDown(id){
	clearTimeout(timer);
	document.getElementById(id).scrollTop+=scrollStep;
	timer=setTimeout("scrollDivDown('"+id+"')",40);
}
function scrollDivUp(id){
	clearTimeout(timer);
	document.getElementById(id).scrollTop-=scrollStep;
	timer=setTimeout("scrollDivUp('"+id+"')",40);
}
function scrollDivRight(id, maxOffset, scrollWidth){	
	clearTimeout(timer)	;
	scrollOffset = document.getElementById(id).scrollLeft+scrollStep;
	if (scrollOffset < maxOffset - scrollWidth) {
		document.getElementById(id).scrollLeft+=scrollStep;
		timer=setTimeout("scrollDivRight('"+id+"', "+maxOffset+", "+scrollWidth+")",40);
	}
}
function scrollDivLeft(id){
	clearTimeout(timer);
	document.getElementById(id).scrollLeft-=scrollStep;
	timer=setTimeout("scrollDivLeft('"+id+"')",40);
}
function stopMe(){
	clearTimeout(timer);
}

var clearSearch = true;
function focusSearch() {
	if (clearSearch==true) {
		document.getElementById("xSearch").value="";
		document.getElementById("xSearch").className="searchFieldFocused";
		clearSearch = false;
	}
}

function swapFooter(ID){
	for (f=0;f<tabs.length;f++) {
		document.getElementById(tabs[f]).style.display="none";
		document.getElementById(tabs[f]+"Tab").className="";
	}
	for (f=0;f<tabs.length;f++) {
		if (tabs[f]==ID) {
			document.getElementById(tabs[f]).style.display="block";
			document.getElementById(tabs[f]+"Tab").className="over";
		}
	}
	return false;		
}
var tabsBtoB = new Array("incentivesB2B", "promotionsB2B", "rewardsB2B", "teamB2B");	
function swapFooterBtoB(ID){
	document.getElementById("corporate").style.display="none";	
	for (f=0;f<tabsBtoB.length;f++) {
		document.getElementById(tabsBtoB[f]+"Tab").className="";
		document.getElementById(tabsBtoB[f]).style.display="none";
	}
	document.getElementById(ID).style.display="block";
	document.getElementById(ID+"Tab").className="over";
	//swapFooterIncentives("inc_list");
	return false;		
}
var tabsIncentive = new Array("inc_list", "inc_customer", "inc_employee", "inc_partners");
function swapFooterIncentives(ID){
	for (f=0;f<tabsIncentive.length;f++) {
		document.getElementById(tabsIncentive[f]).style.display="none";
	}
	document.getElementById(ID).style.display="block";
	return false;		
}
function goSlide(whichSlide){
	clearTimeout(slideShow);				
	if (whichSlide!=currentSlide) {
		changeSlide (whichSlide);						
	}
	slideShow = window.setTimeout("goNextSlide()", 30000);
}				
function goNextSlide() {				
	nextSlide = currentSlide + 1;
	if (nextSlide>8) {
		nextSlide=0;
	}
	changeSlide (nextSlide);
	slideShow = window.setTimeout("goNextSlide()", 8000);
}			
function changeSlide(whichSlide){
	document.getElementById("sectionDiv_"+currentSlide).style.display="none";
	document.getElementById("sectionDiv_"+whichSlide).style.display="block";
	document.getElementById("slideLink_"+currentSlide).className="";
	document.getElementById("slideLink_"+whichSlide).className="over";					
	currentSlide = whichSlide;
}
var slideShow = false;
var currentSlide = 0;
function initSlideshow(){
	slideShow = window.setTimeout('goNextSlide()', 20000);
	currentSlide = 0;
}
var XMLHttpArray = [
		function() {return new XMLHttpRequest()},
		function() {return new ActiveXObject("Msxml2.XMLHTTP")},
		function() {return new ActiveXObject("Msxml2.XMLHTTP")},
		function() {return new ActiveXObject("Microsoft.XMLHTTP")}
	];
	var theUploadKey = "";
	function createXMLHTTPObject(){
		var xmlhttp = false;
		for(var i=0; i<XMLHttpArray.length; i++){
			try{xmlhttp = XMLHttpArray[i]();}
			catch(e){continue;						}
			break;
		}
		return xmlhttp;
	}
	function AjaxRequest(url,callback,method){
		var req = createXMLHTTPObject();
		req.onreadystatechange= function(){
			if(req.readyState != 4) {return;}
			if(req.status != 200) {return;}
			callback(req);
		}
		req.open(method,url,true);
		req.setRequestHeader('User-Agent', 'My XMLHTTP Agent');
		req.send(null);
	}
	var autoSearchListCount = 0;
	var autoSearchListActive = -1;	
	var autoSearchDelay = false;
	var autoSearchCloseDelay = false;
	function autoSearch(evt) {
		var charCode = (evt.which) ? evt.which : event.keyCode
		switch (charCode) {			
			case 38:
				if (autoSearchListCount>0) {
					if (autoSearchListActive<=0) {
						autoSearchListActive = autoSearchListCount;
					} else {
						autoSearchListActive--;
					}
					renderArrows();
				}
				break;				
			case 40:
				if (autoSearchListCount>0) {
					if (autoSearchListActive>autoSearchListCount || autoSearchListActive==-1) {
						autoSearchListActive = 1;
					} else {
						autoSearchListActive++;
					}
					renderArrows();
				}
				break;
			default:
				clearTimeout(autoSearchDelay);
				autoSearchDelay = window.setTimeout("autoSearchDelayed()", 250)				
				break;
		}
	}
	function autoSearchDelayed(){
		xSearch = document.getElementById("xSearch").value;
		if (xSearch.length >=2) {
			url = "/autoSearch.html?xSearch="+encodeURIComponent(xSearch);
			AjaxRequest(url,renderSearchList,"get");
		}
	}
	function goAutoSearchArrow(){
		if (autoSearchListActive>-1) {
			self.location.href=document.getElementById("autoSearch_"+autoSearchListActive).href;
			return false;
		} else {
			return true;
		}
	}
	function renderSearchList(req) {
		if (req.responseText!="") {
			document.getElementById("autoSearchContent").style.display = "block"
			document.getElementById("autoSearchContent").innerHTML = req.responseText;
			autoSearchListCount = parseInt (document.getElementById("autoSearchProductCount").value);
			autoSearchListActive = -1;
			//if (document.getElementById("xSearchReal").value!=document.getElementById("xSearch").value){
				//url = "/autoSearch.html?xSearch="+encodeURIComponent(document.getElementById("xSearch").value);
				//AjaxRequest(url,renderSearchList,"get");
			//}
		} else { 
			document.getElementById("autoSearchContent").style.display = "none";
			autoSearchListCount = 0;
			autoSearchListActive = -1;
		}
	}
	function renderArrows(){
		for (f=1;f<=autoSearchListCount;f++) {
			if (autoSearchListActive==f) {
				document.getElementById("autoSearch_"+f).className="productGroupSearchActive";
			} else { 
				document.getElementById("autoSearch_"+f).className="productGroupSearch";
			}
		}
		if (autoSearchListActive == parseInt (autoSearchListCount) + 1) {
			document.getElementById("autoSearch_All").className="productGroupSearchAllActive";				
		} else {
			document.getElementById("autoSearch_All").className="productGroupSearchAll";
		}
	}
	function hideAutoSearch(){
		autoSearchCloseDelay = window.setTimeout("hideAutoSearchDelayed()", 250)
	}
	function hideAutoSearchDelayed(){
		document.getElementById("autoSearchContent").style.display = "none";
		autoSearchListCount = 0;
		autoSearchListActive = -1;		
	}
	function clearAutoSearchDelay(){
		clearTimeout(autoSearchCloseDelay);
		return true;
	}
	function submitAutoSearch() {
		document.getElementById("autoSearchForm").submit();
		return false;
	}
	function initTimer (secsToZero){
		thisObject = new Object();
		thisObject.secsToZero = secsToZero;
		var d = new Date();
		thisObject.startTime = (d.getHours() * 60 * 60) + (d.getMinutes() * 60) + (d.getSeconds());
		thisObject.timer = setTimeout ("updateTimer()", 1000);
		return thisObject;
	}
	function updateTimer (){
		var d = new Date();
		thisTime = (d.getHours() * 60 * 60) + (d.getMinutes() * 60) + (d.getSeconds());				
		secsSincePageload = thisTime - timerObject.startTime;
		secsToZero = timerObject.secsToZero - secsSincePageload;
		hours = Math.floor(secsToZero / (60 * 60));
		secsToZero = secsToZero - (hours * 60 * 60);
		mins = Math.floor (secsToZero / 60);
		secs = secsToZero - (mins * 60);				
		hours = hours.toString ();
		while (hours.length < 2) {hours = "0" + hours;}
		mins = mins.toString ();
		while (mins.length < 2) {mins = "0" + mins;}
		secs = secs.toString ();
		while (secs.length < 2) {secs = "0" + secs;}
		document.getElementById("timerH1").innerHTML = hours.substr(0, 1);
		document.getElementById("timerH2").innerHTML = hours.substr(1, 1);
		document.getElementById("timerM1").innerHTML = mins.substr(0, 1);
		document.getElementById("timerM2").innerHTML = mins.substr(1, 1);
		document.getElementById("timerS1").innerHTML = secs.substr(0, 1);
		document.getElementById("timerS2").innerHTML = secs.substr(1, 1);
		thisObject.timer = setTimeout ("updateTimer()", 1000);
	}



	
