var settime = 0;
if (typeof(currTab)=="undefined")
{
	var currTab="";
}
function init()
{
	document.onmousemove = getMouseXY;
}

function getScrollXY()
{
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' )
	{
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	}
	else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
	{
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
	{
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	return [ scrOfX, scrOfY ];
}
var tempX = 0;
var tempY = 0;
function getMouseXY(e) 
{

	if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)
	
	if (e)
	{ 
		if (e.pageX || e.pageY)
		{ // this doesn't work on IE6!! (works on FF,Moz,Opera7)
			tempX = e.pageX;
			tempY = e.pageY;
			
			//algor = '[e.pageX]';
			//if (e.clientX || e.clientY) algor += ' [e.clientX] ';
		}
		else if (e.clientX || e.clientY)
		{ // works on IE6,FF,Moz,Opera7
			tempX = e.clientX + getScrollXY()[0];
			tempY = e.clientY + getScrollXY()[1];
			//algor = '[e.clientX]';
			//if (e.pageX || e.pageY) algor += ' [e.pageX] ';
		}
	}
	
	/*if (IE) { // grab the x-y pos.s if browser is IE
	tempX = event.clientX + document.body.scrollLeft;
	tempY = event.clientY + document.body.scrollTop;
	}
	else {  // grab the x-y pos.s if browser is NS
	tempX = e.pageX;
	tempY = e.pageY;
	}  
	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}  
	document.Show.MouseY.value = tempY;
	menu=document.getElementById("cmenu");
	menu.style.top=tempY+"px";
	menu.style.left=tempX+"px";
	*/
//document.getElementById('show').innerHTML= 'X: '+tempX+'<br />Y: '+tempY+'<hr>Scroll_left: '+getScrollXY()[0]+'<br />Scroll_right: '+getScrollXY()[1];
	return true;
}



var isDHTML = 0;
var isLayers = 0;
var isAll = 0;
var isID = 0;
if (document.getElementById)
{
	isID = 1;
	isDHTML = 1;
}
else
{
	if (document.all)
	{
		isAll = 1;
		isDHTML = 1;
	}
	else
	{
		browserVersion = parseInt(navigator.appVersion);
		if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4))
		{
			isLayers = 1;
			isDHTML = 1;
		}
	}
}
/* /End */
function findDOM(objectID)
{
	if (isID)
	{
	return (document.getElementById(objectID));
	}
	else
	{
		if (isAll)
		{
			return (document.all[objectID]);
		}
		else
		{
			if (isLayers)
			{
				return (document.layers[objectID]);
			}
		}
	}
}
var curTab = new Array;
var curDiv = new Array;

function loadEvents(Tabs)
{
	for (el = 0;el<Tabs.length; el++)
	{
		x = findDOM(Tabs[el]);
		y = x.getElementsByTagName('div');

		searchType =(typeof(currTab)=="undefined" || currTab!="" )?currTab:y[0].id;

		for ( i=0; i < y.length; i++ )
		{
			if ( currTab !="" )
			{
				if ( currTab != y[i].id )
					{
						findDOM('cont_4_'+y[i].id).style.display = 'none'; //turn off the rest
						y[i].className ='srch_menu_item_off';
						//curTab = findDOM(searchType);//y[i]; // defines the first tab as current <a>
						//curDiv = findDOM('cont_4_'+searchType); // this is the div asociated with the selected tab
					}
					else
					{
						curTab = findDOM(searchType);//y[i]; // defines the first tab as current <a>
						curTab.className ='srch_menu_item_on';
						curDiv = findDOM('cont_4_'+searchType); // this is the div asociated with the selected tab
						curDiv.style.display = 'block';
					}
			}
			else
				{
					curTab = y[0];//y[i]; // defines the first tab as current <a>
					curDiv = findDOM('cont_4_'+searchType); // this is the div asociated with the selected tab
//					alert("curTab: "+curTab+"\ny[i].id: "+y[i].id+"\nsearchType:"+searchType );
				}
			y[i].onclick = onClickFunction;
			y[i].onmouseover = onMouseOverFunction;
			y[i].onmouseout = onMouseOutFunction;
		}
	}
//alert("curTab.id: "+curTab.id+"\ncurDiv: "+curDiv.id);
}
// multimedia fragments tab selection
function onClickFunction()
{
//alert("curr: "+curDiv.id+"\nthis: cont_4_"+this.id+"\n\ncurTab.id: "+curTab.id+"\nthis: "+this.id);
//	curTabSystem = getParentDiv(this);
	curDiv.style.display = 'none';  // remove the current div
	findDOM("cont_4_"+this.id).style.display = 'block'; //display the clicked
	// change appearances of the clicked tabs
	curTab.className ='srch_menu_item_off';
	this.className ='srch_menu_item_on';
	// updates the currents
	curTab = this;
	curDiv = document.getElementById("cont_4_"+this.id);
}
// multimedia tabs onmousein
function onMouseOverFunction(){
//curTabSystem = getParentDiv(this);
//this.className ='srch_menu_item_on';
//this.style.textDecoration="underline";
}
// multimedia tabs onmouseout
function onMouseOutFunction(){
//tabName = getParentDiv(this);
//alert(this.id+" - "+curTab[tabName.id].id);
//this.style.textDecoration="none";
//if (this != curTab[tabName.id]){
//this.className ='srch_menu_item_off';
//}
}
function getParentDiv(id)
{
	return id.parentNode;
}

