var agt=navigator.userAgent.toLowerCase();
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    var is_nav6 = (is_nav && (is_major == 5));
    var is_nav6up = (is_nav && (is_major >= 5));
    var is_gecko = (agt.indexOf('gecko') != -1);
    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5")==-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
	var is_mac    = (agt.indexOf("mac")!=-1);

function MM_swapImage() { //v2.0
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  } }
  document.MM_swapImgData = swapArray; //used for restore
}


function Validate()
{
	var pr_selected = false

	if (document.forms[1].name.value == '')
	{
		alert("The field 'Name' is empty, please fill it in.");
		document.forms[1].name.focus();
		return false;
	}
	if (document.forms[1].role.value == '')
	{
		alert ("The field 'Role' is empty, please fill it in.");
		document.forms[1].role.focus();
		return false;
	}
	if (document.forms[1].company.value == '')
	{
		alert ("The field 'Company' is empty, please fill it in.");
		document.forms[1].company.focus();
		return false;
	}
	if (document.forms[1].media.value == '' || document.forms[1].media.selectedIndex == 0)
	{
		alert ("The field 'Media Name' is empty, please fill it in.");
		document.forms[1].media.focus();
		return false;
	}
	if (document.forms[1].country.value == '' || document.forms[1].country.selectedIndex == 0)
	{
		alert ("The field 'Country' is empty, please fill it in.");
		document.forms[1].country.focus();
		return false;
	}
	if (document.forms[1].email.value == '')
	{
		alert ("The field 'E-Mail Address' is empty, please fill it in.");
		document.forms[1].email.focus();
		return false;
	}
	if (document.forms[1].phone.value == '')
	{
		alert ("The field 'Telephone' is empty, please fill it in.");
		document.forms[1].phone.focus();
		return false;
	}
	if (document.forms[1].fax.value == '')
	{
		alert ("The field 'Fax' is empty, please fill it in.");
		document.forms[1].fax.focus();
		return false;
	}
	if (document.forms[1].pref_comm[0].checked == false)
	{
		if (document.forms[1].pref_comm[1].checked == false)
		{
			alert ("The field 'Preferred method of communication' is empty, please fill it in.");
			document.forms[1].pref_comm[0].focus();
			return false;
		}
	}

	for (var i = 0; i < (document.forms[1].pr_type.length - 1); i++)
	{
		if (document.forms[1].pr_type[i].checked == true)
		{
			pr_selected = true;
		}
	}

	if (pr_selected != true)
	{
		alert ("You must choose at least one type of Press Release to receive!");
		document.forms[1].pr_type[0].focus();
		return false;
	}
	else
	{
		document.forms[1].submit();
		return true;
	}
}

function ValidateAll()
{
	if (document.forms[1].pr_type[9].checked == false)
	{
		for (var i = 0; i < (document.forms[1].pr_type.length - 1); i++)
		{
			document.forms[1].pr_type[i].checked = false;
		}
	}
	else
	{
		for (var i =  0; i < (document.forms[1].pr_type.length - 1); i++)
		{
			document.forms[1].pr_type[i].checked = true;
		}
	}
}

function CU_Validate()
{

	var sSection = document.forms[1].section.value;

	if (document.forms[1].Email1.value == '')
	{
		alert("You have not given your email address!");
		document.forms[1].Email1.focus();
		return false;
	}
	if (document.forms[1].Email2.value == '')
	{
		alert("Please confirm your email address.");
		document.forms[1].Email2.focus();
		return false;
	}
	if (document.forms[1].Email1.value != document.forms[1].Email2.value)
	{
		alert("The email addresses don not match.");
		document.forms[1].Email2.focus();
		return false;
	}
	if (document.forms[1].CommentBody.value == '')
	{
		alert("The field 'Your Question' is empty, please fill it in.");
		document.forms[1].CommentBody.focus();
		return false;
	}
	if (sSection != 'Brands')
	{
	 /* alert(document.forms[1].Comment.selectedIndex); */
		if (document.forms[1].Comment.value == '-1' || document.forms[1].Comment.selectedIndex == 0)
		{
			alert("Please state which area your question relates to.");
			document.forms[1].Comment.focus();
			return false;
		}
	}
	if (sSection != 'Investor Centre')
	{
		if (document.forms[1].Country.value == '-1' || document.forms[1].Country.selectedIndex == 0)
		{
			alert("Please state which Country you are from.");
			document.forms[1].Country.focus();
			return false;
		}
		if (sSection == 'Company')
		{
			if ((document.forms[1].Country.value == '44' || document.forms[1].Country.selectedIndex == 0) && document.forms[1].Country2.value == '')
			{
				alert("Please state which Country you are from.");
				document.forms[1].Country2.focus();
				return false;
			}
			else
			{
				document.forms[1].submit();
				return true;
			}
		}
		else
		{
			document.forms[1].submit();
			return true;
		}
	}
	else
	{
		document.forms[1].submit();
		return true;
	}
}


