/**
  * Function for opening the product features window, and
  * possibly the print window
  */

/*********************************************************
   funcOpenWindow()
   strURL - String, URL that the window opens initially
   strWindowName - String, name of the window 
   intWindowHeight - Int, initial window height
   intWindowWidth - Int, initial window width
   blnCanResize - Boolean, can the user resize the window
   Andy Millard, 8th January 2002
**********************************************************/
function funcOpenWindow(strURL, strWindowName, intWindowHeight, intWindowWidth, blnCanResize)
{
   if (blnCanResize)
   {
      return window.open(strURL, strWindowName, "width=" + intWindowHeight + ",height=" + intWindowWidth + ",scrollbars=yes,screenX=0,screenY=0,top=150,left=300,marginheight=0, marginwidth=0,resizable=yes");
   }
   else
   {
      return window.open(strURL, strWindowName, "width=" + intWindowHeight + ",height=" + intWindowWidth + ",scrollbars=yes,screenX=0,screenY=0,top=150,left=300,marginheight=0, marginwidth=0,resizable=no");
   }
}


// pre-load images function
function MM_preloadImages() { //v3.0
	var d=document; 
	if(d.images){ 
		if(!d.MM_p) 
			d.MM_p=new Array();
			var i,
			j=d.MM_p.length,
			a=MM_preloadImages.arguments; 
			for(i=0; i<a.length; i++)
				if (a[i].indexOf("#")!=0){ 
					d.MM_p[j]=new Image; 
					d.MM_p[j++].src=a[i];
				}
		}
	}

// image swapping functions
function MM_swapImgRestore() { //v3.0
	var i;
	var x;
	var a=document.MM_sr; 
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) 
		x.src=x.oSrc;
	}

function MM_swapImage() { //v3.0
	var i;
	var j=0;
	var x;
	var a=MM_swapImage.arguments; 
	
	document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

	if ((x=MM_findObj(a[i]))!=null){
		document.MM_sr[j++]=x; 
		if(!x.oSrc) 
			x.oSrc=x.src;
			x.src=a[i+2];
		}
	}

function MM_findObj(n, d) { //v3.0
	var p;
	var i;
	var x;
	if(!d) d=document;
		if((p=n.indexOf("?"))>0&&parent.frames.length) {
			d=parent.frames[n.substring(p+1)].document;
			n=n.substring(0,p);
		}
	
	if(!(x=d[n])&&d.all) x=d.all[n];
		for (i=0;!x&&i<d.forms.length;i++) 
			x=d.forms[i][n];
			for(i=0;!x&&d.layers&&i<d.layers.length;i++)
				x=MM_findObj(n,d.layers[i].document);
				return x;
	}

/* NAVIGATION */
// swap the images in the main navigation 
// and show the respective options for each
// item
function mainNavigation(intimagenum, strLanguage, strDirStructure) {
    var j;
    for (j=1; j<=5; j++) {
        var strImgObjectName = "mainNav" + j;
        var strOn;
        if (j == intimagenum)
            strOn = "_on";
        else
            strOn = "";
        var strImgFileName = strDirStructure + "images/" + strLanguage + "/navigation/site/top_nav_" + j + strOn + ".gif";
        //Lookup the image in the document
        var objImg = document.images[strImgObjectName];
        // Set the source file
        objImg.src = strImgFileName;

    }
   
    //showelement("show1", intimagenum == 1);
    //showelement("show2", intimagenum == 2);
    //showelement("show3", intimagenum == 3);

    showelement('show1', 1);
    showelement('show2', 2);
    showelement('show3', 3);
    
}

// Show layer function
// IE 4-6 NS 4-6
function showelement(strName, blnShow) {

    // W3C dom compliant browsers (IE5, Mozilla etc.)
    if (document.getElementById)
    {
        document.getElementById(strName).style.visibility = 
            blnShow ? "visible" : "hidden";
        return;
    }
    // NS4 layers
    if (document.layers) 
    {
        document.layers[strName].visibility =
            blnShow ? "show" : "hide";
        return;
    }
    // Anything which supports document.all (IE4; some others like Konqueror)
    if (document.all)
        document.all[strName].visibility = 
            blnShow ? "visible" : "hidden";
}


// swap images in the home page navigation
function homeNavImgSwap(intImageNum, strDirStructure, strLanguage, intRangeCount) {
    var j;
    for (j=1; j<=intRangeCount; j++) {
        var strImgObjectName = "rotaryCollection" + j;
        var strOn;
        if (j == intImageNum)
            strOn = "_on";
        else
            strOn = "";
        var strImgFileName = strDirStructure + "images/" + strLanguage + "/navigation/product/rotary_collection_" + j + strOn + ".gif";
        //Lookup the image in the document
        var objImg = document.images[strImgObjectName];
        // Set the source file
        objImg.src = strImgFileName;
    }
}

