// JavaScript Document

window.onload = function init () {
	
	
	//loadhpalider('table-contant',9,1000);
	
	//feat_loadhpalider('featured-contant',5,3000);
	
	loadopecityajax();
	
	content_area(10);

};



oldone=1
numfr=2

function loadopecityajax()
{
	
	
	for(k=2;k<=6;k++)
	{
		fram="frame"+k;
		changeOpacFn(0, fram);
	}

	document.getElementById("frame1").style.zIndex=2;
	//tst=opacityFn("frame1", 1, 100, 900);
	
	settime=setInterval(next_,4000);
}

function next_()
{
	if(numfr==1){oldone=6;}else{oldone=numfr-1;}
	for(k=1;k<=6;k++)
	{
			if(numfr==k)
			{
				changeOpacFn(0, "frame"+numfr);
				document.getElementById("frame"+numfr).style.zIndex=2;
				tst=opacityFn("frame"+numfr, 1, 100, 2000);
			}
			else if(oldone==k)
			{
					document.getElementById("frame"+k).style.zIndex=1;
			}
			else
			{
					document.getElementById("frame"+k).style.zIndex=-1;
					tst=opacityFn("frame"+numfr, 1, 100, 2000)
			
			}
	}
	if(numfr==6){numfr=1;}else{numfr=numfr+1;}
}


function opacityFn(id, opacStart, opacEnd, millisec) 
{
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;
 	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) 
	{
		for(i = opacStart; i >= opacEnd; i--) 
		{
			setTimeout("changeOpacFn(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} 
	else if(opacStart < opacEnd) 
	{
		for(i = opacStart; i <= opacEnd; i++)
		{
			setTimeout("changeOpacFn(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
	return (i);
}
			

function changeOpacFn(opacity, id) 
{
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
	if(opacity==0){document.getElementById(id).style.display="none";}else{document.getElementById(id).style.display="";}
} 


function content_area(cont_id)
{
	
	var tag_id='text_';
	
	var bg_id='click';
	
	for(i=1;i<=10;i++)
	{
		new_id=tag_id+i;
		
		bgimg_id=bg_id+i;
		
		if(cont_id==i)
		{
			newImage = "url(images/active-menu.jpg)";

		$(document.getElementById(new_id)).show("fast");
		//document.getElementById(new_id).style.backgroundImage = newImage;
		$('#click'+i).css({ backgroundImage : "url(images/active-menu.jpg)" });

		}
		else
		{
		$('#click'+i).css({ backgroundImage : "url(images/sub-menu-button-bg.jpg)" });
		$(document.getElementById(new_id)).hide("fast");
		}
	}
		
	
	
}

