// switch divs /////////////////////////////////////////////////////////

arr_divs=new Array();
arr_divs[1]='news';
arr_divs[2]='prize';
arr_divs[3]='andy';
arr_divs[4]='condition';
arr_divs[5]='judge';
arr_divs[6]='form';
arr_divs[7]='contact';
arr_divs[8]='links';

arr_winner_divs=new Array();
arr_winner_divs[0]='winners';
arr_winner_divs[1]='winner_2012_biography';
arr_winner_divs[2]='winner_2012_works';
arr_winner_divs[3]='winner_2010_biography';
arr_winner_divs[4]='winner_2010_works';
arr_winner_divs[5]='winner_2009_biography';
arr_winner_divs[6]='winner_2009_works';
arr_winner_divs[7]='winner_2008_biography';
arr_winner_divs[8]='winner_2008_works';
arr_winner_divs[9]='winner_2007_biography';
arr_winner_divs[10]='winner_2007_works';
arr_winner_divs[11]='winner_2006_biography';
arr_winner_divs[12]='winner_2006_works';


function switch_winners_html_divs(p_div_id)
{
	var div_id;
	len=arr_winner_divs.length;
	/* Hide all divs */
	for(i=0;i<len;i++)
	{
		div_id=arr_winner_divs[i]+"";

		//if(div_id != p_div_id)
		document.getElementById(div_id).style.display     = 'none';	
	}

	/* Show chosen div */
	document.getElementById(p_div_id).style.display     = 'block';
}

// flashProxy is the proxy for communicating with the top flash file.
// menu_proxy is the proxy for communicating with the menu flash file.
function show_site_section(p_div_id)
{
	switch_html_divs(p_div_id);

	// flashProxy.call('goto_and_stop',p_div_id);
	// the following two lines replace the previous one due to a misterious bug:
	// the goto_and_stop function was stopped being called after 27 hits on the 
	// logo and one of the menu links.
	// The name for each flash file was set using the kit's setId method in the html file
	// containing the flash files.
	x=window.document.swf_top;
	x.TGotoLabel("/",p_div_id);

	// This functin replaces the call from the top swf file to the proxy.
	// This is olso due to the fact that after 27 calls to the proxy
	// the call did not work.
	if(p_div_id=="news")
	{
		
		x=window.document.swf_menu;
		x.GotoFrame(1);
	}
}

function switch_html_divs(p_div_id)
{
	var div_id;
	//for(i=1;i<arr_divs.length;i++)
	for(i=1;i<8;i++)
	{
		div_id=arr_divs[i]+"";

		//if(div_id != p_div_id)
		document.getElementById(div_id).style.display     = 'none';	
	}
	//alert(p_div_id);
	document.getElementById(p_div_id).style.display     = 'block';

	if(p_div_id=="andy")
	{
		switch_winners_html_divs('winners');		
	}
}




// the top swf file calls this function when 
function goto_and_stop(p_frame_num)
{
	//alert(menu_proxy);
    menu_proxy.call('goto_and_stop',p_frame_num);
}


function showNextOrPrveImage(nextOrPrev)
{
    var div_id;
	//for(i=1;i<arr_divs.length;i++)
	for(i=1;i<=NUM_IMAGES;i++)
	{
		div_id='img_'+i;
		document.getElementById(div_id).style.display='none';	
	}
	//alert(p_div_id);
	div_id='img_'+setCurrentNextImgIdx(nextOrPrev);
	document.getElementById(div_id).style.display='block';
}

/* Get next circular image idx and set it */
function setCurrentNextImgIdx(nextOrPrev)
{
	if(nextOrPrev=='next')
	{
		if(CURR_IMG_IDX<NUM_IMAGES)
			CURR_IMG_IDX++;
		else
			CURR_IMG_IDX=1;
	}
	else
	{
		if(CURR_IMG_IDX>1)
			CURR_IMG_IDX--;
		else
			CURR_IMG_IDX=NUM_IMAGES;
	}
	return CURR_IMG_IDX;
}


function openWindow(p_w,p_h,p_url,p_name)
{
	//alert(p_url);
	features = '';
	var w = p_w;
	var h = p_h;
	var top = (screen.height - h)/4;
	var left = (screen.width - w)/2; 
	if(top < 0) top = 0; 
	if(left < 0) left = 0; 
	features =  "'top=";
	features += top;
	features += ',left=';
	features += left;
	features += ',height=';
	features += p_h;
	features += ',width = ';
	features += p_w;
	features += ',status=no,toolbar=no,menubar=no,location=no';
	//alert (top);alert (left);alert (features);
	window.open(p_url,p_name,features);
}
