/* $Header: /usr/local/cvsroot/newproj/elements/scripts/triggers.js,v 1.2 2009/09/16 23:24:46 tngsandiego Exp $ */
/* TRIGGERS */
var timerId;
var timerId2;
var lopen='';
var idGetBig;
var actSize=10;
// 1 - dropdown
function startTrigger(n,who){
	if(!n){
		n = 10000;
	}
	if(!timerId){
        	timerId = setTimeout('resizeHeight("cover_'+who+'",1);setLeft("cover_'+lopen+'",-999);changeClass("head_button_'+who+'","head_button");stopTrigger();', n);
	}
}
function stopTrigger(){
	clearTimeout(timerId);
	timerId = false;
}
// display
function displayMenu(obj,element) {
	lopen = element;
	var but = document.getElementById("cover_"+element);
	var leftIn=findPosX(obj);
 	leftIn+=7;
	but.style.left = leftIn +'px';
	but.style.display = 'block';
	changeClass('head_button_'+element,"head_button head_button_selected");
}
function hideLastMenu(now){
        if(lopen.length > 0){
        	//alert(lopen);
        	if(lopen==now){return false;}
        	changeClass('head_button_'+lopen,"head_button");
		setLeft("cover_"+lopen,'-999');
		resizeHeight("cover_"+lopen,10);
		actSize=10;
		stopTrigger();
		clearInterval(idGetBig);
	}
}
// 2 - livesearch
function startTrigger2(n,who){
	if(!n){
		n = 10000;
	}
	if(!timerId){
        	timerId2 = setTimeout('hide("'+who+'");stopTrigger2();', n);
	}
}
function stopTrigger2(){
	clearTimeout(timerId2);
	timerId2 = false;
}
function findPosX(obj){
	if(eval(document.getElementById("pageContainer"))){
		var mainDad=document.getElementById("pageContainer");
	}else{
		var mainDad=document.getElementById("bigContainer");
	}
	var difference = mainDad.offsetLeft;
	var curleft = 0;
	if(obj.offsetParent){
		while(1){
			curleft += obj.offsetLeft;
			if(!obj.offsetParent) break;
			obj = obj.offsetParent;
		}
	}else if(obj.x){
		curleft += obj.x;
	}
	curleft -= difference + 7;
	return curleft;
}
// circle Header
var headerTimerId;
function circleHeader(count){
document.getElementById('controlBanner').value=0;
count=parseInt(count) - 1;
//document.getElementById('debug').innerHTML += " ["+count+"] ";
	headerTimerId = setInterval(function(){
		var actualObj = document.getElementById('controlBanner');
		var objValue = parseInt(actualObj.value);
		if(objValue>=count){
			objValue = 0;
		}else{
			objValue += 1;
		}
		actualObj.value = objValue;
		bannerShow(objValue);
		//document.getElementById('debug').innerHTML += " ("+actualObj.value+") ";
	},5000);
}

/* hideslow/displayslow */
var idHide,idShow;
function hideslow(id){
var obj = document.getElementById(id);
var uniqueId = id.split('_');
var debug = document.getElementById('debug');
if(obj.style.display == 'none'){return false;}
var actOpac = 100;
        var localIdHide = setInterval(function(){
        	actOpac = parseInt(actOpac * 0.8);
                obj.style.opacity = number_format(parseFloat(actOpac/100), 1, ".", ",");
                obj.style.filter = 'alpha(opacity=' + actOpac + ')';
                if(actOpac < 1){
                	//document.getElementById('debug').innerHTML += " ("+obj.id+")>"+obj.style.opacity+"|"+actOpac+" ";
                        obj.style.display = 'none';
                        obj.style.opacity = 0;
                        obj.style.filter = 'alpha(opacity=0)';
			if(uniqueId[1]==document.getElementById('controlBanner').value){
	                        obj.style.opacity = 1;
	                        obj.style.filter = 'alpha(opacity=100)';
	                        obj.style.display = 'block';
			}
			clearInterval(localIdHide);
		}
        },33);
}
function displayslow(id){
var obj = document.getElementById(id);
var actOpac=1;
if(obj.style.display == 'block'){return false;}
obj.style.display = 'block';
        var localShow = setInterval(function(){
        	actOpac = parseInt(actOpac * 2);
                obj.style.opacity = number_format(parseFloat(actOpac/100), 1, ".", ",");
                obj.style.filter = 'alpha(opacity=' + actOpac + ')';
                if(actOpac > 99){
                        obj.style.opacity = 1;
                        obj.style.filter = 'alpha(opacity=100)';
			clearInterval(localShow);
		}
        },33);
}
