/*
* 2008 - Lost Boys
*
* To get the link and the logo on your website you should place a piece of JavaScript on your site.
* 
* <script type="text/javascript" src="http://www.akzonobel.com/logo_embedder/logo_embedder.js"></script>
* <script type="text/javascript">
* 	embedLogo('64', 'white', 'top');
* </script>
* 
* the embedLogo function takes three arguments (size, background, position)
* 
* size: 			'between 50x60 and 200x239'
* background: 'white' | 'other' 
* position: 	'top' | 'bottom'
* 
* If a background a value 'other' is used a transparent .png instead of a white background .gif
* Additional CSS/HTC is loaded to make sure older Internet Explorer handle the transparency correctly.
* 
* Calling this function will create the HTML inside your own page, no iframe is used.
* 
* 
*/

/* 
* main function to embed to the logo on your page
*/
function embedLogo(imageSize, backgroundColor, logoOrientation) {

	/*
	* where to find the logos, css etc
	*/
	var root = "http://www.akzonobel.com/endorsement"
	// var root = "/endorsement"
	/*
	* URL of css file
	*/
	var styleSheetSrc = root + "/logo_embedder.css"
	/*
	* where to go after a user clicks on the logo?
	*/
	var clickUrl = "http://www.akzonobel.com";

	/*
	* alt / title attribute of logo
	*/
	var toolTip = "Go to the AkzoNobel homepage"
	/*
	* initial string the will build the URL to the logo
	*/
	var imageSrc = root + "/logos/";

	// basic style for logo
	addStyleSheet(styleSheetSrc);


	// start in correct folder
	if (backgroundColor == 'white') {
		imageSrc += 'white/akzonobel-logo-';
	} else {
		imageSrc += 'transparent/akzonobel-logo-';
	}

	sizeArray = imageSize.toLowerCase().split('x');
	w = parseInt(sizeArray[0]);
	h = parseInt(sizeArray[1]);

	if (w == 0 || w > 200 || w < 50) {
		alert("invalid imagesize specified. You specified: " + imageSize);
		return false;
	}
	
	imageSrc += imageSize
	
	if (logoOrientation == 'bottom') {
		imageSrc += '-bottom'
	} else {
		imageSrc += '-top'
	}
	
	if (backgroundColor == 'white') {
		imageSrc += '.gif'
	} else {
		imageSrc += '.png'
		// add some styles to make sure the PNG logo transparency works in IE
		if (document.all && /MSIE (5\.5|6)/.test(navigator.userAgent) && document.styleSheets && document.styleSheets[0] && document.styleSheets[0].addRule)
		{
			document.styleSheets[0].addRule('#embedded-akzo-logo-link img', 'behavior: url('+root+'/iepngfix.htc)');
		}
	}

	clickUrl += '?endorsement_logo=1&src=' + window.location;
	document.write('<a id="embedded-akzo-logo-link" title="'+toolTip+'" href="'+clickUrl+'" title="AkzoNobel"><image width="'+w+'" height="'+h+'" src="'+imageSrc+'" alt="'+toolTip+'" /></a>')
}

/*
* add a stylesheet link to the current document
*/
function addStyleSheet(href) {
	var styleSheetLink = document.createElement('link');;
	styleSheetLink.setAttribute("rel", "stylesheet");
	styleSheetLink.setAttribute("href", href);
	styleSheetLink.setAttribute("media", "screen");
	document.getElementsByTagName('head')[0].appendChild(styleSheetLink);
}