
	//jQuery(".scontent.active").height(jQuery(".scontent.active").parent().height());
	jQuery(".scontent.active").parent().height(jQuery(".scontent.active").height());

	/* 
	var images = jQuery(".maincontent.active .subhead .subimages .title .rotatedtext");
	for(var i=0; i<images.length; i++){
		jQuery(images[i]).height(jQuery(images[i]).parent().width());
	} */

	jQuery(document).ready( //for chrome, otherwise width hasnt been set properly
		function(){
			setTimeout(function(){ //needs to be run when new stuff is made

				images = jQuery(".maincontent.active .subhead .subimages .title .rotatedtext");
				for(var i=0; i<images.length; i++){
					jQuery(images[i]).height(jQuery(images[i]).parent().width());
					jQuery(images[i]).parent().css("display", "block");

					
					
				}
			},100)


			//test for chome rotate
			//jQuery('.maincontent.active .subhead .subimages.active.level1 > a > .title > div.rotatedtext').animate({rotate: '+=10deg'}, 4000);

			//console.log(jQuery.browser );
			
			//webkit doesnt like overriding the css with transforms
			


			
			/*
			if(jQuery.browser.webkit ){//if webkit, rotate
				//console.log(jQuery('.maincontent .subhead .subimages > a > .title > div.rotatedtext').rotate()==0);
				jQuery('.maincontent .subhead .subimages > a > .title > div.rotatedtext').rotate('90deg');
			}
			*/
			//jQuery('.maincontent .subhead .subimages > a > .title > div.rotatedtext').css(rotate,"+=90deg");
			
		}
	)
	
	
	
	
	function ajaxsubmenuopen2(id,this1){
		jQuery(".maincontent.active").parent().animate({height:700},300);
	}

	var leftright=0;
	var expand=false; // depreciated
	function ajaxsubmenuopen(id,this1){

		
		leftright=0;

		//is it allready active? then bring in the submenus.
		if(jQuery(this1).parent().hasClass("active")){


			var toopen = jQuery('.subimages'+id+".active .subimages:first");
			
			if(toopen.length>0){
				var thea = jQuery('> a', toopen);//the a for opening the next menu

				var id = toopen.attr("class").match(/subimages[0-9]+/);
				id=id[0].match(/[0-9]+/);
				id=id[0];
				
				ajaxsubmenuopen(id, thea[0]);

				return;
			}
			
			expand=true;
		}else{
			expand=false;
		}
		
		
		var tomove=jQuery(".maincontent.active .subhead > .subimages");
		var found=false;
		var width = jQuery(".maincontent.active .subhead").width();
		

		var found=new Array();//aray of jquery dom objects which are found
		found[0] = jQuery(".maincontent.active .subhead .subimages"+id);
		while(true){
			if(found[(found.length-1)].parent().hasClass("subimages")){
				found[found.length]=found[(found.length-1)].parent();
			}else{break;}
		}
		ajaxsubmenuopenloop(tomove,0,1,found,width);

		var temp;
		if(this1!=null){
			temp = this1.href
		}else{
			temp=null
		}
		ajaxsubmenuopencontent(id,temp);
                
                
                
                
                

	}

	function ajaxsubmenuopenloop(tomove,level,no,found,width){

		if(tomove.length==0) return;
		
		var foundb=false;
		var activeb=false;
		
		for(var i=0; i<tomove.length; i++){
			if(inArray(jQuery(tomove[i]), found)){
				foundb=true;
				activeb=true;
				
				//its found, do stuff, animation, etc
				if(level==0){
					var color="#349957";

/*
					console.log("animate color");
					console.log(jQuery(".maincontent.active .subhead .subimages.active.level0 > a > .title"));
*/

					//since only the top level is active at any one time
					var ele;
					if(jQuery(".maincontent.active .subhead .subimages.active.level0 > a > .title").length > 0){
						ele = jQuery(".maincontent.active .subhead .subimages.active.level0"); 
					}else{
						ele = jQuery(".maincontent.active .subhead .subimages.active.level1").parent();
					}

					//console.log(ele);
					
					jQuery("> a > .title", ele).animate({color: color }, duration);//chagen to green
					jQuery("> a > .title .arrows .arrowr", ele).animate({borderRightColor:color}, duration);
					jQuery("> a > .title .arrows .arrowl",ele).animate({borderLeftColor:color}, duration);
					
				}else if(level==1){

				}


				
				//console.log(jQuery("div.rotatedtext"));
				//not in if, since, this only gets called once	
				//jQuery(".maincontent.active .subhead .subimages.active.level1 > a > .title > div.rotatedtext").animate({rotate:"90deg" , top:0, color:"#bebebe" }, duration);

				
				jQuery(".maincontent.active .subhead .subimages.active.level1 > a > .title > div.rotatedtext").animate({color: "#bebebe"},duration);
				jQuery(".maincontent.active .subhead .subimages.active.level1 > a > .title > div.rotatedtext").css("font-weight", "normal");

				

				
				//switch the active div. dmn, removes them all
				jQuery(".maincontent.active .subhead .subimages.active").removeClass("active");
				jQuery(tomove[i]).addClass("active");

				
				if(level==0){
					
					//var tele = jQuery(".maincontent.active .subhead .subimages.active.level0 > a > .title").css("color", "red");
					//tele.clearQueue();
					//tele.animate({top:50}, 2000);
					
					var color="#ffffff";

					jQuery(".maincontent.active .subhead .subimages.active.level0 > a > .title").clearQueue();
					jQuery(".maincontent.active .subhead .subimages.active.level0 > a > .title").animate({color: color }, duration);//chagen to white
					jQuery(".maincontent.active .subhead .subimages.active.level0 > a > .title .arrows .arrowr").clearQueue();
					jQuery(".maincontent.active .subhead .subimages.active.level0 > a > .title .arrows .arrowr").animate({borderRightColor:color}, duration);
					jQuery(".maincontent.active .subhead .subimages.active.level0 > a > .title .arrows .arrowl").clearQueue();
					jQuery(".maincontent.active .subhead .subimages.active.level0 > a > .title .arrows .arrowl").animate({borderLeftColor:color}, duration);
					
				}else if(level==1){


						 
						jQuery(".maincontent.active .subhead .subimages.active.level1 > a > .title > div.rotatedtext").animate({color: "#ffffff"},duration);
						jQuery(".maincontent.active .subhead .subimages.active.level1 > a > .title > div.rotatedtext").css("font-weight", "bold");
						
						 
				}
				
			}
			//needs to happen before leftright is calculated (which direction to slide the content in)
			ajaxsubmenuopenloop( jQuery(tomove[i]).children("div.subimages"),level+1,tomove.length,found,width)
			
			if(foundb==false){//go left

				var left=0;

				//get the parent id
				if(jQuery(tomove[i]).parent().hasClass("subimages")){
					
					var id = jQuery(tomove[i]).parent().attr("class").match(/subimages[0-9]+/);
					id=id[0].match(/[0-9]+/);
					id=id[0];


					
					if(found[1]!=undefined){
						var fid=found[1].attr("class").match(/subimages[0-9]+/);
						fid=fid[0].match(/[0-9]+/);
						fid=fid[0];
					}else{
						fid = 0;
					}

					
					
					if(activeb==false && id!=fid /* && expand==false */){
						//left = -(distance*(i+no)-width);
						left = -width;
					}else{
						left = (distance*(i+no)-width);
					}
				}else{
					left = (distance*(i+no)-width);
				}
				
				//var left = (distance*(i+no)-width);

				
				jQuery(tomove[i]).animate({left:left}, duration, "linear");
			}else{//go right;

				if(leftright==0 && -(distance*(tomove.length-i-1+level)) ==  jQuery(tomove[i]).position().left){//move left
					leftright=1;
				}else if(leftright == 0 ){
					leftright=2;
				}
				
				jQuery(tomove[i]).animate({left:-(distance*(tomove.length-i-1 + level))}, duration, "linear");
			}

			//console.log("set false");
			activeb=false;
			//do t/ same for the next lvl
			
		}
	}

	function inArray(needle, haystack){
		for(var i=0; i<haystack.length; i++){
			if(haystack[i].attr("class") == needle.attr("class")){
				return true;
			}
		}
		return false;
	} 
	
	
	var leftright=0;
	function ajaxsubmenuopen2(id, this1){

		
		var tomove=jQuery(".maincontent.active .subhead .subimages");
		var found=false;
		var width = jQuery(".maincontent.active .subhead").width();


		var offset=0;
		
		leftright=0;
		for(var i=0; i<tomove.length; i++){
			if(jQuery(tomove[i]).hasClass("subimages"+id)){
				found=true;

				//add action lister to the old tab, so that it will change correctly
				var tmpnum = jQuery(".maincontent.active .subhead .subimages.active").attr("class").match(/[0-9]+/);
				var tmpa = jQuery(".maincontent.active .subhead .subimages.active").parent()[0];
				jQuery(".maincontent.active .subhead .subimages.active").parent().click(function(){
				ajaxsubmenuopen(tmpnum, tmpa);
				return false;}
				);


				jQuery(".maincontent.active .subhead .subimages.active .title").animate({color: "#349957" }, duration);

				jQuery(".maincontent.active .subhead .subimages.active .title .arrows .arrowr").animate({borderRightColor:"#349957"}, duration);
				jQuery(".maincontent.active .subhead .subimages.active .title .arrows .arrowl").animate({borderLeftColor:"#349957"}, duration);
				
				jQuery(".maincontent.active .subhead .subimages.active").removeClass("active");
				jQuery(tomove[i]).addClass("active");

				//remove action lister, for active, 
				jQuery(tomove[i]).parent().attr("onclick","");
				jQuery(tomove[i]).parent().unbind('click');
				jQuery(tomove[i]).parent().click(
					function(){return false;}
						)

				jQuery(".title",tomove[i]).animate({color:"#ffffff"}, duration);
				jQuery(".title .arrows .arrowr",tomove[i]).animate({borderRightColor:"#ffffff"}, duration);
				jQuery(".title .arrows .arrowl",tomove[i]).animate({borderLeftColor:"#ffffff"}, duration);
				
				
			}
			if(found==false){

				if(jQuery(tomove[i]).hasClass("sub")){
					offset+=1;
					
				}
				
				jQuery(tomove[i]).animate({left:(distance*(i+1)-width)}, duration);
				
			}else{ //move to the right

				
				if(leftright==0 && -(distance*(tomove.length-i-1)) ==  jQuery(tomove[i]).position().left){//move left
					leftright=1;
				}else if(leftright == 0 ){
					leftright=2;
				}

				
				jQuery(tomove[i]).animate({left:-(distance*(tomove.length-i-1))}, duration);
			}
		}
		
		
		var temp;
		if(this1!=null){
			temp = this1.href
		}else{
			temp=null
		}
			
		ajaxsubmenuopencontent(id,temp);
	}
	
	function ajaxsubmenuopencontent(id, href){
		//check if content exists
		
		//jQuery(".scontent.active").fadeOut(duration/2);
		//jQuery(".scontent.active").removeClass("active");//not active any more
		
		if(jQuery('.scontent'+id+".active").length>0){

			//needs to load in the overview
			
			return;//the content is allready open, so return.
		}
		
		var start = new Date().getTime();

		//needs doing
		
		if(href){//if href in null, then back button was pressed, dont track it
			url=addoption(href,"ajax=2")//submenu
			
			var pageTracker = _gat._getTracker("UA-1463358-2");
			pageTracker._trackPageview();
			
			pageTracker._trackPageview(url);
		} 
		
		if(jQuery(".scontent" + id).length>0){//it exists, so dont load it in


			
			var tempduration = duration;
			/* if(leftright==1){
				//jQuery(".scontent.active").fadeOut(duration/2);
				jQuery(".scontent.active").animate({left:-jQuery(".scontent.active").width()},tempduration)
			}else if(leftright==2){
				jQuery(".scontent.active").animate({left:jQuery(".scontent.active").width()},tempduration)
			}*/

			jQuery(".scontent.active").fadeOut(tempduration);
			
			
			jQuery(".scontent.active").removeClass("active");
			
			jQuery(".submenucontent .scontent"+id).addClass("active");
			//jQuery(".submenucontent .scontent.active").delay(duration/2);
			//jQuery(".submenucontent .scontent.active").fadeIn(duration/2);
			
			jQuery(".submenucontent .scontent"+id).css("display","block");
			jQuery(".scontent.active").css("left", jQuery(".scontent.active").width()+"px");//move it off to the left, so it doesnt flicker

			//only animate one
			jQuery(".scontent.active").parent().height(jQuery(".scontent.active").height());//height calculation
			jQuery(".maincontent.active").parent().animate({height:jQuery(".maincontent.active").height()},duration);

			ignorehash[ignorehash.length]=jQuery("#innercontent .maincontent.active .scontent.active .namehash").html();
			window.location.hash = jQuery("#innercontent .maincontent.active .scontent.active .namehash").html();
			hash[jQuery("#innercontent .maincontent.active .scontent.active .namehash").html()]=id;//hash to id

			jQuery(".scontent.active").css("display","none");
			jQuery(".scontent.active").css("left", 0);//move it back to center;
			/*
			if(leftright==1){
				jQuery(".scontent.active").css("left", jQuery(".scontent.active").width()+"px");
				jQuery(".scontent.active").animate({left:0},tempduration);
			}else if(leftright==2){
				jQuery(".scontent.active").css("left", "-"+jQuery(".scontent.active").width()+"px");
				jQuery(".scontent.active").animate({left:0},tempduration);
			}
			*/
			//setTimeout(function(){
				jQuery(".scontent.active").fadeIn(tempduration);
			//}, tempduration)
                        
                        Cufon.refresh();
			
			
		}else{//load it in

			/*
			//moved befor if
			url=addoption(href,"ajax=2")//submenu
			pageTracker._trackPageview(url);
			*/

			jQuery(".scontent.active").fadeOut(tempduration);
			
			jQuery.ajax({
				  url: url,
				  success: function(data) {
					//old think
					
					var now=new Date().getTime();
					var tempduration = duration-(now-start);
				    if(tempduration>200){
				    }else{
				    	tempduration=500;
				    }

					/*
					if(leftright==1){
						//jQuery(".scontent.active").fadeOut(duration/2);
						jQuery(".scontent.active").animate({left:-jQuery(".scontent.active").width()},tempduration)
					}else if(leftright==2){
						jQuery(".scontent.active").animate({left:jQuery(".scontent.active").width()},tempduration)
					}*/

					
					jQuery(".scontent.active").removeClass("active");
					
					//create the div for the content to go in
					jQuery(".maincontent.active .submenucontent").append("<div class='scontent scontent"+id+"' style='position:absolute; display:none;'></div>")
					
					  //put the data in the newly created absolute div;
					jQuery(".maincontent.active .submenucontent .scontent"+id).css("display","block");
					jQuery(".maincontent.active .submenucontent .scontent"+id).addClass("active");
				    jQuery(".maincontent.active .submenucontent .scontent"+id).html(data);

					//resize

					//only animate one of them, or it wont work.
					
					jQuery(".scontent.active").parent().height(jQuery(".scontent.active").height());
					jQuery(".maincontent.active").parent().animate({height:jQuery(".maincontent.active").height()},duration);
					
					
					//eo resize
				    jQuery(".maincontent.active .submenucontent .scontent"+id).css("display","none");
	
				    

					ignorehash[ignorehash.length]=jQuery("#innercontent .maincontent.active .scontent.active .namehash").html();
					window.location.hash = jQuery("#innercontent .maincontent.active .scontent.active .namehash").html();
					hash[jQuery("#innercontent .maincontent.active .scontent.active .namehash").html()]=id;//hash to id

					//jQuery(".scontent.active").css("display","block");
					/*
					if(leftright==1){
						jQuery(".scontent.active").css("left", jQuery(".scontent.active").width()+"px");
						jQuery(".scontent.active").animate({left:0},tempduration);
					}else if(leftright==2){
						jQuery(".scontent.active").css("left", "-"+jQuery(".scontent.active").width()+"px");
						jQuery(".scontent.active").animate({left:0},tempduration);
					}
					*/
					jQuery(".scontent.active").fadeIn(tempduration);
					Cufon.refresh();
					/* 
				    if(now-start<(duration/2)){//all things are fine, que it up
				    	jQuery(".scontent.active").delay(duration/2-(now-start));
				    	jQuery(".scontent.active").fadeIn(duration/2);
				    }else if(now-start<(duration-200)){ //fade in faster
				    	jQuery(".scontent.active").fadeIn(duration-(now-start));
				    }else{//missed it, fade in normaly
				    	jQuery(".scontent.active").fadeIn(duration/2);
				    }
				    */
                                   
                                   
				    
				  }
				});
			
		}
		
	}
	
	function addoption(url, option){

		if(!url)return null; //if url is null, its not needed, so just rutern null
		
		if(url.match(/\?/)){
			url=url+"&"+ option;
		}else{
			url=url+"?"+option;
		}
		return url;
	}


	
	function autoload(){


		var this1 = jQuery(".subhead .subimages")
		
		for(i=0; i<this1.length; i++){

			var href = jQuery("> a", this1[i]).attr("href");

			//console.log(jQuery(this1[0]));
			//console.log(href);
			
			//find the id
			var id = jQuery(this1[i]).attr("class").match(/subimages[0-9]+/);
			id=id[0].match(/[0-9]+/);
			id=id[0];

			//console.log("id = " + id);

			//console.log("-001 = " + id);
			autoload2(id, href, i*1000);
			
		}
		
		
	}

	function autoload2(id, href, timeout){

		//console.log("000 = " +id);
		
		setTimeout(function(){

			//console.log("001 = " + id);
			
			url=addoption(href,"ajax=2")//submenu
			
					
			if(jQuery(".scontent" + id).length>0){//it exists, so dont load it in
	
			}else{
				//console.log("002");
	
				jQuery.ajax({
					  url: url,
					  success: function(data) {
	
						
						//jQuery(".scontent.active").removeClass("active");
						
						//create the div for the content to go in
						jQuery(".maincontent.active .submenucontent").append("<div class='scontent scontent"+id+"' style='position:absolute; display:none;'></div>")
						
						  //put the data in the newly created absolute div;
						jQuery(".maincontent.active .submenucontent .scontent"+id).css("display","block");
						//jQuery(".maincontent.active .submenucontent .scontent"+id).addClass("active");
					    jQuery(".maincontent.active .submenucontent .scontent"+id).html(data);
	
						//resize
	
						//only animate one of them, or it wont work.
						
						//jQuery(".scontent.active").parent().height(jQuery(".scontent.active").height());
						//jQuery(".maincontent.active").parent().animate({height:jQuery(".maincontent.active").height()},duration);
						
						
						//eo resize
					    jQuery(".maincontent.active .submenucontent .scontent"+id).css("display","none");
		
					    
						//ignorehash[ignorehash.length]=jQuery("#innercontent .maincontent.active .scontent.active .namehash").html();
						//window.location.hash = jQuery("#innercontent .maincontent.active .scontent.active .namehash").html();
						hash[jQuery("#innercontent .maincontent.active .scontent"+id+" .namehash").html()]=id;//hash to id
                                                Cufon.refresh();
						
				}});
			}

		},timeout);
	}
	
	autoload();
