



/* --------------------------------------------------- */

/* POP-UP WINDOW */

/* --------------------------------------------------- */

function openwin(URL,theHeight,theWidth,addScroll) {

	var nXpos = (screen.availWidth - theWidth) / 2; 

	var nYpos = (screen.availHeight - theHeight) / 2; 

	var win = window.open(URL, 'popupWin', 'top=' + nYpos + ',left=' + nXpos + ',screenY=' + nYpos + ',screenX=' + nXpos + ',height=' + theHeight + ',width=' + theWidth + 'toolbar=0,scrollbars=' + addScroll + ',location=0,statusbar=0,menubar=0');

	win.focus();

}







/* --------------------------------------- */

/* OPEN EXTERNAL LINKS IN NEW WINDOW */

/* --------------------------------------- */

function externalLinks() { 

 if (!document.getElementsByTagName) return; 

 var anchors = document.getElementsByTagName("a"); 

 for (var i=0; i<anchors.length; i++) { 

   var anchor = anchors[i]; 

   if (anchor.getAttribute("href") && 

       anchor.getAttribute("rel") == "external") 

     anchor.target = "_blank"; 

 } 

}











/* --------------------------------------------------- */

/* AUTO TAB */

/* --------------------------------------------------- */

var isNN = (navigator.appName.indexOf("Netscape")!=-1);



function autoTab(input,len, e) {

  var keyCode = (isNN) ? e.which : e.keyCode; 

  var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];

  if(input.value.length >= len && !containsElement(filter,keyCode)) {

    input.value = input.value.slice(0, len);

    input.form[(getIndex(input)+1) % input.form.length].focus();

  }



  function containsElement(arr, ele) {

    var found = false, index = 0;

    while(!found && index < arr.length)

    if(arr[index] == ele)

    found = true;

    else

    index++;

    return found;

  }



  function getIndex(input) {

    var index = -1, i = 0, found = false;

    while (i < input.form.length && index == -1)

    if (input.form[i] == input)index = i;

    else i++;

    return index;

  }

  return true;

}







/* --------------------------------------------------- */

/* HANDLE PNGS  */

/* --------------------------------------------------- */

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.

{

   var arVersion = navigator.appVersion.split("MSIE")

   var version = parseFloat(arVersion[1])

   if ((version >= 5.5) && (document.body.filters))

   {

      for(var i=0; i<document.images.length; i++)

      {

         var img = document.images[i]

         var imgName = img.src.toUpperCase()

         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")

         {

            var imgID = (img.id) ? "id='" + img.id + "' " : ""

            var imgClass = (img.className) ? "class='" + img.className + "' " : ""

            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "

            var imgStyle = "display:inline-block;" + img.style.cssText

            if (img.align == "left") imgStyle = "float:left;" + imgStyle

            if (img.align == "right") imgStyle = "float:right;" + imgStyle

            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle

            var strNewHTML = "<span " + imgID + imgClass + imgTitle

            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"

            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"

            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"

            img.outerHTML = strNewHTML

            i = i-1

         }

      }

   }

}





/* --------------------------------------- */

/* HOME PAGE BANNERS AND TEXT TOGGLES */

/* --------------------------------------- */



function fadeIn(which) {

	

	var imgDiv = which + '-img';

	

	Effect.Fade(which, {duration:0.6, queue:'parallel',from:0.0, to:1.0});

	Effect.Fade(imgDiv, {duration:0.5, queue:'parallel',from:0.0, to:1.0});

			

	Effect.Fade('default-copy', {duration:0.8, queue:'parallel',from:1.0, to:0.0});

	Effect.Fade('default-img', {duration:0.8, queue:'parallel',from:1.0, to:0.0});

	

}







/* --------------------------------------- */

/* HOME PAGE BANNERS AND TEXT TOGGLES */

/* --------------------------------------- */



function fadeOut(which) {

	

	var imgDiv = which + '-img';

	

	Effect.Fade(which, {duration:0.6, queue:'parallel',from:1.0, to:0.0});

	Effect.Fade(imgDiv, {duration:0.5, queue:'parallel',from:1.0, to:0.0});

}