function openit(openPage) {

		if ((navigator.appName == 'Netscape') || (navigator.appName == 'Mozilla')) {
			var browserType = "Navigator";
			var windowCall = "unilever_ns";
		}else{
			if ((navigator.appName == 'Microsoft Internet Explorer') || (navigator.appName == 'MSIE')) {
				var browserType = "Explorer";
				var windowCall = "unilever_ie";
			}else{
				var browserType = "Generic";
				var windowCall = "unilever_ns";
			}
		}

		var onMac = navigator.appVersion.indexOf("Mac") >0;
	var onWin = navigator.appVersion.indexOf("Win") >0;
		var version = parseInt(navigator.appVersion);
		if (navigator.appVersion.indexOf("5.") != -1) {
			var version = 5;
		}
		var agent = (navigator.userAgent.toLowerCase());
		if (agent.indexOf() == "opera") {
			var browserType = "Opera";
			var windowCall = "unilever_ns";
		}
		var windowWide = 700;
		var windowTall = 540;

		if(onMac) {
			if (browserType == "Explorer") {
				if (version < 5) {
					var windowWide = 664;
					var windowTall = 513;
				}else{
					var windowWide = 662;
					var windowTall = 458;
				}
			}else{
				if (browserType == "Navigator") {
					if (version < 5) {
						var windowWide = 680;
						var windowTall = 475;
					}else{
						var windowWide = 680;
						var windowTall = 575;
					}
				}
			}
		}

		if(onWin) {
			if (browserType == "Explorer") {
				if (version < 5) {
					var windowWide = 680;
					var windowTall = 454;
				}else{
					var windowWide = 680;
					var windowTall = 454;
				}
			}else{
				if (browserType == "Navigator") {
					if (version < 5) {
						var windowWide = 680;
						var windowTall = 474;
					}else{
						var windowWide = 690;
						var windowTall = 635;
					}
				}
			}
		}

		var win = window.open(openPage,windowCall,'width='+windowWide+',height='+windowTall+',status=yes,resizable=yes,menubar=yes,toolbar=yes,scrollbars=yes');

}

