/* Handle jquery Requests for map roll over */

/*<![CDATA[*/
var $JS = jQuery.noConflict();
var g_big_width = "46px";
var g_big_height = "495px";
					
var g_diff = 2;
var g_difftop = 0;
					
var g_small_width = "36px";
var g_small_height = "388px";
var g_left_row = "-23px";
var g_zoom_up_speed = "200";
var g_zoom_down_speed = "100";
var g_opt_=3;

/* When all is ready */
$JS(document).ready(function() {
				

/* crossSlide http://www.gruppo4.com/~tobia/cross-slide.shtml */
/* Check if crossSlide container DIV is on page */
if ( $JS('#FAslideshow').length != 0 ){
	$JS('#FAslideshow').crossSlide({
	  fade: 3
	}, [
	   { src: 'http://www.topolskicentury.org.uk/wp-content/uploads/2009/11/Feliks-painting-at-Memoir-slide-l.jpg',
	     from: 'bottom right 1.0x',
	    to:   'top left 1.0x',
	    time: 8
	  },
	  { src: 'http://www.topolskicentury.org.uk/wp-content/uploads/2010/01/topolski-entrance.jpg',
	     from: '0% 0%',
	    to:   '60% 80% 1.0x',
	    time: 16
	  },
	   { src: 'http://www.topolskicentury.org.uk/wp-content/uploads/2010/01/Memoir-interior-1.jpg',
	     from: '100% 80%',
	    to:   '0% 0%',
	    time: 16
	  },
	   { src: 'http://www.topolskicentury.org.uk/wp-content/uploads/2010/01/Black-Panthers1.jpg',
	     from: 'center right 1.3x',
	    to:   'top left 0.7x',
	    time: 16
	  },
	  { src: 'http://www.topolskicentury.org.uk/wp-content/themes/topolski 2/images/abg.jpg',
	     from: 'top right 0.25x',
	    to:   'center center 1x',
	    time: 8
	  }
	  
	  	]);
}




				
			/* test single */

				/* position blobs */
/*		       $JS(".mapblobnew").each(function (i) {
					thisVals = $JS(this).next().html();
					var valsArray = thisVals.split(",");


						$JS(this).prepend('<img style="top: 0px; left: 50px;" src="http://www.fetherstonhaugh.com/script/topolski_web_assets/store/wp/wp-content/themes/topolski/images/number-1.png"/>');
					
		       });


			$JS(".mapblobnew img").hover(function () {
		           $JS(this).stop();
						
				r_new_left = parseFloat($JS(this).css("left"),10) - g_diff + "px";
				r_new_top = parseFloat($JS(this).css("top"),10) - g_difftop + "px";
						//alert(r_new_top);
			    $JS(this).stop().animate({width: "20px", height: "20px", left: r_new_left, top: r_new_top}, 200);
      			}, function () {
		           $JS(this).stop();
				
				r_new_left = parseFloat($JS(this).css("left"),10) + g_diff + "px";
				r_new_top = parseFloat($JS(this).css("top"),10) + g_difftop + "px";
				r_new_left = 50 + "px";
				//r_new_top = 0 + "px";
			    $JS(this).stop().animate({width: "16px", height: "16px", left: r_new_left, top: r_new_top}, 200);
				
			});
				
*/
				/* position blobs */
		       $JS(".mapblob").each(function (i) {
					thisVals = $JS(this).next().html();
					var valsArray = thisVals.split(",");

		        	$JS(this).css("opacity","0");
		        	$JS(this).css("display","block");

					theObj = this;
					theTab = $JS(this).attr("id"); blobIDStr = theTab.replace("menu_tab_","");  
					theTabVal = blobIDStr.replace("map_blob_",""); 
					theObj = $JS('#map_blob_'+theTabVal); 

/* Gifs seem smoother in IE */
					if ( $JS("#menu_tab_"+ theTabVal).is('.selected')	){	
						$JS(this).prepend('<div class="map_blob_img" ><img style="top: '+valsArray[3]+'px; left: -23px;" src="http://www.topolskicentury.org.uk/wp-content/themes/topolski/images/all-the-numbers.gif" /></div>');
						$JS(".map_blob_img img",theObj).css("width", g_big_width);
						$JS(".map_blob_img img",theObj).css("height", g_big_height);
						$JS(".map_blob_img img",theObj).css("top", valsArray[3]+'px');
						
						
						$JS(".map_blob_img",theObj).css("width", '22px');
						$JS(".map_blob_img",theObj).css("height", '22px');
						
						r_new_left = parseFloat(valsArray[0],10) - g_diff + "px";
						r_new_top = parseFloat(valsArray[1],10) - g_difftop + "px";
						$JS(this).css("left",r_new_left);
						$JS(this).css("top",r_new_top);
						
											
						
					}
			        else{
						$JS(this).prepend('<div class="map_blob_img" ><img style="top: '+valsArray[2]+'px; left: 2px;" src="http://www.topolskicentury.org.uk/wp-content/themes/topolski/images/all-the-numbers.gif"/></div>');
						$JS(this).css("left",valsArray[0] + "px");
						$JS(this).css("top",valsArray[1] + "px");
						
			        }
			        
		        	
		    //$JS(this).animate({opacity: 1}, 800, "swing");
		      });

//$JS(".mapblob").fadeIn("2000");
		
		    $JS(".mapblob").animate({"opacity": "1"}, 20, "swing");
			
			$JS(".mapblob, #map_tab li").hover(function () {
					/* Over */
		          //stops the event from happening in case of an abrupt mouseOut.  Removed as each and hover conflict
		           //$JS(this).stop();
		           
					theTab = $JS(this).attr("id"); 
					blobIDStr = theTab.replace("menu_tab_","");  
					theTabVal = blobIDStr.replace("map_blob_",""); 
					theObj = $JS('#map_blob_'+theTabVal); 
				
					r_leftPos = $JS(theObj).css("left");
					r_topPos = $JS(theObj).css("top");
					

					//alert($JS("#menu_tab_"+ theTabVal));
					//Only expand if we are at base padding
					if ( (! $JS("#menu_tab_"+ theTabVal).is('.selected') )  )
					{
					

						r_new_left = parseFloat(r_leftPos,10) - g_diff + "px";
						r_new_top = parseFloat(r_topPos,10) - g_difftop + "px";
	
						thisVals = $JS(theObj).next().html();
						var valsArray = thisVals.split(",");
	
				

					
			        	if (g_opt_ == 1)
			        	{$JS(".map_blob_img img",theObj).animate({width: g_big_width, height: g_big_height, top: valsArray[3]+'px', left:"0px"}, g_zoom_up_speed,"swing");}
			        	else if (g_opt_ == 2){
			        	$JS(".map_blob_img img",theObj).animate({width: g_big_width, height: g_big_height, top: valsArray[3]+'px'}, g_zoom_up_speed,"swing");
			        	}

			        	//$JS(".map_blob_img img",theObj).animate({width: g_big_width, height: g_big_height, top: valsArray[3]+'px'}, g_zoom_up_speed,"swing");
			            //$JS(".map_blob_img",theObj).animate({width: '22px', height: '22px'}, g_zoom_up_speed,"swing");
			        	//$JS(theObj).animate({left: r_new_left, top: r_new_top}, g_zoom_up_speed,"swing");

						/*Option 3*/
						else if (g_opt_ == 3){
						//$JS(".map_blob_img img",theObj).fadeOut("0");			        	
		        	    //$JS(".map_blob_img img",theObj).css("opacity","0.5");
		        	    
			        	$JS(".map_blob_img img",theObj).css({"width":g_big_width,"height":g_big_height,"top":valsArray[3]+"px","left":"0px"});
						//$JS(".map_blob_img img",theObj).fadeIn("50");
			        	//$JS(".map_blob_img img",theObj).animate({"opacity":"1", "width":g_big_width,"height":g_big_height,"top":valsArray[3]+"px","left":"0px"}, g_zoom_up_speed,"swing");
						}				        	
			        	
			        	//alert("#menu_tab_"+ theTabVal);
			        	$JS("#menu_tab_"+ theTabVal).addClass('selected');
					}
					else{
						

					}
       			}, function () {
	 				/* Out */

          //stops the event from happening in case of an abrupt mouseOut
            		$JS(this).stop();

	 				theTab = $JS(this).attr("id"); 
	 				blobIDStr = theTab.replace("menu_tab_","");  
					theTabVal = blobIDStr.replace("map_blob_",""); 
					theObj = $JS('#map_blob_'+theTabVal); 


		 			 if ($JS(".map_blob_img img",theObj).css('left') == g_left_row ){
		 			 	}
	 			     else{
						thisVals = $JS(theObj).next().html();
						var valsArray = thisVals.split(",");
						
						//r_padding = "2px";
						r_new_left = valsArray[0] + "px";
						r_new_top = valsArray[1] + "px";
						r_new_img_top =  valsArray[2] + "px";
						
						
						
			        	if (g_opt_ == 1){
						
						$JS(".map_blob_img img",theObj).animate({width: g_small_width,height: g_small_height, top: r_new_img_top, left: "2px"}, g_zoom_down_speed);
			        	}
			        	else if (g_opt_ == 2){

						$JS(".map_blob_img img",theObj).animate({width: g_small_width,height: g_small_height, top: r_new_img_top}, g_zoom_down_speed);
			        	}
			        	else if (g_opt_ == 3){

						
						//$JS(".map_blob_img img",theObj).animate({width: g_small_width,height: g_small_height, top: r_new_img_top}, g_zoom_down_speed);
						//$JS(".map_blob_img",theObj).animate({width: '16px', height: '16px'}, g_zoom_down_speed);
						//$JS(theObj).animate({left: r_new_left, top: r_new_top}, g_zoom_down_speed);
						
			        	$JS(".map_blob_img img",theObj).css({"width":g_small_width,"height":g_small_height,"top":r_new_img_top,"left":"2px"});
			        	}
			        	
						$JS("#menu_tab_"+ theTabVal).removeClass('selected');
						
					}
					
 
  				});



			/* click event */
			$JS(".mapblob").click(function () {
				/* stop(); */
				blobIDStr = $JS(this).attr("id");
				blobID = blobIDStr.replace("map_blob_","");
				
		        //document.location = $JS("#menu_tab_link_"+ blobID + " a").attr('href');
		        document.location = $JS("a#menu_tab_link_"+ blobID ).attr('href');
				
			});

	 
	});
/*]]>*/
