function WriteFlash () {
 s = "";
 if (navigator.userAgent.indexOf("MSIE") != -1) {
  s = s + ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="660" height="300">');
 } else {
  s = s + ('<object data="images/flash/cps.swf" width="660" height="300" type="application/x-shockwave-flash">');
 }
 s = s + ('<param name="movie" value="images/flash/cps.swf" />');
 s = s + ('<param name="quality" value="high" />');
 s = s + ('<param name="bgcolor" value="#FFFFFF" />');
 s = s + ('<param name="menu" value="false" />');
 s = s + ('<p>&nbsp;</p>');
 s = s + ('<p style="text-align: center;">This browser does not have a Flash Plug-in.<br />');
 s = s + ('<b><a href="http://www.macromedia.com/go/getflashplayer">Get the latest Flash Plug-in here</a></b></p>');
 s = s + ('</object>');
 document.write (s);
} 

                                             
function FlashCircleDiagram (strFile, strID, intWidth, intHeight, arParams, strAltHTML)
{
	if (navigator.userAgent.indexOf("MSIE") != -1) {
		document.write ('<object id="'+strID+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
		document.write ('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"');
		document.write ('width="'+intWidth+'"');
		document.write ('height="'+intHeight+'">');
	} else {
		document.write ('<object id="'+strID+'" data="'+strFile+'"');
		document.write ('width="'+intWidth+'"');
		document.write ('height="'+intHeight+'"');
		document.write ('type="application/x-shockwave-flash">');
	}
	if (arParams) {
		for (x in arParams) {
			keyvalue = arParams[x].split(":",2);
			document.write('<param name="' +keyvalue[0]+ '" value="' + keyvalue[1] + '" />');
		}
	}
	document.write ('<param name="movie" value="' + strFile + '" />');
	if (strAltHTML) document.write(strAltHTML);
	document.write ('</object>');
}



function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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 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_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 preloadmyimages(){
MM_preloadImages('images/layout/slices/intake_storage_f2.jpg','images/layout/slices/intake_storage_fill.jpg','images/layout/slices/process_design_fill.jpg','images/layout/slices/mixing_blending_fill.jpg','images/layout/slices/project_fill.jpg','images/layout/slices/heat_treat_fill.jpg','images/layout/slices/auto_fill.jpg','images/layout/slices/system_integration_fill.jpg','images/layout/slices/separate_fill.jpg','images/layout/slices/constructions_fill.jpg','images/layout/slices/process_storage_fill.jpg','images/layout/slices/hygenic_fill.jpg','images/layout/slices/cleaning_fill.jpg','images/layout/slices/after_sales_fill.jpg');
}


function clearField(obj, text)
{
	if (obj.value == text) obj.value = '';
}

function fillField(obj, text)
{
	if (obj.value == '') obj.value = text;
}

function eValidate(){
		
		filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		useremail = document.getElementById('email').value;
		
		if (filter.test(useremail)){
		//return true;
		}else{
			alert("Please input a valid email address!");
			return false;
		}
}

function contact_validate(){
		test = new Array(6);
		test[0] = document.getElementById('email').value;
		test[1] = document.getElementById('firstname').value;
		test[2] = document.getElementById('lastname').value;
		test[3] = document.getElementById('company').value;
		
		eValidate();
		
		for (i in test){
			if (test[i] == ''){
				alert ('You must supply a name, address, company and email address!');	
				return false;
			}
		}
		
		
		return true;
		
	
}

function goFocus(obj)
{
	obj.focus();
}


function fixLayout() {
	
	
	
	//if (!false) {
		
		//document.write("Test worked");
		
		var	winwidth = window.innerWidth;   //$(window).width();
		var	winheight = window.innerHeight; //$(window).height();
		var widthlimit = 960;
		var backlimit = 700;
		var backwidth = 1920;
		var back_x = "center";
		var back_y = 100;
		var page_y = 0;
		var move = 0;
		var movemax = 100;
		if (winwidth < widthlimit) back_x = 0 - ((backwidth - widthlimit) / 2) + "px";
		if (winheight > backlimit) move = winheight - backlimit;
		if (move > movemax) move = movemax;
		
		document.getElementById("outerDiv").style.marginTop=page_y+move;   //css("margin-top",page_y+move);//$("#Layout").css("margin-top",page_y+move);
		if (winwidth < widthlimit) {
			document.getElementById("outerDiv").style.marginLeft="0px";  //css.("margin-left","0");
			document.getElementById("outerDiv").style.left="50%";                       // css("left","0");
			document.getElementById("outerDiv").style.marginTop= "80px";
		} else {
			document.getElementById("outerDiv").style.marginLeft="-480px" ;            //css("margin-left","-480px");
			document.getElementById("outerDiv").style.left="50%";    
			document.getElementById("outerDiv").style.marginTop="80px";//css("left","50%");
		}
		//document.getElementById(body).style.backgroundPosition=back_x + " " + (0-back_y+move)+"px"                //css({ backgroundPosition: back_x + " " + (0-back_y+move)+"px" });
		document.body.style.backgroundPosition=back_x + " " + (0-back_y+move)+"px";
	//}
}

//function changeStyle()
//{
//   document.write("test");
 //  document.getElementById("menuItem1").style.backgroundColor="#6EC6F0";
//}

//function menuBg()
//{
//	 document.write("test");
  //var url = 
 
//}

function changeStyle(pcode)
{
	//document.write(pcode);
	switch(pcode)
	{
	case "": 
	  document.getElementById("menuItem1").style.backgroundColor="#6EC6F0";
	  document.getElementById("processId").style.color="#FFFFFF";
	  break;   
	  
	case "intake_storage": 
	  document.getElementById("menuItem1").style.backgroundColor="#6EC6F0";
	  document.getElementById("processId").style.color="#FFFFFF";
	  break; 
	  
	  case "mixing_blending": 
	  document.getElementById("menuItem1").style.backgroundColor="#6EC6F0";
	  document.getElementById("processId").style.color="#FFFFFF";
	  break; 
	  
	  case "heat_treatment": 
	  document.getElementById("menuItem1").style.backgroundColor="#6EC6F0";
	  document.getElementById("processId").style.color="#FFFFFF";
	  break; 
	  
	  case "separation_homogenisation": 
	  document.getElementById("menuItem1").style.backgroundColor="#6EC6F0";
	  document.getElementById("processId").style.color="#FFFFFF";
	  break; 
	  
	  case "process_vessels": 
	  document.getElementById("menuItem1").style.backgroundColor="#6EC6F0";
	  document.getElementById("processId").style.color="#FFFFFF";
	  break; 
	  
	  case "cleaning_in_place": 
	  document.getElementById("menuItem1").style.backgroundColor="#6EC6F0";
	  document.getElementById("processId").style.color="#FFFFFF";
	  break; 
	  
	  
	  
	  
	  

	  
	case "services": 
	document.getElementById("menuItem2").style.backgroundColor="#A40000";
	 document.getElementById("servicesId").style.color="#FFFFFF";
	break;
	
	case "process_design": 
	document.getElementById("menuItem2").style.backgroundColor="#A40000";
	 document.getElementById("servicesId").style.color="#FFFFFF";
	break;
	
	case "project_management": 
	document.getElementById("menuItem2").style.backgroundColor="#A40000";
	 document.getElementById("servicesId").style.color="#FFFFFF";
	break;
	
	case "automation_and_control": 
	document.getElementById("menuItem2").style.backgroundColor="#A40000";
	 document.getElementById("servicesId").style.color="#FFFFFF";
	break;
	
	case "construction_and_management": 
	document.getElementById("menuItem2").style.backgroundColor="#A40000";
	 document.getElementById("servicesId").style.color="#FFFFFF";
	break;
	
	case "hygienic_fabrication": 
	document.getElementById("menuItem2").style.backgroundColor="#A40000";
	 document.getElementById("servicesId").style.color="#FFFFFF";
	break;
	
	case "after_sales_service": 
	document.getElementById("menuItem2").style.backgroundColor="#A40000";
	 document.getElementById("servicesId").style.color="#FFFFFF";
	break;
	
	
	
	
	
	
	
	
	case "newslist": 
	{
	 document.getElementById("menuItem3").style.backgroundColor="#FF7D17";
	 document.getElementById("newsId").style.color="#FFFFFF";
	}
	break;
	
	case "newsarticle": 
	{
	 document.getElementById("menuItem3").style.backgroundColor="#FF7D17";
	 document.getElementById("newsId").style.color="#FFFFFF";
	}
	break;
	
	
	
	
	case "literature":
	document.getElementById("menuItem4").style.backgroundColor="#00782C";
	 document.getElementById("literatureId").style.color="#FFFFFF";
	break;
	
	
	case "cps_today": 
	document.getElementById("menuItem5").style.backgroundColor="#0C76C4";
	 document.getElementById("aboutusId").style.color="#FFFFFF";
	break;
	
	case "company_history": 
	document.getElementById("menuItem5").style.backgroundColor="#0C76C4";
	 document.getElementById("aboutusId").style.color="#FFFFFF";
	break;
	
	
	case "links": 
	document.getElementById("menuItem6").style.backgroundColor="#EA0000";
	 document.getElementById("linksId").style.color="#FFFFFF";
	break;
	case "contact_details": 
	document.getElementById("menuItem7").style.backgroundColor="#D96300";
	 document.getElementById("contactusId").style.color="#FFFFFF";
	break;
	  case "key_personnel": 
	document.getElementById("menuItem7").style.backgroundColor="#D96300";
	 document.getElementById("contactusId").style.color="#FFFFFF";
	break;
	case "location": 
	document.getElementById("menuItem7").style.backgroundColor="#D96300";
	 document.getElementById("contactusId").style.color="#FFFFFF";
	break;
	 
	  
	default:  
	 // document.getElementById("menuItem1").style.backgroundColor="#6EC6F0";
	}
}
	//document.write(pcode);
	
/* if ( pcode == "home" )
		{
		    
		   document.getElementById("menuItem1").style.backgroundColor="#6EC6F0";
		}
		
		else if ( pagecode == "services" )
		{
		    
		   document.getElementById("menuItem2").style.backgroundColor="#6EC6F0";
		}
		else if ( pagecode == "newslist" )
		{
		   
		   document.getElementById("menuItem3").style.backgroundColor="#FF7D17";
		}
		else if ( pagecode == "home" )
		{
		    
		   document.getElementById("menuItem4").style.backgroundColor="#6EC6F0";
		}
		else if ( pagecode == "home" )
		{
		    
		   document.getElementById("menuItem5").style.backgroundColor="#6EC6F0";
		}
		else if ( pagecode == "home" )
		{
		   
		   document.getElementById("menuItem6").style.backgroundColor="#6EC6F0";
		}
		else if ( pagecode == "home" )
		{
		    
		   document.getElementById("menuItem7").style.backgroundColor="#6EC6F0";
		}

} */

