/* Image Preloads (cities highlights) and put it into array*/

	var maps = new Array();

	Original = new Image(1024,329);
	Original.src = "/images/home_header.gif";
	maps[1] = Original;
	
	Vancouver = new Image(1024,329);
	Vancouver.src = "/images/home_header_vancouver.gif";
	maps[2] = Vancouver;

	Toronto = new Image(1024,329);
	Toronto.src = "/images/home_header_toronto.gif";
	maps[3] = Toronto;

	Hongkong = new Image(1024,329);
	Hongkong.src = "/images/home_header_hongkong.gif";
	maps[4] = Hongkong;

	Japan = new Image(1024,329);
	Japan.src = "/images/home_header_japan.gif";
	maps[5] = Japan;


/* Mouseover function */

	function cities(map_id) 
	{
		GetObj("worldmap").src = maps[map_id].src; 
		return true;
	}


/*****preload imgs for menu ********************/

	home = new Image(1024,23);
	home.src = "/images/menu_home.gif";

	about = new Image(1024,23);
	about.src = "/images/menu_about.gif";

	cast = new Image(1024,23);
	cast.src = "/images/menu_cast.gif";

		cast_2x_profile = new Image(1024,23);
		cast_2x_profile.src = "/images/menu_cast_2x_profile.gif";

		cast_team2x = new Image(1024,23);
		cast_team2x.src = "/images/menu_cast_team2x.gif";

		cast_xsd_sw = new Image(1024,23);
		cast_xsd_sw.src = "/images/menu_cast_xsd_sw.gif";

	news = new Image(1024,23);
	news.src = "/images/menu_news.gif";

	classes = new Image(1024,23);
	classes.src = "/images/menu_classes.gif";

	med = new Image(1024,23);
	med.src = "/images/menu_med.gif";

	contact = new Image(1024,23);
	contact.src = "/images/menu_contact.gif";

	/* End Image Preloads */
	

	var clicked = false;// trigger for menu-link, clicked or not

	function onMouseOver(menu_name)
	{	
		GetObj("menubar").src = menu_name.src; 		
	}

	function onMouseOut(menu_name)
	{
		if (!clicked)// if link is not clicked on mouseout img is changes back
		{
			GetObj("menubar").src = menu_name.src; 
		}else       // if link is clicked img is not changes on mouseout
			{
				clicked = false;
			}
	}	
	
	/* clicked is the trigger, if link is clicked on mouseout should't change img 
	   otherwise it is blinking as JS works faster then new page loading from the server*/
	function click()
	{
		clicked = true; 
	}

/************* preload big pictures and put it into an array ************************/

	var imgs = new Array();
	
	Big_image1 = new Image(638,427);
	Big_image1.src = "/photos/1.jpg";
	imgs[1] = Big_image1;
	
	Big_image2 = new Image(638,427);
	Big_image2.src = "/photos/2.jpg";
	imgs[2] = Big_image2;

	Big_image3 = new Image(640,427);
	Big_image3.src = "/photos/3.jpg";
	imgs[3] = Big_image3;

	Big_image4 = new Image(638,427);
	Big_image4.src = "/photos/4.jpg";
	imgs[4] = Big_image4;

	Big_image5 = new Image(640,427);
	Big_image5.src = "/photos/5.jpg";
	imgs[5] = Big_image5;

function loadPicture(pict)
{	
	GetObj("big_image").src = imgs[pict].src;
	blur(pict);
}

function blur(picture)
{	
	var id;
	var l;
	if ((imgs.length)==0) {l=5;} else {l=imgs.length-1;} 
	
	for(i=1;i<=l;i++)
	{		
		id = "i"+i;
		if (picture!=i)
		{
			GetObj(id).src = "photos/thmb_000" + i + "_bw.jpg";
			_setStyle(GetObj(id), "opacity: 0.35;cursor:pointer;filter:alpha(opacity=35)");		
		}else 
			{
				GetObj(id).src = "photos/thmb_000" + i + ".jpg";
				_setStyle(GetObj(id), "opacity: 1;cursor:pointer;filter:alpha(opacity=100)");			
			}
	}
}
/***********************************************************************/
function GetObj(id) 
{
	 if (document.getElementById)
	 {
		 return document.getElementById(id);
	 } else if (document.all)
		   {
			  return document.all[id];
			}
return false;
}

/********* setAttribute('style', ...) workaround for IE ******************/

function rzCC(s){
   // thanks http://www.ruzee.com/blog/2006/07/\
   // retrieving-css-styles-via-javascript/
   for(var exp=/-([a-z])/; 
       exp.test(s); 
       s=s.replace(exp,RegExp.$1.toUpperCase()));
   return s;
 }

 function _setStyle(element, declaration) {
   if (declaration.charAt(declaration.length-1)==';')
     declaration = declaration.slice(0, -1);
   var k, v;
   var splitted = declaration.split(';');
   for (var i=0, len=splitted.length; i<len; i++) {
      k = rzCC(splitted[i].split(':')[0]);
      v = splitted[i].split(':')[1];
      eval("element.style."+k+"='"+v+"'");
   }
 }
 /****************************************************************************/
 function loadPCastPage(){
 
 }
 function blur_cast(picture, url)
{	
	var id;
	for(i=1;i<=5;i++)
	{		
		id = "i"+i;
		if (picture!=i)
		{				
			GetObj(id).src = "../images/" + url + "_bw.jpg";
			_setStyle(GetObj(id), "opacity: 0.35;cursor:pointer;filter:alpha(opacity=35)");			
		}else 
			{
				GetObj(id).src = "../images/" + url + ".jpg";
				_setStyle(GetObj(id), "opacity: 1;cursor:pointer;filter:alpha(opacity=100)");			
			}
	}
}

function bwCastIn(id, pic) {
	id = "i" + id;
	GetObj(id).src = "../images/" + pic + ".jpg";
	_setStyle(GetObj(id), "opacity: 1;cursor:pointer;filter:alpha(opacity=100)");
}

function bwCastOut(id, pic) {
	id = "i" + id;
	GetObj(id).src = "../images/" + pic + "_bw.jpg";
	_setStyle(GetObj(id), "opacity: 0.5;cursor:pointer;filter:alpha(opacity=50)");
}

/********************************************************************************/
function playvideo(video_file_name, preview_picture ,link){	
	video_frame = GetObj("video_div");	
	
	video_frame.innerHTML = "<object id='player' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' name='player' width='570' height='400'>" +
		"<param name='movie' value='JWPLayer/player-viral.swf' /><param name='allowfullscreen' value='true' />" +
		"<param name='allowscriptaccess' value='always' /><param name='flashvars' value='file=http://" + link + "/video/" + video_file_name + 
	    "&image=http://" + link + "/video/" + preview_picture + "' /><object type='application/x-shockwave-flash' data='JWPLayer/player-viral.swf' width='570' height='400'>"+
		"<param name='movie' value='JWPLayer/player-viral.swf' /><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' />" +
        "<param name='flashvars' value='file=http://" + link + "/video/" + video_file_name + "&image=http://" + link +"/video/" + preview_picture + "' />" +
        "<p><a href='http://get.adobe.com/flashplayer'>Get Flash</a> to see this player.</p>	</object></object>";
}