function MM_jumpMenu(targ,selObj,restore){
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function showlayer(n)
{
if (is_nav && !is_nav6up && !is_mac)
   {
	document.images[imageArrayName[b]].src = imageArray[b].src;
	document.images[imageArrayName[n]].src = imageArrayOn[n].src;
	document.layers[divArrayName[b]].visibility='hidden';
	document.layers[divArrayName[n]].visibility='visible';
	b = n;
   }

	if (is_nav && !is_nav6up && is_mac)
   {
	document.images[imageArrayName[b]].src = imageArray[b].src;
	document.images[imageArrayName[n]].src = imageArrayOn[n].src;
	document.layers[divArrayName[b]].visibility='hidden';
	document.layers[divArrayName[n]].visibility='visible';
	b = n;
   }
   if (is_nav6up || is_gecko)
   {
        document.images[imageArrayName[b]].src = imageArray[b].src;
	document.images[imageArrayName[n]].src = imageArrayOn[n].src;
	document.getElementById(divArrayName[b]).style.visibility='hidden';
	document.getElementById(divArrayName[n]).style.visibility='visible';
	b = n;
    }
	if (is_ie5up && !is_mac)
   {
        document.images[imageArrayName[b]].src = imageArray[b].src;
	document.images[imageArrayName[n]].src = imageArrayOn[n].src;
	document.getElementById(divArrayName[b]).style.visibility='hidden';
	document.getElementById(divArrayName[n]).style.visibility='visible';
	b = n;
    }
	if (is_ie4 && !is_mac)
    {
	document.images[imageArrayName[b]].src = imageArray[b].src;
	document.images[imageArrayName[n]].src = imageArrayOn[n].src;
	document.all(divArrayName[b]).style.visibility='hidden';
        document.all(divArrayName[n]).style.visibility='visible';
        b = n;
    }
	if (is_ie5up && is_mac)
    {
	document.images[imageArrayName[b]].src = imageArray[b].src;
	document.images[imageArrayName[n]].src = imageArrayOn[n].src;
	document.all(divArrayName[b]).style.visibility='hidden';
	document.all(divArrayName[n]).style.visibility='visible';
        b = n;
    }
	if (is_ie4 && is_mac)
    {
	document.images[imageArrayName[b]].src = imageArray[b].src;
	document.images[imageArrayName[n]].src = imageArrayOn[n].src;
	document.all(divArrayName[b]).style.visibility='hidden';
	document.all(divArrayName[n]).style.visibility='visible';
	b = n;
    }
  return false
}

// Resize window functionality due to Netscape 4 problems

if(!window.saveInnerWidth) {
  window.onresize = resizeIt;
  window.saveInnerWidth = window.innerWidth;
  window.saveInnerHeight = window.innerHeight;
}

// compatibility with annual review pages. to be removed
function setStory(){
  return true
}
// compatibility with annual review pages. to be removed
function setNav() {
 return true
}

// compatibility with annual review pages. to be removed
function setSub() {
 return true
}

function resizeIt() {
    if (saveInnerWidth < window.innerWidth ||
        saveInnerWidth > window.innerWidth ||
        saveInnerHeight > window.innerHeight ||
        saveInnerHeight < window.innerHeight )
   {
	        window.history.go(0);
    }
}

function openSlideShowWindow(sURL){
      var sLink
      var regexp = /href\s*=\s*\"*[^\">]*/ig;
      var vArray = sURL.match(regexp);
      if(vArray != null){
         sLink = vArray[0].replace(/href\s*=\s*\"*/ig,"");         
      }else{
         sLInk = sURL;
      }
      window.open(sLink, 'popupwindow', 'width=523,height=580,resizable');
}


function goBadega(url)
{
var str = 'http:\/\/korma.unilever.com/cc/specmail.nsf/enquiry?open&country='+url;
window.open(str,'printWindow','location=yes,menubar=yes,scrollbars=yes,resizable=yes,width=655,height=635');
}

function SharePriceChange(change){
        if  (change > 0 ){
             return change + ' <img src="/ImagesCommon/icon_up.gif" height="13" width="13" border="0" alt="up">';
        }else{
            if (change < 0) {
                return  change + ' <img src="/ImagesCommon/icon_down.gif" height="13" width="13" border="0" alt="down">';
            }else{
                return  change + ' <img src="/ImagesCommon/px.gif" height="13" width="13" border="0" alt="no change">';
            }
       }
}

function ThemeNavNext(ThemeCount, Increment) {
    if (Increment == 1) {
        if (result < ThemeCount) {
             result++;
        }
        else {
             result = 1;
        }
    }
    else {
        if (result ==1) {
            result=ThemeCount;
        }
        else {
             result--;
        }
    }
    VaryTheme(result);
}
	
function writeHTML(theSpan, theText){
    document.getElementById(theSpan).innerHTML = theText
}


function tmt_findObj(n){
	var x,t; if((n.indexOf("?"))>0&&parent.frames.length){t=n.split("?");
	x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
	}else{x=document.getElementById(n)}return x;
}


function MM_showHideLayers() { //v3.0A Modified by Al Sparber and Massimo Foti for NN6 Compatibility
  var i,p,v,obj,args=MM_showHideLayers.arguments;if(document.getElementById){
   for (i=0; i<(args.length-2); i+=3){ obj=tmt_findObj(args[i]);v=args[i+2];
   v=(v=='show')?'visible':(v='hide')?'hidden':v;
   if(obj)obj.style.visibility=v;}} else{
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}



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];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,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);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,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 controlExpand() {
  var sup = event.srcElement.id;
  if (sup != '')
  {
  var sub = document.all[(sup + 'Sub')]
    if (sub != null)
    {
      if (sub.style.display == 'none')
      {
        sub.style.display = '';
      }
      else
      {
        sub.style.display = 'none';
      }
    }
  }
}



function checkRadios() {
 var el = document.forms[1].elements;
 for(var i = 0 ; i < el.length ; ++i) {
  if(el[i].type == "radio") {
   var radiogroup = el[el[i].name]; // get the whole set of radio buttons.
   var itemchecked = false;
   for(var j = 0 ; j < radiogroup.length ; ++j) {
    if(radiogroup[j].checked) {
	 itemchecked = true;
	 break;
	}
   }
   if(!itemchecked) {
    alert("Please select a response for each statement.");
    if(el[i].focus)
     el[i].focus();
	return false;
   }
  }
 }
 return true;
}



function checkFeedback() {
 var el = document.forms[1].elements;
 for(var i = 0 ; i < el.length ; ++i) {
  if(el[i].type == "radio") {
   var radiogroup = el[el[i].name]; // get the whole set of radio buttons.
   var itemchecked = false;
   for(var j = 0 ; j < radiogroup.length ; ++j) {
    if(radiogroup[j].checked) {
	 itemchecked = true;
	 break;
	}
   }
   if(!itemchecked) {
    alert("Please select a a value rating.");
    if(el[i].focus)
     el[i].focus();
	return false;
   }
  }
 }
 return true;
}


function checkGoals(action) {


if (document.form1.TotalValues.value<3 || document.form1.TotalValues.value>7 ) {
	alert ("Please select between 3 and 7 goals");
	return false;
}

if (action=="prioritise") {
   	document.form1.action="prioritise.asp";
   	} else {
   	document.form1.action="results.asp";   	
   	}

document.form1.submit();
   	
   	
}


function countGoals() {

 goalcount=0;
 var el = document.forms[1].elements;
 var itemempty = true;
 var allchecked = true;
 var allchecked1 = false;
 var allchecked2 = false;
 var nogoal=false;
 
 for(var i = 0 ; i < el.length ; ++i) {
 
  if(el[i].type == "textarea") {


 
    if(el[i].value !="") {
	 itemempty = false;
	 goalcount=goalcount+1;
	 
	 var radiogroup1 = el[el[i+1].name];
	 var radiogroup2 = el[el[i+4].name];

	 var allchecked1 = false;
	 var allchecked2 = false;
 
	   for(var j = 0 ; j < radiogroup1.length ; ++j) {
	   
	   
	    if(radiogroup1[j].checked==true) {
		 allchecked1 = true;
		}
	   }

	   for(var j = 0 ; j < radiogroup2.length ; ++j) {
	   
	   
	    if(radiogroup2[j].checked==true) {
		 allchecked2 = true;

		}
	   }

	if (allchecked1==false || allchecked2==false ) {
		allchecked=false;
	
	}

	}



    if(el[i].value =="") {
	 
	 var radiogroup1 = el[el[i+1].name];
	 var radiogroup2 = el[el[i+4].name];

	 var allchecked1 = false;
	 var allchecked2 = false;
 
	   for(var j = 0 ; j < radiogroup1.length ; ++j) {
	   
	   
	    if(radiogroup1[j].checked==true) {
		 allchecked1 = true;
		}
	   }

	   for(var j = 0 ; j < radiogroup2.length ; ++j) {
	   
	   
	    if(radiogroup2[j].checked==true) {
		 allchecked2 = true;

		}
	   }

	if (allchecked1==true || allchecked2==true ) {
		nogoal=true;
	
	}

	}

	
    }

 }


if(itemempty) {
	alert("Please enter and rate at least four specific goals.");
	return false;
}

if(allchecked == false) {
	alert("Please rate each goal on importance and ease of achievement.");
	return false;
}


   if(goalcount<4) {
    alert("Please enter at least four specific goals.");
	return false;
   }


   if(nogoal==true) {
    alert("Please enter a goal wherever you have entered an importance/achievement rating.");
	return false;
   }


 return true;

}

function checkPriority() {
 var el = document.forms[1].elements;
 for(var i = 0 ; i < el.length ; ++i) {
  if(el[i].type == "radio") {
   var radiogroup = el[el[i].name]; // get the whole set of radio buttons.
   var itemchecked = false;
   for(var j = 0 ; j < radiogroup.length ; ++j) {
    if(radiogroup[j].checked) {
	 itemchecked = true;
	 break;
	}
   }
   if(!itemchecked) {
    alert("Please rate each pair of statements.");
    if(el[i].focus)
     el[i].focus();
	return false;
   }
  }
 }
 return true;
}


function updateTotalValues(CheckBox) {
	var Total = parseInt(document.form1.TotalValues.value)
	if (CheckBox.checked) {
		if (Total==7) {
			alert("Choose a maximum of 7 goals")
			CheckBox.checked = false;
			return false;
		}
		document.form1.Comparisons.value = parseInt(document.form1.Comparisons.value) + Total
		document.form1.TotalValues.value++; 
	} else {
		document.form1.TotalValues.value--;
		document.form1.Comparisons.value = parseInt(document.form1.Comparisons.value) - Total+1
	}
}





function savePage(filename) {

	verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr);


	if (app.indexOf('Microsoft') != -1) {

		document.execCommand('SaveAs',false,filename);
	} else
	{
	
		alert("Please select SAVE AS  from the FILE menu to save a copy of this page on your computer");
	}
	
}	


function printPage() {

	print();
	
}	



function validateFeedback() {
	
	msg1="";
	msg2="";
	
	if (document.form1.value[0].checked || document.form1.value[1].checked || document.form1.value[2].checked || document.form1.value[3].checked ) 
	{
		msg1="";
	} else
	{
		msg1="Enter a value rating\n";
	}

	if (document.form1.comment.value=="") 
	{
		msg2="Enter a comment\n";
	}
	
	
	if (msg1 || msg2) {
	
		alert("Error:\nPlease complete all required fields.\n\n"+msg1+msg2);
		return false;
	}	
	else
	{
		document.form1.submit();	
	}

}
