function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
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 getElement(id)
{
	return MM_findObj(id, null);
}
 

function setStatus(statusText) {
    if (parent.window){
	   if (parent.window.status ){
          parent.window.status = statusText;
	   }
	}
	return true;
} 
 
var alreadySubmitted = false;
function submitQuestion(n)
{ 
  if ( ! alreadySubmitted )
  {
  	 alreadySubmitted = true;	
     document.forms["question"].user_response_no.value=n;
     document.forms["question"].do_what.value="answer-question";
     document.forms["question"].submit();
  }
}
 
function keepCurrentCategory()
{ 
  document.forms["question"].do_what.value="keep-current-category";
  document.forms["question"].submit();
}
 
function slowDown()
{ 
  document.forms["question"].do_what.value="slow-down";
  document.forms["question"].submit();
}
 
function changeCategory(category_key)
{ 
  document.forms["question"].category_key.value=category_key;
  document.forms["question"].do_what.value="change-category";
  document.forms["question"].submit();
}
 
  
function incrementLevel()
{ 
  document.forms["question"].do_what.value="increment-level-step";
  document.forms["question"].submit();
}

function decrementLevel()
{ 
  document.forms["question"].do_what.value="decrement-level-step";
  document.forms["question"].submit();
}
 
function setUserProfile(frm)
{ 
    var radioCollection, checkedButton;
    if(frm){
	    radioCollection = frm.elements["field"];
	    if(radioCollection){
	    	 
	        //if(typeof radioCollection.length != "number"){
	        // radioCollection = [radioCollection]; // Convert to array
	        //}
	        for(var c = 0;c < radioCollection.length;c++){
	        	if(radioCollection[c].checked){
	                checkedButton = radioCollection[c];
	                break;
	            }
	        }
	        if(checkedButton) {
				frm.profile_key.value=checkedButton.value;
  		        return 1;
	        }
	    }   
    }  
    frm.profile_key.value="NOT-PROVIDED";  		        
	return 1;  
}

	function resizeIMG(){
			var objImg = $("#q-picture-b");
			var objImgsmall = $("#q-picture-s");
			var img_w = objImg.width();
			var img_h = objImg.height();
			var w=parseInt(img_w);
			var h=parseInt(img_h);
			
			$("#q-pic-enlarge").width(img_w);
			$("#q-pic-enlarge").height(img_h);
			$("#q-pic-enlarge").css("left",899-w);
			
			if (w/h>247/165&&w>247) objImgsmall.width(247);
			if (w/h<247/165&&h>165) objImgsmall.height(165);
			$("#q-pic").show();
			
		}
		
		function resizeSyringe() {
			$("#syringe").width(22*$("#syringe li").length);
			$("#syringe").show();
		}
		
		function resizeVials() {
			$("#vials").width(22*$("#vials li").length);
			$("#vials").show();		 
			$("#vials2").width(22*$("#vials2 li").length);
			$("#vials2").show();		 
		}
		
		$(document).ready(function(){
			//resizeIMG();
			resizeSyringe();
		    resizeVials();
				
			$("#pagemain_left").height($("#pagemain_right").height());
			$("#show-how-play").height($("#pagemain_right").height());
			$("#for").css("margin-top",$("#show-how-play").height()-458+150);
			
			$("#logo").ifixpng();
			$("#syringe img").ifixpng();
			$("#vials img").ifixpng();
			$("#vials2 img").ifixpng();
			
			$("#frame-bottom a").bind("click", function(){
				$("#frame-bottom").css("background","url('/assets/images/frame-bottom-2.gif')")
				$("#show-how-play").show();
			})
			
			$("#show-how-play").bind("mouseleave", function(){
				$("#frame-bottom").css("background","url('/assets/images/frame-bottom.gif')")
				$("#show-how-play").hide();
			})
			
			/*
			$("#q-picture-s").bind("click", function(){
				$("#q-pic-enlarge").css("visibility","visible");
			})
			
			$("#q-picture-b").bind("mouseleave", function(){
				$("#q-pic-enlarge").css("visibility","hidden");
			})
			
			$("#q-picture-b").bind("click", function(){
				$("#q-pic-enlarge").css("visibility","hidden");
			})
			*/
			
			$("a.arrow").bind("mouseenter", function(){
				$("#Categories-menu").show();
			})
			
			$("#Categories-menu").bind("mouseleave", function(){
				$("#Categories-menu").hide();
			})
		});
		
 
