/*
File Type		:		script
Purpose			:		main script
Last-Modified	:		20 January 2011
*/
function fade(args,j){
	
	if(j){
		$("#img"+args).fadeOut("fast");
		if(args < 4){ args++; }else{ args = 1;}
		$("#img"+args).fadeIn("fast",function(){setTimeout("fade("+args+","+j+")",7000);});
	}
	else{
		stop();
	}
}
function adjust(args)
{
	fade(args,false);//document.getElementById("img"+args).
	stop();
}
function jx(event)
{
	t = event.currentTarget;
}
function movetoLeft()
{
	j = function(x){return document.getElementById(x);};
	width = j("count").value;
	tw = (width*200);
	parent = $("#parent").width();
	child = j("child").offsetLeft;
	difference = tw - parent;

	if(tw > parent && child > -difference){
		x = j("child").offsetLeft;
		j("child").style.marginLeft = x-200+"px";
	}

}
function movetoRight()
{
	j = function(x){return document.getElementById(x);};
	width = j("count").value;
	tw = (width*200);
	parent = $("#parent").width();
	child = j("child").offsetLeft;
	difference = tw - parent;

	if(tw > parent && child < 0){
		x = j("child").offsetLeft;
		j("child").style.marginLeft = x+200+"px";
	}
}
function zoomout(k)
{
	x = document.getElementById(k);
	
	if((x.offsetHeight-15) < 50){
		y = (x.offsetHeight-15)+5;
		x.style.height = y+"px";
		j = x.offsetHeight-40;
		x.style.marginTop = -j+"px";
		setTimeout("zoomout('"+k+"')",1);
	}
}
function zoomback(k)
{
	x = document.getElementById(k);
	x.style.height = 25+"px";
	x.style.marginTop = 0+"px";
	/*if((x.offsetHeight-15) > 25){
		y = (x.offsetHeight-15)-2;
		x.style.height = y+"px";
		j = x.offsetHeight-40;
		x.style.marginTop = -j+"px";
		setTimeout("zoomback('"+k+"')",10);
	}*/
}
function resize(event)
{
	x = event.currentTarget;
	parent = x.parentNode;
	before = parent.previousSibling;
	beforeChild = before.firstChild;
	after = parent.nextSibling;
	afterChild = after.firstChild;
	/*b = before.previousSibling;
	bChild = b.firstChild;
	l = after.nextSibling;
	lChild = l.firstChild;*/
	
	//main
		parent.style.width = 170+"px";
		parent.style.height = 170+"px";
		parent.style.marginTop = -40+"px";
		x.style.width = 170+"px";
		x.style.height = 170+"px";
	
	//before 1
		before.style.width = 140+"px";
		before.style.height = 140+"px";
		before.style.marginTop = -30+"px";
		beforeChild.style.width = 140+"px";
		beforeChild.style.height = 140+"px";
		
	//before 2
		/*b.style.width = 140+"px";
		b.style.height = 140+"px";
		b.style.marginTop = -20+"px";
		bChild.style.width = 140+"px";
		bChild.style.height = 140+"px";*/
		
	//after 1
		after.style.width = 160+"px";
		after.style.height = 160+"px";
		after.style.marginTop = -30+"px";
		afterChild.style.width = 160+"px";
		afterChild.style.height = 160+"px";
		
	//after 2
		/*l.style.width = 140+"px";
		l.style.height = 140+"px";
		l.style.marginTop = -20+"px";
		lChild.style.width = 140+"px";
		lChild.style.height = 140+"px";*/
		
		
}
function normal(event)
{
	x = event.currentTarget;
	parent = x.parentNode;
	before = parent.previousSibling;
	beforeChild = before.firstChild;
	after = parent.nextSibling;
	afterChild = after.firstChild;
	/*b = before.previousSibling;
	bChild = b.firstChild;
	l = after.nextSibling;
	lChild = l.firstChild;*/
	
	//main
		parent.style.width = 120+"px";
		parent.style.height = 120+"px";
		parent.style.marginTop = 0+"px";
		x.style.width = 120+"px";
		x.style.height = 120+"px";
		
	//before 1
		before.style.width = 120+"px";
		before.style.height = 120+"px";
		before.style.marginTop = 0+"px";
		beforeChild.style.width = 120+"px";
		beforeChild.style.height = 120+"px";
	//before 2
		/*b.style.width = 120+"px";
		b.style.height = 120+"px";
		b.style.marginTop = 0+"px";
		bChild.style.width = 120+"px";
		bChild.style.height = 120+"px";*/
		
	//after 1
		after.style.width = 120+"px";
		after.style.height = 120+"px";
		after.style.marginTop = 0+"px";
		afterChild.style.width = 120+"px";
		afterChild.style.height = 120+"px";
		
	//after 2
		/*l.style.width = 120+"px";
		l.style.height = 120+"px";
		l.style.marginTop = 0+"px";
		lChild.style.width = 120+"px";
		lChild.style.height = 120+"px";*/
		
}
function video_run(x){
	
	//::environment variables
	sw = screen.availWidth;
	sh = screen.availHeight;
	tw = 600;
	th = 350;
	
	cx = parseInt((sw/2)-(tw/2));
	cy = parseInt((sh/2)-(th/2));
	
	j = document.createElement("div");
	f = document.createElement("embed");
	s = document.createElement("div");
	
	//::SHADOW
	s.style.width = 100+"%";
	//s.style.minHeight = sh+"px";
	s.style.height = 100+"%";
	s.style.position = "absolute";
	s.style.zIndex = 20;
	s.style.display = "none";
	s.style.backgroundColor = "#000000";
	s.id = "shadow-struct";
	
	//::parentHolder
	j.style.width = tw+"px";
	j.style.height = th+"px";
	j.style.backgroundColor = "#000000";
	j.style.position = "fixed";
	j.style.left = cx+"px";
	j.style.top = cy+"px";
	j.style.display = "none";
	j.id = "struct-video";
	j.zIndex = 21;
	
	//::video
	f.style.width = tw+"px";
	f.style.height = th+"px";
	f.src = x;
	f.id = "struct-src";
	
	document.body.onclick = function(){$("#"+j.id).fadeOut(
														   function(){
															   document.body.removeChild(j);
															   $("#"+s.id).fadeOut();
															   }
														   )};
	
	//::APPEND
		document.body.appendChild(s);
		document.body.appendChild(j);
		
		$("#"+s.id).fadeTo("normal",0.5, function(){
			$("#"+j.id).fadeIn(function(){
										
				j.appendChild(f);
				
				//::CHECK SCROLLING
					scrollCheck();
					resize();
			});
		});
		
}
function scrollCheck(){
	tgt = document.getElementById("shadow-struct");
	if(window.pageYOffset != 0 || tgt.marginTop != 0){
		currentY = window.pageYOffset;
		tgt.style.top = currentY+"px";
	}
	else{
		currentY = window.pageYOffset;
		tgt.style.top = currentY+"px";
	}
	setTimeout("scrollCheck()",0);
}
function resize(){
	if(document.body.onresize) {
		alert("AAAA");
	}
	setTimeout("resize()",0);
}


