//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 bannerSRC = "";
 var bannerLink = "";
 var bannerTarget = "";


 switch(r) //regionImages
	{
		//Croda.Com
		
		case "62": //Home
  		noBanner = 1;
 		break;
		
		case "63": //Company
  		bannerSRC = "images/banners/corp_company.jpg";
		//if (p == "45"){ bannerSRC = "images/banners/corp/2010_company.jpg";}
		//if (p == "433"){ bannerSRC = "images/banners/corp/2010_policy.jpg";}
		//if (p == "463"){ bannerSRC = "images/banners/corp/2010_policy.jpg";}
		//if (p == "852"){ bannerSRC = "images/banners/corp/2010_policy.jpg";}
		//if (p == "478"){ bannerSRC = "images/banners/corp/2010_policy.jpg";}
		//if (p == "2115"){ bannerSRC = "images/banners/corp/2010_company.jpg";}
		if (p == "416"){ noBanner = 1;}
		//if (p == "1044"){ bannerSRC = "images/banners/corp/2010_directors.jpg";}
		//if (p == "118"){ bannerSRC = "images/banners/corp/2010_governance.jpg";}
		//if (p == "235"){ bannerSRC = "images/banners/corp/2010_governance.jpg";}
		//if (p == "236"){ bannerSRC = "images/banners/corp/2010_governance.jpg";}
		//if (p == "554"){ bannerSRC = "images/banners/corp/2010_governance.jpg";}
		//if (p == "555"){ bannerSRC = "images/banners/corp/2010_governance.jpg";}
		//if (p == "556"){ bannerSRC = "images/banners/corp/2010_governance.jpg";}
		//if (p == "237"){ bannerSRC = "images/banners/corp/2010_governance.jpg";}
		//if (p == "414"){ bannerSRC = "images/banners/corp/2010_history.jpg"; bannerLink = "home.aspx?d=content&s=1&r=63&p=415";}		
		//if (p == "415"){ bannerSRC = "images/banners/corp/2010_history.jpg";}
		//if (p == "112"){ bannerSRC = "images/banners/corp/2010_technology.jpg";}
		if (p == "111"){ bannerSRC = "images/banners/corp/2010_manufacturing.jpg";}
		//if (p == "462"){ bannerSRC = "images/banners/corp/2010_research.jpg";}
		if (p == "113"){ bannerSRC = "images/banners/corp/2010_safety.jpg";}
		if (p == "2011"){ bannerSRC = "images/banners/corp/2010_safety.jpg";}
		if (p == "2012"){ bannerSRC = "images/banners/corp/2010_safety.jpg";}
		if (p == "2013"){ bannerSRC = "images/banners/corp/2010_safety.jpg";}
		if (p == "2014"){ bannerSRC = "images/banners/corp/2010_safety.jpg";}
		if (p == "2015"){ bannerSRC = "images/banners/corp/2010_safety.jpg";}
		if (p == "2016"){ bannerSRC = "images/banners/corp/2010_safety.jpg";}
		if (p == "2017"){ bannerSRC = "images/banners/corp/2010_safety.jpg";}
		if (p == "2018"){ bannerSRC = "images/banners/corp/2010_safety.jpg";}
		if (p == "2019"){ bannerSRC = "images/banners/corp/2010_safety.jpg";}
		if (p == "2020"){ bannerSRC = "images/banners/corp/2010_safety.jpg";}
		if (p == "2021"){ bannerSRC = "images/banners/corp/2010_safety.jpg";}
		if (p == "232"){ bannerSRC = "images/banners/corp/2010_safety.jpg";}
		//if (p == "1946"){ bannerSRC = "images/banners/corp/2010_reach.jpg";}		
 		break;
		
		case "70": //Markets 
  		bannerSRC = "images/banners/corp_company.jpg";
		//if (p == "44" || p == ""){ noBanner = 1;}
		if (p == "95"){ bannerSRC = "images/layout/corp/markets/2010_PersonalCare.jpg"; bannerLink = "http://www.croda.com/home.aspx?s=147"; bannerTarget = "new";}
		if (p == "103"){ bannerSRC = "images/layout/corp/markets/2010_HealthCare.jpg";}
		if (p == "203"){ bannerSRC = "images/layout/corp/markets/2010_HealthCare.jpg";}
		if (p == "204"){ bannerSRC = "images/layout/corp/markets/2010_HealthCare.jpg";}
		if (p == "205"){ bannerSRC = "images/layout/corp/markets/2010_HealthCare.jpg";}
		if (p == "2530"){ bannerSRC = "images/layout/corp/markets/2010_HealthCare.jpg";}
		if (p == "106"){ bannerSRC = "images/layout/corp/markets/2010_Crop_Care.jpg";}
		if (p == "104"){ bannerSRC = "images/layout/corp/markets/2010_HomeCare.jpg";}
		if (p == "223"){ bannerSRC = "images/layout/corp/markets/2010_Oleochemicals.jpg";}
		if (p == "105"){ bannerSRC = "images/layout/corp/markets/2010_PolymerAdditives.jpg";}
		if (p == "224"){ bannerSRC = "images/layout/corp/markets/2010_PolymersCoatings.jpg";}
		if (p == "1456"){ bannerSRC = "images/layout/corp/markets/2010_LubricantsAdditives.jpg";}
		if (p == "169"){ bannerSRC = "images/layout/corp/markets/2010_GeoTechnologies.jpg";}		
		if (p == "1584"){ bannerSRC = "images/layout/corp/markets/2010_Oilfield.jpg";}
		if (p == "439"){ bannerSRC = "images/layout/corp/markets/2010_Mining.jpg";}
		
		if (p == "440"){ bannerSRC = "images/layout/corp/markets/2010_Mining.jpg";}
		if (p == "488"){ bannerSRC = "images/layout/corp/markets/2010_Mining.jpg";}
		if (p == "2524"){ bannerSRC = "images/layout/corp/markets/2010_Mining.jpg";}
		if (p == "2525"){ bannerSRC = "images/layout/corp/markets/2010_Mining.jpg";}
		if (p == "2526"){ bannerSRC = "images/layout/corp/markets/2010_Mining.jpg";}
		
		
		if (p == "168"){ bannerSRC = "images/layout/corp/markets/2010_WaterTreatment.jpg";}
		
		if (p == "288"){ bannerSRC = "images/layout/corp/markets/2010_WaterTreatment.jpg";}
		if (p == "289"){ bannerSRC = "images/layout/corp/markets/2010_WaterTreatment.jpg";}
		if (p == "291"){ bannerSRC = "images/layout/corp/markets/2010_WaterTreatment.jpg";}
		
		
		
		if (p == "1629"){ bannerSRC = "images/layout/corp/markets/2010_Textiles.jpg";}
		if (p == "1806"){ bannerSRC = "images/layout/corp/markets/2010_PrintingInks.jpg";}
		if (p == "441"){ bannerSRC = "images/layout/corp/markets/2010_ThermalPaper.jpg";}
		if (p == "225") { noBanner = 1;}
			//{ bannerSRC = "images/layout/corp/markets/2010_Seatons.jpg";}
  		break;
		
		
		case "73": //Locations 
		bannerSRC = "images/banners/corp_locations.jpg";
		if (p == "82"){ bannerSRC = "images/banners/corp_locationsEurope.jpg";}
		if (p == "83"){ bannerSRC = "images/banners/corp_locationsEurope.jpg";}
		if (p == "53"){ bannerSRC = "images/banners/corp_locationsEurope.jpg";}
		if (p == "56"){ bannerSRC = "images/banners/corp_locationsEurope.jpg";}
		if (p == "1626"){ bannerSRC = "images/banners/corp_locationsEurope.jpg";}
		if (p == "92"){ bannerSRC = "images/banners/corp_locationsEurope.jpg";}
		if (p == "1627"){ bannerSRC = "images/banners/corp_locationsEurope.jpg";}
		if (p == "93"){ bannerSRC = "images/banners/corp_locationsEurope.jpg";}
		if (p == "94"){ bannerSRC = "images/banners/corp_locationsEurope.jpg";}
		if (p == "102"){ bannerSRC = "images/banners/corp_locationsEurope.jpg";}
		if (p == "1623"){ bannerSRC = "images/banners/corp_locationsEurope.jpg";}
		if (p == "461"){ bannerSRC = "images/banners/corp_locationsEurope.jpg";}
		
		if (p == "57"){ bannerSRC = "images/banners/corp_locationsAsia.jpg";}
		if (p == "85"){ bannerSRC = "images/banners/corp_locationsAsia.jpg";}
		if (p == "397"){ bannerSRC = "images/banners/corp_locationsAsia.jpg";}
		if (p == "209"){ bannerSRC = "images/banners/corp_locationsAsia.jpg";}
		if (p == "84"){ bannerSRC = "images/banners/corp_locationsAsia.jpg";}
		if (p == "58"){ bannerSRC = "images/banners/corp_locationsAsia.jpg";}
		if (p == "110"){ bannerSRC = "images/banners/corp_locationsAsia.jpg";}
		if (p == "1621"){ bannerSRC = "images/banners/corp_locationsAsia.jpg";}
		if (p == "86"){ bannerSRC = "images/banners/corp_locationsAsia.jpg";}
		if (p == "1625"){ bannerSRC = "images/banners/corp_locationsAsia.jpg";}
		if (p == "88"){ bannerSRC = "images/banners/corp_locationsAsia.jpg";}
		if (p == "89"){ bannerSRC = "images/banners/corp_locationsAsia.jpg";}
		if (p == "87"){ bannerSRC = "images/banners/corp_locationsAsia.jpg";}
		if (p == "398"){ bannerSRC = "images/banners/corp_locationsAsia.jpg";}
		if (p == "210"){ bannerSRC = "images/banners/corp_locationsAsia.jpg";}
		if (p == "1624"){ bannerSRC = "images/banners/corp_locationsAsia.jpg";}
		if (p == "208"){ bannerSRC = "images/banners/corp_locationsAsia.jpg";}
		
		if (p == "90"){ bannerSRC = "images/banners/corp_locationsUSA.jpg";}
		if (p == "91"){ bannerSRC = "images/banners/corp_locationsUSA.jpg";}
		if (p == "96"){ bannerSRC = "images/banners/corp_locationsUSA.jpg";}
		if (p == "464"){ bannerSRC = "images/banners/corp_locationsUSA.jpg";}
		
		if (p == "97"){ bannerSRC = "images/banners/corp_locationsLatam.jpg";}
		if (p == "98"){ bannerSRC = "images/banners/corp_locationsLatam.jpg";}
		if (p == "99"){ bannerSRC = "images/banners/corp_locationsLatam.jpg";}
		if (p == "100"){ bannerSRC = "images/banners/corp_locationsLatam.jpg";}
		if (p == "424"){ bannerSRC = "images/banners/corp_locationsLatam.jpg";}
		if (p == "101"){ bannerSRC = "images/banners/corp_locationsLatam.jpg";}
		if (p == "1756"){ bannerSRC = "images/banners/corp_locationsLatam.jpg";}
		if (p == "238"){ bannerSRC = "images/banners/corp_locationsLatam.jpg";}
		if (p == "429"){ bannerSRC = "images/banners/corp_locationsLatam.jpg";}
		if (p == "430"){ bannerSRC = "images/banners/corp_locationsLatam.jpg";}
		if (p == "423"){ bannerSRC = "images/banners/corp_locationsLatam.jpg";}
		if (p == "427"){ bannerSRC = "images/banners/corp_locationsLatam.jpg";}
		if (p == "426"){ bannerSRC = "images/banners/corp_locationsLatam.jpg";}
		if (p == "428"){ bannerSRC = "images/banners/corp_locationsLatam.jpg";}
		if (p == "425"){ bannerSRC = "images/banners/corp_locationsLatam.jpg";}
		
		break;
		
		case "233": //Investor 
		bannerSRC = "images/banners/corp_investor.jpg";
		
		if (p == "120"){noBanner = 1; fullHeight = 1;} //detailed price
		if (p == "126"){noBanner = 1; fullHeight = 1;} //Ealerts
		if (p == "226"){noBanner = 1; fullHeight = 1;} //report 2002
		if (p == "227"){noBanner = 1; fullHeight = 1;} //report 2001
		if (p == "229"){noBanner = 1; fullHeight = 1;} //report 2000
		if (p == "557"){noBanner = 1; fullHeight = 1;} //report 2003
		if (p == "993"){noBanner = 1; fullHeight = 1;} //report 2004
		if (p == "958"){noBanner = 1; fullHeight = 1;} //Share Price charts page 
		if (p == "1210"){noBanner = 1; fullHeight = 1;} //report 2005
		if (p == "1343"){noBanner = 1; fullHeight = 1;} //report 2006
		if (p == "1470"){noBanner = 1; fullHeight = 1;} //report 2007
		if (p == "1927"){noBanner = 1; fullHeight = 1;} //Report08
		break;
		
		case "234": //Careers 
		bannerSRC = "images/banners/corp_company.jpg";
		//bannerSRC = "images/banners/corp_careers.jpg";
		break;
			
		case "79":  //CSR
		noBanner = 1;
  		//bannerSRC = "images/layout/corp2009/design/csrBG.jpg";
		//if (p == "130" || p == ""){ noBanner = 1;}
		//if (p == "1611"){ bannerSRC = "images/banners/2010_CSR_responsibleCare.gif";}
		break;
		
		case "255":  //Croda Direct
		bannerSRC = "images/banners/corp_locations.jpg";
		if (p == "1769"){ bannerSRC = "images/layout/corp/markets/2010_Oleochemicals.jpg";}
		if (p == "1825"){ bannerSRC = "images/layout/corp/markets/2010_PolymersCoatings.jpg";}
		if (p == "1826"){ bannerSRC = "images/layout/corp/markets/2010_LubricantsAdditives.jpg";}
		if (p == "1928"){ bannerSRC = "images/layout/corp/markets/2010_Crop_Care.jpg";}
		if (p == "2051"){ bannerSRC = "images/layout/corp/markets/2010_PersonalCare.jpg";}
		if (p == "2278"){ bannerSRC = "images/layout/corp/markets/2010_HealthCare.jpg";}
		if (p == "2279"){ bannerSRC = "images/layout/corp/markets/2010_HomeCare.jpg";}
		if (p == "2280"){ bannerSRC = "images/layout/corp/markets/2010_PolymerAdditives.jpg";}
		if (p == "2491"){ bannerSRC = "images/layout/corp/markets/2010_Oilfield.jpg";}
		if (p == "2077"){ bannerSRC = "images/layout/corp/markets/2010_Crodarom.jpg";}
		
		break;
		 
  		//End Croda.Com
  
		default://add site defaults here
			 switch(s)
		  			{
		  			case "1"://Croda.Com
						bannerSRC = "1";
						if (r == ""){ noBanner = 1;}
						break;
		  			case "2":
						bannerSRC = "2";
						break;
					case "135": //Ent tech
						 noBanner = 1;
						break;
					case "146": //Croda Direct
						bannerSRC = "images/banners/corp_locations.jpg";
						break;
						
		  			default:
						 noBanner = 1;
						break;
		  }
}

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;");
																});

							   
							   if (noBanner == 0 && (d == "content" || d == "" )){
								 
							$("td.layoutContent").prepend('<div class="banner" id="site' + getParameterByName("s") + 'banner"></div>');
							$("div.banner").css("background-image", "url("+bannerSRC+")");
							$("div.banner").css("background-repeat", "no-repeat");
							
							if (bannerLink != ""){
							$("div.banner").css("cursor", "hand");
							
							if (bannerTarget == "new"){
							$('.banner').click( function(){ window.open(bannerLink)} );
							
							} else {
							$('.banner').click( function(){ window.location = bannerLink; });
							}
							}
							
							
							 }
							
							
							
							
							$("#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-20);
							}
							
							//Fix the Iframe issue
							var contentHeight = $("#tableMainLayout td.layoutContent").height();
							$('#tableMainLayout td.layoutContent iframe:not(".external")').css("height", contentHeight+"px");
							
							if (contentHeight < 350){
							$("#tableMainLayout td.layoutContent").css("height", "350px");	
							}
							
							//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){
	

			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();
				
			
			}
			
}
			//END Breadcrumb fix
					
					
$('#webcast').hover(
  function () {
	  
	  if ($('#webcastContent').css('display') == "none"){

    $('#webcastContent').slideDown("slow");

	  }
  }, 
  function () {

  }
);

$('#webcastContent a.close, *').click(function(){ $('#webcastContent').slideUp("slow"); });
				

						   });