/* $Header: /usr/local/cvsroot/scottmadden.com/elements/scripts/script.js,v 1.4 2009/04/09 19:16:20 tngsandiego Exp $ */




function linkInTopFrame(link,frame){
        top.frames[frame].location.href = link;
}

/* Thingy */
function lastThingy(id){
	document.getElementById(id).className='bottomFlier_over';
}
function lastThingyOff(id){
	document.getElementById(id).className='bottomFlier';
}
var idHide,idShow;
function hideslow(id){
var obj = document.getElementById(id);
var actOpac=100;
        idHide = setInterval(function(){
        	actOpac = parseInt(actOpac * 0.8);
        	alert('Halpha(opacity=' + actOpac + ')');
                obj.style.opacity = number_format(parseFloat(actOpac/100), 1, ".", ",");
                obj.style.filter = 'alpha(opacity=' + actOpac + ')';
                if(actOpac < 1){
                        obj.style.opacity=0;
                        obj.style.filter = 'alpha(opacity=0)';
			clearInterval(idHide);
		}
        },33);
}
function displayslow(id){
var obj = document.getElementById(id);
var actOpac=1;
//alert(actOpac+ " ; " + id + " :: " + obj);
        idShow = setInterval(function(){
        	actOpac = parseInt(actOpac * 1.2);
        	alert('Salpha(opacity=' + actOpac + ')');
                obj.style.opacity = number_format(parseFloat(actOpac/100), 1, ".", ",");
                obj.style.filter = 'alpha(opacity=' + actOpac + ')';
                if(actOpac > 99){
                        obj.style.opacity=100;
                        obj.style.filter = 'alpha(opacity=100)';
			clearInterval(idShow);
		}
        },33);
}

/* Grading */
function gradeTo(id,title){
	var actual=document.forms['glb'].elements['actual'].value;
	document.forms['glb'].elements['actual'].value=id;
	
	hide('bigHead_'+actual);
	display('bigHead_'+id);
	hide('greyBall_'+actual);
	display('greyBall_'+id);
	
	var newTitle = document.getElementById('title');
	newTitle.innerHTML = title;
}
/* Bios */
function showBios(id){
	clearInterval(idShow);
	if(eval(document.getElementById("biosHead_1")))document.getElementById("biosHead_1").className="floatLeft pointer unactive relative mr2";
	if(eval(document.getElementById("biosHead_2")))document.getElementById("biosHead_2").className="floatLeft pointer unactive relative mr2";
	if(eval(document.getElementById("biosHead_3")))document.getElementById("biosHead_3").className="floatLeft pointer unactive relative mr2";
	if(eval(document.getElementById("biosHead_4")))document.getElementById("biosHead_4").className="floatLeft pointer unactive relative mr2";

	document.getElementById("biosHead_"+id).className="floatLeft pointer active relative mr2";
	
	var obj = document.getElementById('biosCover');
	var actOpac=1;
	var up=true;
	display('biosCover');
        idShow = setInterval(function(){
                if(up){
	        	actOpac = actOpac * 1.6;
	                obj.style.opacity = number_format(parseFloat(actOpac/100), 1, ".", ",");
	                obj.style.filter = 'alpha(opacity=' + number_format(actOpac, 0, ".", ",") + ')';
                }else{
			actOpac = actOpac * 0.6;
		        obj.style.opacity = number_format(parseFloat(actOpac/100), 1, ".", ",");
		        obj.style.filter = 'alpha(opacity=' + number_format(actOpac, 0, ".", ",") + ')';
	        }
                if(actOpac > 99 && up){
                        obj.style.opacity=100;
                        obj.style.filter = 'alpha(opacity=100)';
			
			if(eval(document.getElementById("bios_1")))hide("bios_1");
			if(eval(document.getElementById("bios_2")))hide("bios_2");
			if(eval(document.getElementById("bios_3")))hide("bios_3");
			if(eval(document.getElementById("bios_4")))hide("bios_4");

			display("bios_"+id);
			actOpac=100;
			
			up=false;
		}else if(actOpac < 1){
			obj.style.opacity=0;
			obj.style.filter = 'alpha(opacity=0)';
			hide('biosCover');
			clearInterval(idShow);
		}
        },33);
}

/* Search */
function createMenus(list){
var listArr = Array();
	var mainDiv = document.getElementById('tipContainer');
	var sb = document.getElementById('topSearchBox');
	removeOpt('newDiv');

	var newDiv = document.createElement('DIV');
	newDiv.id = 'newDiv';
	mainDiv.appendChild(newDiv);

	listArr = list.split("|");
	if(listArr.length<1 || list.length<=1){
		hide('liveSearch');
		stopTrigger2();
		return false;
	}else{
		display('liveSearch');
		//startTrigger2(5000,'liveSearch');
	}
	for(k=0;k<listArr.length;k++){
		var listDiv = document.createElement('DIV');
		//listDiv.onclick = function(){document.forms['eve_form_topsearch'].elements['form_search_phrase'].value=this.innerText;hide('liveSearch');stopTrigger2();};
		listDiv.onclick = function(){if(this.innerText==undefined || this.innerText.length<=1){var toGo = this.textContent;}else{var toGo = this.innerText;};document.forms['eve_form_topsearch'].elements['form_search_phrase'].value=toGo;hide('liveSearch');stopTrigger2();};
		listDiv.className = 'tipElement';
		listDiv.innerHTML = "<span style='font-weight:bold;font-size:10pt;margin-left:10px;'>"+sb.value+"</span>" + listArr[k].substring(sb.value.length);
		newDiv.appendChild(listDiv);
		
		delete newDiv;
	}
	return true;
}

/* IE6 HACK */
function mObscure(id){
	document.getElementById(id).style.backgroundColor='#485e71';
}
function mEnlight(id){
	document.getElementById(id).style.backgroundColor='#6E89A1';
}
/* Custom FindPos */
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;
}