// jquery.js.js - For jQuery scripting

$("document").ready(function(){ 
	var position_on_row=0;
	var tallest_height=0;
	var last_break=0;
	$("strong.us").css('font-weight','normal')
	$("#main .cnt").each(function(i){
		$("#main .cnt").eq(i).hasClass("two")?size_of_column=2:$("#main .cnt").eq(i).hasClass("three")?size_of_column=3:size_of_column=1;
		$("#main .cnt").eq(i).next().hasClass("two")?next_size_of_column=2:$("#main .cnt").eq(i).next().hasClass("three")?next_size_of_column=3:next_size_of_column=1;
		$("#main .cnt").eq(i).height()>tallest_height?tallest_height=$("#main .cnt").eq(i).height():null;
		position_on_row+=size_of_column
		if( position_on_row+next_size_of_column > 3){
			$("#main .cnt").eq(i).next().css("clear","left");
			position_on_row=0;
			tallest_height=0;
			last_break=i;
			}
		})
	$("#subm .hdr h2").wrapInner("<span></span>")
	if($("span.pull-out-text").length>0 && $("#main .cnt").eq(0).children(".opening-paragraph").length > 0){
		$("#cnt").addClass("has-pull-out-text");
		$("#main .cnt").eq(0).children(".opening-paragraph").eq(0).before('<div class="pull-out">'+$("span.pull-out-text").html()+'</div>');
		}
	use_front_animation=true
	zI=1000;
	if(use_front_animation){
		if($("#subm .hdr")){
			$("#subm .hdr").append('<ul class="index"></ul>')
			$("#subm .hdr .pane").each(function(n){
				$("#subm .hdr .index").append('<li>'+n+'</li>');
				})
			l=$("#subm .hdr .index li:first").addClass("active-marker");
			$("#subm .hdr .index li").css("width",(100/$("#subm .hdr .index li").length)+"%");
			$("#subm .hdr .index li").mouseover(function(){ 
				$(this).addClass("current");
				});
			$("#subm .hdr .index li").mouseout(function(){
				$(this).removeClass("current");
				});
			$("#subm .hdr .index li").click(function(){
				$("#subm .hdr").css("height",$("#subm .hdr").css("height"))
				clearTimeout(move_nF);
				fx=4;
				if(!fx){
					$("#subm .hdr .pane").hide().eq($("#subm .hdr .index li").index($(this))).show();
					}
				if(fx==1){
					indexIs=$("#subm .hdr .index li").index($(this))
					$("#subm .hdr").find("blockquote,p").hide()
					$("#subm .hdr .active-pane").slideUp("slow",function(){
						$(this).removeClass("active-pane");
						$("#subm .hdr .pane").eq(indexIs).slideDown("slow",function(){
							$("#subm .hdr .pane").eq(indexIs).find("blockquote,p").show();
							}).addClass("active-pane");
						})
					}
				if(fx==2){
					indexWas=$("#subm .hdr .index li").index($("#subm .hdr .index li.active-marker"));
					indexIs=$("#subm .hdr .index li").index($(this));
					$("#subm .hdr .active-pane").animate({ left: indexIs<indexWas?900:"-900px" },1500,function(){
						$(this).removeClass("active-pane");
						$("#subm .hdr .pane").eq(indexIs).css("left",indexIs<indexWas?"-900px":900).animate({left: 0},1500).addClass("active-pane");
						});
					}
				if(fx==3){
					// Goodfellas
					indexWas=$("#subm .hdr .index li").index($("#subm .hdr .index li.active-marker"));
					indexIs=$("#subm .hdr .index li").index($(this));
					$("#subm .hdr .active-pane").animate({ left: indexIs<indexWas?900:"-900px" },1,function(){
						$(this).removeClass("active-pane");
						$("#subm .hdr .pane").eq(indexIs).addClass("moving").css("left",indexIs<indexWas?"-900px":900).animate({left: indexIs<indexWas?900:"-900px"},500,function(){
							$(this).removeClass("moving").css("left","0");
							});
						$("#subm .hdr .pane").eq(indexIs).addClass("active-pane");
						});
					}
				if(fx==4){
					$("#subm .hdr").css("height","305px").css("width","900px");
//					$("#subm .hdr .pane").css("height","275px").css("width","900px").css("position","absolute");
//					$("#subm .hdr .index").css("margin-top","275px");
					indexIs=$("#subm .hdr .index li").index($(this))
					$("#subm .hdr").find("blockquote,p").hide()
					h=$("#subm .hdr .active-pane").height();
					$("#subm .hdr .pane").eq(indexIs).css("height","1px").addClass("over-pane").css("z-index",zI).animate({height: h},750,function(){
						zI++
						$("#subm .hdr .active-pane").removeClass("active-pane");
						$(this).addClass("active-pane").removeClass("over-pane");
						$(this).find("blockquote,p").show();
						})
					}
				$("#subm .hdr .index li.active-marker").removeClass("active-marker")
				$(this).addClass("active-marker");
				});
			function do_move_nF(){
				move_nF = setTimeout(function(){
					if($("#subm .hdr .index li.active-marker").nextAll("li").length!=0){
						$("#subm .hdr .index li.active-marker").nextAll("li").eq(0).click();
						}
					else{
						$("#subm .hdr .index li").eq(0).click();
						}
					do_move_nF();
					},9000);
				}
			do_move_nF()
			}
		}

	if(document.getElementById){
		if(document.getElementById("map")){
			if(GBrowserIsCompatible()){
				var map = new GMap2(document.getElementById("map"));
				map.setCenter(new GLatLng(53.79694618443293,-1.5520977973937988), 16);
				var mapControl = new GMapTypeControl();
				map.addControl(mapControl);
				map.addControl(new GSmallMapControl());
				$("body").unload(function(){ 
					GUnload()
					});
				};
			};
		};
	});