function iframeFullHeight (){
	   
	   $('iframe').each(function() {
		   
   		$(this).load(function(){
				this.style.height = $(this).contents().find('body').outerHeight(true) + 'px';
				$(this).css("overflow", "hidden");
				});
				$(this).css("overflow", "hidden");
				this.style.height = $(this).contents().find('body').outerHeight(true) + 'px';
				$(this).attr("rel", "resized");
			
		});


	   
   }


//returns the value of the URL parameter specified

function getParameterByName( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
///End URL parameter

////View port Dimentions
var fullHeight = 0;
var viewportwidth;
var viewportheight;



/***************************Checking for Doctype***************************************************

/******************************
Version info "object"
******************************/
function versionInfo()
{
this.xhtml="";
this.version="";
this.importance="";
}
function detectDoctype(){
var re=/\s+(X?HTML)\s+([\d\.]+)\s*([^\/]+)*\//gi;
var myversionInfo=new versionInfo();
/*********************************************
Just check for internet explorer.
**********************************************/
if(typeof document.namespaces != "undefined"){
if(document.all[0].nodeType==8)
re.exec(document.all[0].nodeValue);
else
return null;
}else{
if(document.doctype != null)
re.exec(document.doctype.publicId);
else
return null;
}
myversionInfo.xhtml=RegExp.$1;
myversionInfo.version=RegExp.$2;
myversionInfo.importance=RegExp.$3;
return myversionInfo;
}
var myversionInfo=detectDoctype();
if(myversionInfo != null){
//alert(myversionInfo.xhtml);
//alert(myversionInfo.version);
//alert(myversionInfo.importance);

// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
     // viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
    //   viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
     //  viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
      // viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }
}

////End Viewport Dimentions 
else{
//alert("There is no DOCTYPE in the code!");
}



/*************************End of checking for doctype ***********************************/



/**************************Banner Script*************************************************/
 var noBanner = 0;
 var s = getParameterByName("s");
 var r = getParameterByName("r");
 var p = getParameterByName("p");
 var d = getParameterByName("d");
 


		
  
	
var crodaLinkURL = "";



$(document).ready(function() {
	

	
	
	
	
						   
						   $('img.showAlt').each(function(){ 
														  var altText = $(this).attr('alt');
														  var align = $(this).attr('align');
							$(this).wrap('<div class="widgetRight"></div>');
															$(this).after('<p>'+altText+'</p>');	
															$(this).wrap('<p></p>');
																$(this).attr("style", "margin: auto;");
																});

							   
						
							
							
							
							$("#marketsMenu").accordion({
								collapsible: true,
								autoHeight: false,
								active: false,
								clearStyle: true
								});
							
							
						
							
							
							if( s== 1){//changes the color of the small menu box on the left
							
							$('.crodamenuhighlight1').prev().css("background-color", "#cccccc");
							$('.crodamenuhighlight1').prev().css("padding-left", "5px");
							
							}
							
							$('#standardMenu .content').hide();
							$('#standardMenu .link').click(function(){
										   $(this).siblings().slideToggle("fast");
										 	}
								);
							
							///make page Full height
							if (fullHeight == 1 ){
							$("TABLE#tableMainLayout").css("height", viewportheight-75);
							}
							
							//Fix the Iframe issue
							var contentHeight = $("#tableMainLayout td.layoutContent").height();
							
							
							if (contentHeight < 350){
							$("#tableMainLayout td.layoutContent").css("height", "350px");	
							contentHeight = 350;
							$('#tableMainLayout td.layoutContent iframe:not(".external")').css("height", contentHeight+"px");
							} else {
								
								
								
								
									$('#tableMainLayout td.layoutContent iframe:not(".external")').css("height", contentHeight+"px");
								
							}
							
							//End Iframe fix
							
							
							
							
							
							 $('#homePageGallery').crodaGallery({thumbPercentage: 10});
							 
							 $('#csrHomePage').crodaGallery({allowThumbs: 0});
							   
							   //To Make anything clickable add the class 'crodaLink' and the attribute 'go="location"'
							   $('.crodaLink').click(function(){
							   crodaLinkURL = $(this).attr("go");
							   if ($(this).attr("target") == "new") {
								   window.open(crodaLinkURL, "blank");
								   } else {
									   window.location = crodaLinkURL;
									   }
									   
									   
								
							   
							   
							   });
							   
							   $('.crodaLink').hover(
													  function(){
														$(this).addClass('crodaLinkHover');  
														
													  },
													  function () {
														  $(this).removeClass('crodaLinkHover');
														  
													  }
													  );
								//end Clickable


			 /* $('#3boxModel').css({"position" : "relative", "display" : "block"});
			  $('#3boxModel img').css({"cursor" : "pointer"})
			  var img1height = $('#3boxModel #img1').height();
			  $('#3boxModel').css({"height" : img1height+"px"});
			  $('#3boxModel #img1').css({"position" : "absolute", "left" :"0px"});
			  $('#3boxModel #img2').css({"position" : "absolute", "right" :"0px", "top" : "0px"});
			  var img3Pos = $('#3boxModel #img2').height() + 20;
			  $('#3boxModel #img3').css({"position" : "absolute", "right" :"0px", "top" : img3Pos+"px"});
			  
			  $('#3boxModel img').click(function(){
										loc = $(this).attr("go");
										window.location = loc;
										});
			  
			  var countDivs = $('#3boxModel div').size();
			  
			  if (countDivs == 3){
			  $('#3boxModel #img1').next().addClass("s"+s+"_image1div");
			  $('#3boxModel #img1').next().attr("id", "image1div_p"+p);
			  $('#3boxModel #img2').next().addClass("s"+s+"_image2div");
			  $('#3boxModel #img2').next().attr("id", "image2div_p"+p);
			  $('#3boxModel #img3').next().addClass("s"+s+"_image3div");
			  $('#3boxModel #img3').next().attr("id", "image3div_p"+p);
			  
			  }
				  */
				  
				  
		  //product Finder breadcrumb moves into standard breadcrumb position
/*if(s == 1 || s == 145 || s == 155 || s == 156 || s == 151 || s == 152 || s == 157 || s == 158 || s == 136 || s == 111 || s == 160 || s == 133 || s == 137 || s == 143 || s == 144 || s == 139 || s == 141 || s == 149 || s == 150 || s == 110 || s == 153  || s == 131 || s == 140  || s == 147 || s == 148 ){
	

			if ($('td.TBLglobal-breadcrumb span.breadCrumb').size() > 0){
				
				//alert($('td.TBLglobal-breadcrumb span.breadCrumb').html());
				$('div#breadCrumb span.breadCrumb').html($('td.TBLglobal-breadcrumb span.breadCrumb').html());
				
				$('div#breadCrumb div#printButton').html($('td.TBLglobal-breadcrumb img').parent().html());
				$('table.ProductBreadcrumb').remove();
				
			
			}
			
}*/

if(s == 1 || s == 145 || s == 155 || s == 156 || s == 151 || s == 152 || s == 157 || s == 158 || s == 136 || s == 111 || s == 160 || s == 133 || s == 137 || s == 143 || s == 144 || s == 139 || s == 141 || s == 149 || s == 150 || s == 110 || s == 153  || s == 131 || s == 140  || s == 147 || s == 148 ){
	
	if ($('.pageTypeBreadcrumb').size() > 0){
			
			$('#breadCrumb').html($('.pageTypeBreadcrumb').html());
			$('.pageTypeBreadcrumb').remove();
			
	}
	
}

			//END Breadcrumb fix
					
					
$('#webcast').hover(
  function () {
	  
	  if ($('#webcastContent').css('display') == "none"){

    $('#webcastContent').slideDown("slow");

	  }
  }, 
  function () {

  }
);

$('#webcastContent a.close, *').click(function(){ $('#webcastContent').slideUp("slow"); });
				

var tth;
var ttw;

$('#disclosurePages').hide(0);
//$('#hexWrapper').show(0);
$('#hexWrapper').fadeIn(600);
setTimeout(function(){

$('#hexWrapper .jigsaw img, #hexWrapper .middle img').each(function(){
		
		var th = $(this).height()*0.7;
		var tw = $(this).width()*0.7;
		
		$(this).css("height",th).css("width",tw);
		
		
		//$(this).parent().css("display", "block");
		
		$(this).attr("relh", th);
		$(this).attr("relw", tw);
		
		
					});
}, 0)
//$('#hexWrapper a').draggable({ revert: true });	 


$('#hexWrapper .jigsaw').hover(function(){
	
	
	tth = $("img", this).attr("relh");
	ttw = $("img", this).attr("relw");
	
	$(this).css("z-index" , "110");
	
	$("span", this).stop().animate({ fontSize: "22px"}, 200);
	$("img", this).stop().animate({height: tth*1.2+"px",width: ttw*1.2+"px"}, 200);
	
	
	 }, function(){
		 $("span", this).stop().animate({ fontSize: "15px"}, 200);
		 
		$("img", this).stop().animate({height: tth+"px", width: ttw+"px"}, 200, function(){$(this).parent().css("z-index" , "0");});
		
});
	 

	
$('.gri_section_body').slideUp(1000);$('.gri_section_title').click(function(){$('+ div', this).slideToggle();});

//$("#GRIBasket *").hide();	
//$('#GRIBasket').animate({height: "30px"}, 500).animate({width: "30px"}, 500, function(){$(this).addClass("vis");});




/*$('#GRIBasket').hover(function(){
	
	
		$(this).stop().animate({height: "100px"}, 200).animate({width: "220px"}, 500, function(){
			$("*",this).show(); 
			$(this).removeClass("vis");});
		
		}, 
		function(){
			$(this).stop().animate({height: "30px"}, 200).animate({width: "30px"}, 500, function(){
				$(this).addClass("vis");});
			$("*",this).hide();
		});*/




$("a.playClip").click(function(){
	
	
	
	mp3 = $(this).attr("rel");
	
	if($(this).siblings('iframe').length == 0){
		
	$(this).parent().append('<iframe frameborder="0" class="mp3Frame" src ="'+mp3+'" width="0" height="0"></iframe>');
	$(this).siblings('iframe').animate({"height" : "35px"}, 500);
	
	}
	
	
});

$( ".videoContainer" ).dialog({
			autoOpen: false,
			width: 445,
			height: 410,
			modal: true,
			resizable: false,
			buttons: {
				"Close": function() {
					$( this ).dialog( "close" );
				}
			}
			
		});
   $('a.playVideo').click(function() {
	   		
			$("#" + $(this).attr("rel")).dialog( "option", "title", $(this).attr("rel") );
			$("#" + $(this).attr("rel")).dialog( "open" );
			return false;
		});



$('.gri_section blockQuote').prepend("<h2>Case study</h2>");

$(".latestNews").each(function(){
	$(this).append('<div class="feed"></div>');
	$(".feed", this).load( $("h2 a", this).attr("href") +" .crodaNews:eq(0)", function(){
	});
});

var windowSizeArray = [ "width=720,height=445",
                                    "width=300,height=400,scrollbars=yes" ];

$('.puremaxVid').click(function (event){
 
                    var url = $(this).attr("href");
                    var windowName = "popUp";//$(this).attr("name");
                    var windowSize = windowSizeArray[0];
 
                    window.open(url, windowName, windowSize);
 
                    event.preventDefault();
 
                });
				
				
/*******************************Final Video Stuff*******************/


var vidNum = 1;

function moveButton ($obj, $buttonClass, $vidNum, $butt){
	
	$butt = $("#theButton"+vidNum, $obj);
	
	$(window).load(function () {
	
			containerWidth = $("img.oldImage", $obj).width();
			containerHeight = $("img.oldImage", $obj).height();
			
			$('.playButton'+$vidNum, $obj)
				.addClass("hit"+vidNum)
				.fadeTo(0, 0)
				.css('display', 'block')
				.css("position", "absolute")
				.css("width", $butt.width()+"px")
				.css("height", $butt.height()+"px")
				.fadeTo(400, 0.7)
				.css("top", ( (containerHeight/2)  - ($butt.height()/2)       )+"px")
				.css("left", ( (containerWidth/2)  - ($butt.width()/2)       )+"px")
				.find('input').css('margin', '0px').end()
				;
				
	});
}


$('.videoWrapper.image').each(function(){

	
	
	$obj = $(this);
	
	if ($obj.hasClass('test')){
			theButtonSrc = "multimedia/_images/playTrailerWhite.png";
		} else {
			theButtonSrc = "multimedia/_images/playButton.png"; 
		}
	
	
	var buttonID = $("input", $obj).attr('id'), 
		buttonName = $("input", $obj).attr('name'), 
		buttonImage = $("input", $obj).attr('src')
			;	
	
	
	$("input", $obj).remove();
	
	$obj
		.css("position", "relative")
		.css("display", "inline-block")
		.prepend('<img class="oldImage" src="'+buttonImage+'" />')
		.prepend('<div class="playButton'+vidNum+'" style="display: none;"><input type="image" style="border-width:0px; padding: 0;" src="'+ theButtonSrc + '" id="'+buttonID+'" name="'+buttonName+'"></div>')
		;
		
		
		containerWidth = $("img.oldImage", $obj).width();
		containerHeight = $("img.oldImage", $obj).height();
		
		$obj.append('<img src="'+theButtonSrc+'" style="display: none;" id="theButton'+vidNum+'" />');
		
		$butt = $("#theButton"+vidNum, $obj);
		

		/*if (p != "3715"){
		$(window).load(function () {
			
			containerWidth = $("img.oldImage", $obj).width();
			containerHeight = $("img.oldImage", $obj).height();
			
			
			
			$('.playButton', $obj)
				.addClass("hit"+vidNum)
				.fadeTo(0, 0)
				.css('display', 'block')
				.css("position", "absolute")
				.css("width", $butt.width()+"px")
				.css("height", $butt.height()+"px")
				.fadeTo(400, 0.7)
				.css("top", ( (containerHeight/2)  - ($butt.height()/2)       )+"px")
				.css("left", ( (containerWidth/2)  - ($butt.width()/2)       )+"px")
				.find('input').css('margin', '0px').end()
				;


		});
		} else {*/
		
			moveButton($obj, "hit"+vidNum,  vidNum, ($butt.height()/2), ($butt.width()/2));
			
			
		//	}
	
		$('.playButton', $obj).hover(function(){
			$(this).stop(true, true).fadeTo(200, 1)
		}, function(){
			$(this).stop(true, true).fadeTo(200, 0.7)
		});
		
		
		
	vidNum++;
});




/*******************************End Final Video Stuff*******************/				
				
				
	
	
	
$('.WebStatsGraph img').each(function(){
	theHeight = $(this).height();
	$(this).height(0);
	$(this).animate({'height' : theHeight },2000);
});
				
				
				


});