function onThmbClick(o)
{
	var pict = findDOM('pict');//#thumbs/PICT0001.jpg
	var ret='';
	var txt='';
	var hdr='';
	var src = o.src.replace('thumbs/','');
	var I= new Image();

	I.src = src;
	pict.src = I.src;	
}
function onThmbMouseOver(o)
{
	var I= new Image();
	I.src = 'images/'+getBlaze(o.src,2);
	o.src = I.src;
}
function onThmbMouseOut(o)
{
	var I= new Image();
	var ret='';
	var src = o.src.split('/');
	for (i=0;i<imgCollection.length;i++)
	{
		if (imgCollection[i][2]==src[src.length-1]) 
		{
			ret = imgCollection[i][1];
		}
	}
	I.src = 'images/'+ret;
	o.src = I.src;
}



function changeOpac(opacity, id) {
var object = findDOM(id);
    object.style.opacity = (opacity / 100);
    object.style.MozOpacity = (opacity / 100);
    object.style.KhtmlOpacity = (opacity / 100);
    object.style.filter = "alpha(opacity=" + opacity + ")";
}

function changeSize(w,h,id)
{
	var object = findDOM(id);
	object.style.width=w+"px";
	object.style.height=h+"px";
}

var selectedMenu=null;
function flyer(menu,src)
{
	selectedMenu=findDOM(menu);
	selectedMenu.style.top=tempY+"px";
	selectedMenu.style.left=tempX+"px";
	selectedMenu.style.display="block";
	selectedMenu.style.visibility='visible';
	changeOpac(0,selectedMenu.id ,1);
	//changeOpac(50 , menu ,1);
	var I = new Image();
	I.onload = function (e){setTimeout('goOn("'+I.src+'");',300);};
	I.src = 'pictures/'+src;
}
function goOn(src)
{
//	alert(selectedMenu.id);
	var speed = Math.round(500 / 100);
	var timer = 0; 
	var pictLayer ;
	
	pictLayer = findDOM("build_view");
	pictLayer.src = src;
	wfactor = pictLayer.offsetWidth/90;
	hfactor = pictLayer.offsetHeight/90;
	for(i = 0; i <= 100; i++) 
	{
		setTimeout("changeOpac(" + i + ",'" + selectedMenu.id + "')",(timer * speed));
		setTimeout("changeSize("+parseInt(i*wfactor)+","+parseInt(i*hfactor)+",'"+selectedMenu.id+"')",(timer * speed * .4));
		timer++; 
	}
	flyingLayer = findDOM("flylist");
//	flyingLayer.className="flylist";
	flyingLayer.style.width = pictLayer.offsetWidth+80+'px';
	flyingLayer.style.height =pictLayer.offsetHeight+80+'px';
	return true;
}
var closer = 100;
function closeMenu(menu)
{
//	alert(menu);
	//menu=document.getElementById(menu);
	//menu.style.top=tempY+"px";
	//menu.style.left=tempX+"px";
	var speed = 6000;
	var timer = 1; 
	var i=100;
	wfactor = menu.offsetWidth/100;
	hfactor = menu.offsetHeight/100;
//	findDOM("build_view").style.visibility='hidden';
	
//		dec();
		//closer--;
		//alert(closer);
	//findDOM("hdr").style.display='none';
//	menu.style.width = '100px';
//	menu.style.height ='100px';
	killObject(menu);
}
function dec()
{
		i=closer;
		changeOpac(i,menu.id );
		changeSize(parseInt(i*wfactor),parseInt(i*hfactor),menu.id);
		timer = timer+100; 
	if (closer>10)
	{
		closer = closer-10;
		setTimeout("dec();",300);
	}
}
function closeFlyList()
{
	menu=document.getElementById('flylist');
	closeMenu(menu)
}

function killObject(o)
{
	o.style.display='none';
	o.style.visibility='hidden';
}

function updateMenu(menu)
{
	menu=document.getElementById(menu);
	var v=0;
	for (i=0; i<document.Form1.col.length;i++)
		{
			v+=(document.Form1.col[i].checked)?(document.Form1.col[i].value*1):0;
		}
	menu.style.display="none";
	document.Form1.cols.value=v;
	document.Form1.submit();
}

function dragMenu(menu)
{
	menu=document.getElementById(menu);
	menu.style.top=(tempY-5)+"px";
	menu.style.left=(tempX-20)+"px";
	menu.style.display="block";
}
function showPic()
{
	I = new Image;
	I.src="PA190005.jpg";
	var o=document.getElementById("mainDiv");
//	alert(I.src);
	o.appendChild(I);
	
}