/* WATCH TERMINOLOGY */
function showTerminologyText(intImageNum) {

	showelement("A-B", intImageNum == 1);
    showelement("C", intImageNum == 2);
    showelement("D-J", intImageNum == 3);
    showelement("K-P", intImageNum == 4);
    showelement("R-Z", intImageNum == 5);
}

/* CONTACTS PAGE */
// Highlight the region on the map
function showRegion(strRegion, strDirStructure, strLanguage) {
    strSrc = strDirStructure + "images/" + strLanguage + "/contact/" + strRegion + '.gif';
    document.map.src = strSrc;
}

// Show the contact info for each region
function showContactInfo(intImageNum) {

	showelement("contactsWorldwide", intImageNum == 0);
	showelement("contactsNorthAmerica", intImageNum == 1);
    showelement("contactsEurope", intImageNum == 2);
    showelement("contactsEasternEurope", intImageNum == 3);
	showelement("contactsMiddleEast", intImageNum == 4);
	showelement("contactsAfrica", intImageNum == 5);
	showelement("contactsAsia", intImageNum == 6);
	showelement("contactsSouthPacific", intImageNum == 7);
}

/*****************************************************************************************************
  Andy Millard
 Used on home page display display a random image. 
 We use the values above (which is what needs to be changed to add/remove images)
 *****************************************************************************************************
 Andy Millard, 11th October 2002
 Okay, so as you can see, the values are not above. This is because they are now held
 in a document of type 'Rotating Image'. The javascript arrays that used to be above are
 now written out by the XSL in common.
 *****************************************************************************************************/
function HomePageImage()
{
var intRandom = parseInt(Math.random() * MAX_PRODUCT_ROTATION_IMAGES);

var strImage = "";
strImage = "<a href=\"" + PRODUCT_ROTATION_LINK_ARRAY[intRandom][0] + "\"><img width=\"468\" height=\"155\" alt=\"" + PRODUCT_ROTATION_LINK_ARRAY[intRandom][2] + "\" border=\"0\" src=\"" + PRODUCT_ROTATION_LINK_ARRAY[intRandom][1] + "\" /></a>";
document.write (strImage);

}


function RotatingPageImage(intNumber)
{

if (intNumber > MAX_PRODUCT_ROTATION_IMAGES)
	intNumber = MAX_PRODUCT_ROTATION_IMAGES;


var strImage = "";
strImage = "<a href=\"" + PRODUCT_ROTATION_LINK_ARRAY[intNumber-1][0] + "\"><img width=\"468\" height=\"155\" alt=\"" + PRODUCT_ROTATION_LINK_ARRAY[intNumber-1][2] + "\" border=\"0\" src=\"" + PRODUCT_ROTATION_LINK_ARRAY[intNumber-1][1] + "\" /></a>";
document.write (strImage);

}


//// Pop Up Window Script [start] ---------------------------------
var win=null;
	function NewWindow(mypage,myname,w,h,scroll,pos)
	{
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(mypage,myname,settings);
	}
//// Pop Up Window Script [end] ---------------------------------



	//************************************************************************************
	//*																					 *
	//*		Fix IE and Flash: "click to activate and use this content"					 *
	//*																					 *
	//************************************************************************************
		var bo_ns_id = 0;
		
		function startIeFix(){
		  if(isIE()){
			document.write('<div id="bo_ns_id_' + bo_ns_id + '"><!-- ');
		  }
		}
		
		function endIeFix(){
		  if(isIE()){
			document.write('</div>');
			var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);
			var theCode = theObject.innerHTML;
			theCode = theCode.substring(4 ,9+theCode.indexOf("</object>"))
			document.write(theCode);
		  }
		}
		
		function isIE(){
		  // only for Win IE 6+
		  // But not in Windows 98, Me, NT 4.0, 2000
		  var strBrwsr= navigator.userAgent.toLowerCase();
		  if(strBrwsr.indexOf("msie") > -1 && strBrwsr.indexOf("mac") < 0){
			if(parseInt(strBrwsr.charAt(strBrwsr.indexOf("msie")+5)) < 6){
			  return false;
			}
			if(strBrwsr.indexOf("win98") > -1 ||
			   strBrwsr.indexOf("win 9x 4.90") > -1 ||
			   strBrwsr.indexOf("winnt4.0") > -1 ||
			   strBrwsr.indexOf("windows nt 5.0") > -1)
			{
			  return false;
			}
			return true;
		  }else{
			return false;
		  }
		}
		//************************************************************************************
		//*		END																			 *
		//************************************************************************************

