// <!--
function signup(){
	MM_showHideLayers('panel_mask','','show');
	MM_showHideLayers('preview','','hide');
	MM_showHideLayers('store','','hide');	
	MM_showHideLayers('signup','','show');
	document.getElementById('panel_mask').style.zIndex = 999;
	var media_url = 'images/mask_tile.png';
	var flashvars = {};
	var attributes = {};
	var params = {};
	attributes.wmode = "transparent";
	params.bgcolor = "#616161"; 
	params.scale = 	"exactfit";
	swfobject.embedSWF(media_url, "media", "720", "480", "9.0.0", "flash/expressInstall.swf", flashvars, params, attributes);
	swfobject.embedSWF(media_url, "comments", "255", "218", "9.0.0", "flash/expressInstall.swf", flashvars, params, attributes);
	document.getElementById('media').style.zIndex = -1;
};

function preview(){
	MM_showHideLayers('panel_mask','','show');
	MM_showHideLayers('preview','','show');
	MM_showHideLayers('store','','hide');	
	MM_showHideLayers('signup','','hide');
	document.getElementById('panel_mask').style.zIndex = 999;
	var media_url = 'images/mask_tile.png';
	var flashvars = {};
	var attributes = {};
	var params = {};
	attributes.wmode = "transparent";
	params.bgcolor = "#616161"; 
	params.scale = 	"exactfit";
	swfobject.embedSWF(media_url, "media", "720", "480", "9.0.0", "flash/expressInstall.swf", flashvars, params, attributes);
	swfobject.embedSWF(media_url, "comments", "255", "218", "9.0.0", "flash/expressInstall.swf", flashvars, params, attributes);
	document.getElementById('media').style.zIndex = -1;
	top.frames['gameframe'].showGame();
};

// for showing/hiding blog comments
function showhide(num){
	var obj = document.getElementById('resp'+num);
	var iconObj = document.getElementById('blogicon'+num);
	 if(obj.style.display == 'none'){
		obj.style.display = 'block';
		iconObj.src = '../images/icon_minus.gif';
	 }else{
		 obj.style.display = 'none';
		 iconObj.src = '../images/icon_plus.gif';
	 }
}

function store(){
	MM_showHideLayers('panel_mask','','show');
	MM_showHideLayers('preview','','hide');
	MM_showHideLayers('store','','show');	
	MM_showHideLayers('signup','','hide');
	document.getElementById('panel_mask').style.zIndex = 999;
	var media_url = 'images/mask_tile.png';
	var flashvars = {};
	var attributes = {};
	var params = {};
	attributes.wmode = "transparent";
	params.bgcolor = "#616161"; 
	params.scale = 	"exactfit";
	swfobject.embedSWF(media_url, "media", "720", "480", "9.0.0", "flash/expressInstall.swf", flashvars, params, attributes);
	swfobject.embedSWF(media_url, "comments", "255", "218", "9.0.0", "flash/expressInstall.swf", flashvars, params, attributes);

	document.getElementById('media').style.zIndex = -1;
};

function setTabs(ndx){
	for(i=0;i<4;i++){
		if(i == ndx){
			MM_swapImage('tab'+i,'','images/tab' + i  + '_s2.png',1);
		}else{
			MM_swapImage('tab'+i,'','images/tab' + i  + '_s1.png',1);
		}
	}
}

function showCmtform() {
	document.getElementById('commentform').style.display='block';
	document.getElementById('commentlist').style.display='none';
	// fresh iframe
	var f = document.getElementById('iframeCmt');
	f.src = f.src;
	// scroll overflow div to top
	var objDiv = document.getElementById("cmt_box");
	objDiv.scrollTop = 0;
}

function showCmtlist() {
	document.getElementById('commentform').style.display='none';
	document.getElementById('commentlist').style.display='block';
}

//************************************************************
// function loadGame(num)
// Used by Games page
//************************************************************
/*
function loadGame(num){
	var flashvars = {};
	var params = {};
	var attributes = {};
	switch(num){
		case 1 :
			var media_url = '../flash/fpaworld1.swf';
			// set world1 buttons selected/inactive			
			setBtn('btn_world1','off','../images/btn_world1_s3.png');
			// set world2 button active
			setBtn('btn_world2','on','../images/btn_world2_s1.png','../images/btn_world2_s2.png');

			// set flash parameters/attributes
			params.menu = "false";
			params.quality = "high";
			params.allowfullscreen = "false";
			attributes.align = "middle";
		break;
		case 2 :
			var media_url = '../flash/fpaworld2.swf';
			// set world2 button selected/inactive
			setBtn('btn_world2','off','/images/btn_world2_s3.png');
			// set world1 button active
			setBtn('btn_world1','on','/images/btn_world1_s1.png','/images/btn_world1_s2.png');
			// set flash parameters/attributes
			params.menu = "false";
			params.quality = "high";
			params.allowfullscreen = "false";
			attributes.align = "middle";
		break;
		default :
			var media_url = '../images/mask_tile.png';
			attributes.wmode = "transparent";
			params.bgcolor = "#616161"; 
			params.scale = 	"exactfit";
			swfobject.embedSWF(media_url, "panel_media", "720", "480", "9.0.0", "flash/expressInstall.swf", flashvars, params, attributes);
		break;	
	}
	swfobject.embedSWF(media_url, "panel_game", "720", "480", "9.0.0", "flash/expressInstall.swf", flashvars, params, attributes);
}
*/
function setBtn(id, state, imgpath, imgpath_f2){
	btnObj = document.getElementById(id);
	if(state == 'off'){
		btnObj.setAttribute('src', imgpath);
		btnObj.setAttribute('onmouseover', null);
		btnObj.setAttribute('onmouseout', null);
	}else if(state == 'on'){
		btnObj.setAttribute('src', imgpath);
		var overStr = "MM_swapImage('" + id + "','','" + imgpath_f2 + "',1)";
		btnObj.setAttribute('onmouseover', overStr);
		btnObj.setAttribute('onmouseout', 'MM_swapImgRestore()');
	}
}

// Used by the video page
function switchVideo(media_url){
	var likestr = 'http://www.facebook.com/plugins/like.php?href=' + media_url + '&amp;layout=button_count&amp;show_faces=false&amp;width=500&amp;action=like&amp;colorscheme=light&amp;height=20';
	document.getElementById('vidlike').src = likestr;
	var flashvars = {};
		flashvars.rel=0;
		flashvars.hd=1;
		flashvars.fs=1;		
		flashvars.egm=0;
		flashvars.showsearch=0;
		flashvars.showinfo=0;
		flashvars.iv_load_policy=3;
		flashvars.cc_load_policy=0;
		flashvars.enablejsapi=1;
		flashvars.playerapiid='ytplayer';
	var params = {};
		params.allowScriptAccess = "always";
		params.allowFullScreen = "true";
	var attributes = {};
		attributes.id = "panel_media";
		attributes.align = "middle";
	swfobject.embedSWF(media_url, "panel_media", "720", "508", "9.0.0", "../flash/expressInstall.swf", flashvars, params, attributes);
}

// replaces a single character in a string by-position
// s=original string, c=new character, n=position (starting from 0)
function replaceChar(s,c,n){
	(s = s.split(''))[--n] = c;
	return s.join('');
};

// returns random number between minVal and MaxVal. Optional floatVal indicates decimal positions (integer if empty)
function randy(minVal, maxVal, floatVal){
	var randVal = minVal+(Math.random()*(maxVal-minVal));
	 return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}

///////////// STANDARD ADOBE FUNCTIONS ///////////////////////////////////////////////////
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
// -->