/* --------------------------------------- */

/* MOVE FIRST POINTER IMAGE */

/* --------------------------------------- */

function moveit(numMove) {

	var offsetPixels = (15 * numMove);

	var pointer = document.getElementById('p2');

	pointer.style.marginTop = '-' + (194 - offsetPixels) + 'px';

}





/* --------------------------------------- */

/* MOVE SECOND POINTER IMAGE */

/* --------------------------------------- */

function moveit2(numMove) {

	var offsetPixels = (15 * numMove);

	var pointer = document.getElementById('p3');

	pointer.style.marginTop = '-' + (210 - offsetPixels) + 'px';

}





/* --------------------------------------- */

/* MOVE BANNER TITLE */

/* --------------------------------------- */

function lowerIt() {

	var theTitle = document.getElementById('page-title');

	

	var theTop = 240 - theTitle.offsetHeight;

	theTitle.style.top = theTop + 'px';

}







/* --------------------------------------------------- */

/* PRODUCT FINDER */

/* --------------------------------------------------- */



function showForm(whichType) {

	

	if (whichType == "component") {

		document.getElementById('find-component').style.display = 'block';

		document.getElementById('find-mould').style.display = 'none';

	} else if (whichType == "mould") {

		document.getElementById('find-component').style.display = 'none';

		document.getElementById('find-mould').style.display = 'block';

	} else {

		document.getElementById('find-component').style.display = 'none';

		document.getElementById('find-mould').style.display = 'none';

	}

	

}







/* --------------------------------------- */

/* SET A COOKIE */

/* --------------------------------------- */

function SetCookie(cookieName,cookieValue,nDays) {

	var today = new Date();

	var expire = new Date();

	if (nDays==null || nDays==0) nDays=1;

		expire.setTime(today.getTime() + 3600000*24*nDays);

		document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();

}







/* --------------------------------------- */

/* DELETE A COOKIE */

/* --------------------------------------- */

function changeCookie(whatNow) { 

	SetCookie('myRegion', '', -30);

	SetCookie('myRegion',whatNow,2500);

} 









/* --------------------------------------- */

/* SET REGION COOKIE BASED ON TIMEZONE */

/* --------------------------------------- */



function regionCookie() {

	var rightNow = new Date();

	var date1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);

	var date2 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0);

	var temp = date1.toGMTString();

	var date3 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));

	var temp = date2.toGMTString();

	var date4 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));

	var hoursDiffStdTime = (date1 - date3) / (1000 * 60 * 60);

	var hoursDiffDaylightTime = (date2 - date4) / (1000 * 60 * 60);

	

	if (hoursDiffStdTime in {'0':'', '1':''}) { // IS EUROPE

		SetCookie('myRegion','uk',364);

		

	} else { // IS EVERYWHERE ELSE

		SetCookie('myRegion','row',364);

	}

	

}





/* BANNER ROLLOVER */

function composite() {

	setTimeout("compositeImgFade.start()",500);

}



function tooling() {

	setTimeout("toolingImgFade.start()",500);

}



function adhesives() {

	setTimeout("adhesivesImgFade.start()",500);

}



function aero() {

	setTimeout("aerospaceImgFade.start()",500);

}



function auto() {

	setTimeout("performanceImgFade.start()",500);

}



function motor() {

	setTimeout("motorsImgFade.start()",500);

}



function marine() {

	

	setTimeout("marineImgFade.start()",500);

}



function other() {

	setTimeout("windImgFade.start()",500);

}





/* BANNER ROLLOFF */

function compositeOff() {

	compositeImgFade.start();

}



function toolingOff() {

	toolingImgFade.start();

}



function adhesivesOff() {

	adhesivesImgFade.start();

}



function aeroOff() {

	aerospaceImgFade.start();

}



function autoOff() {

	performanceImgFade.start();

}



function motorOff() {

	motorsImgFade.start();

}



function marineOff() {

	marineImgFade.start();

}



function otherOff() {

	windImgFade.start();

}