var newWindow;
var Quadrilateral = "1"
var Round="2";
var FF06="3";
var FF09="4";
var Serrated="5";
var Shouldering="59";
var FaceMilling="61";
var Plunging="131";
var InternalCircularMilling="62";
var ExternalCircularMilling="63";
var SlotMilling="64";
//**********************************************************
function openPicture()
	{
	var  Picture;
	var Title;
	var selInd=document.getElementById("applications").selectedIndex;
	var selIndInsert=document.getElementById("inserttype").selectedIndex;
	if(document.getElementById("applications")[selInd].value=="aFullImmersion")
		{
		//start
		Title="Full Imemersion";
	
		if(document.getElementById("inserttype")[selIndInsert].value=="1")//generalShape
		 	{
			Picture='images/big/Full-Immersion.jpg';
			var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
			window.open(Url,"","menubar=no,width=600,height=400");
			return;
		 	 }
 		else
 			if(document.getElementById("inserttype")[selIndInsert].value==Round)//round
 	 			{
 	 			
 	 			Picture='images/big/RoundInsertFull.jpg';
				var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
				window.open(Url,"","menubar=no,width=600,height=400");
				return;
 	 			}
 	 		else
 				if(document.getElementById("inserttype")[selIndInsert].value==Serrated)
 				{
 	 			
 	 			Picture='images/big/SerrattedInsertFull.jpg';
				var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
				window.open(Url,"","menubar=no,width=600,height=400");
				return;
 	 			}
 	 		else
 	 			
 	 				{
 	 				Picture='images/big/FFWOMTFull.jpg';
					var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
					window.open(Url,"","menubar=no,width=600,height=400");
					return;
					}
 	 			
 	 			
		}
	if(document.all.applications[selInd].value==Shouldering)
		{
		Title="Shouldering";
		if(document.getElementById("inserttype")[selIndInsert].value=="1")//generalShape
		 	{
			Picture='images/big/Shouldering.jpg';
			var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
			window.open(Url,"","menubar=no,width=600,height=400");
			return;
		 	
		 	 }
 		else
 			if(document.getElementById("inserttype")[selIndInsert].value==Round)//round
 	 		{
 	 		Picture='images/big/RoundInsertS.jpg';
			var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
			window.open(Url,"","menubar=no,width=600,height=400");
			return;
 	 		}
 	 		else
 				if(document.getElementById("inserttype")[selIndInsert].value==Serrated)//seraated
 				{
 	 			
 	 			Picture='images/big/SerrattedInsertS.jpg';
				var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
				window.open(Url,"","menubar=no,width=600,height=400");
				return;
 	 			
 	 			}
 	 			else
 	 			
 	 				{
 	 				Picture='images/big/FFWOMTS.jpg';
					var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
					window.open(Url,"","menubar=no,width=600,height=400");
					return;
					}
 	 			
		}//end shouldering
	if(document.all.applications[selInd].value==FaceMilling)
		{
		Title="Face Milling";
		if(document.getElementById("inserttype")[selIndInsert].value=="1")//generalShape
		 	{
			Picture='images/big/Face-Milling.jpg';
			var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
			window.open(Url,"","menubar=no,width=600,height=400");
			return;	 
		 	
		 	 }
 		else
 			if(document.getElementById("inserttype")[selIndInsert].value==Round)//round
 	 		{
 	 		Picture='images/big/RoundInsertFace.jpg';
			var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
			window.open(Url,"","menubar=no,width=600,height=400");
			return;
 	 		}
 	 		else
 				if(document.getElementById("inserttype")[selIndInsert].value==Serrated)//seraated
 					{
 	 			
 	 				Picture='images/big/SerrattedInsertFace.jpg';
					var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
					window.open(Url,"","menubar=no,width=600,height=400");
					return;
 	 				}
 	 			else
 	 			
 	 				{
 	 				Picture='images/big/FFWOMTFace.jpg';
 	 				var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
					window.open(Url,"","menubar=no,width=600,height=400");
					return;
					
					}
		
		}//end face milling
		if(document.all.applications[selInd].value==InternalCircularMilling)
		{
		Title="Internal Circular Milling";
		if(document.getElementById("inserttype")[selIndInsert].value=="1")//generalShape
		 	{
			Picture='images/big/Internal_Milling_large.jpg';
			var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
			window.open(Url,"","menubar=no,width=600,height=400");
			return;	 
		 	
		 	 }
 		else
 			if(document.getElementById("inserttype")[selIndInsert].value==Round)//round
 	 		{
 	 		Picture='images/big/Internal_Milling_Round_large.jpg';
			var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
			window.open(Url,"","menubar=no,width=600,height=400");
			return;
 	 		}
 	 		else
 				if(document.getElementById("inserttype")[selIndInsert].value==Serrated)//seraated
 					{
 	 			
 	 				Picture='images/big/Internal_Milling_Serrated_large.jpg';
					var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
					window.open(Url,"","menubar=no,width=600,height=400");
					return;
 	 				}
 	 			else
 	 			
 	 				{
 	 				Picture='images/big/Internal_Milling_Feed_Mill_large.jpg';
 	 				var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
					window.open(Url,"","menubar=no,width=600,height=400");
					return;
					
					}
		
		}//end internal
		if(document.all.applications[selInd].value==ExternalCircularMilling)
		{
		Title="External circular Milling";
		if(document.getElementById("inserttype")[selIndInsert].value=="1")//generalShape
		 	{
			Picture='images/big/External_Milling_large.jpg';
			var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
			window.open(Url,"","menubar=no,width=600,height=400");
			return;	 
		 	
		 	 }
 		else
 			if(document.getElementById("inserttype")[selIndInsert].value==Round)//round
 	 		{
 	 		Picture='images/big/External_Milling_Round_large.jpg';
			var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
			window.open(Url,"","menubar=no,width=600,height=400");
			return;
 	 		}
 	 		else
 				if(document.getElementById("inserttype")[selIndInsert].value==Serrated)//seraated
 					{
 	 			
 	 				Picture='images/big/External_Milling_Serrated_large.jpg';
					var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
					window.open(Url,"","menubar=no,width=600,height=400");
					return;
 	 				}
 	 			else
 	 			
 	 				{
 	 				Picture='images/big/External_Milling_Feed_large.jpg';
 	 				var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
					window.open(Url,"","menubar=no,width=600,height=400");
					return;
					
					}
		
		}//end external
		if(document.all.applications[selInd].value==SlotMilling)
		{
		Title="Slot Milling";
		if(document.getElementById("inserttype")[selIndInsert].value=="1")//generalShape
		 	{
		 	if(document.getElementById("slotradio1").checked)
				Picture='images/big/STRAIGHT_GROOVE_large.jpg';
			else
				Picture='images/big/T_SLOT_large.jpg';
			var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
			window.open(Url,"","menubar=no,width=600,height=400");
			return;	 
		 	
		 	 }
 		else
 			if(document.getElementById("inserttype")[selIndInsert].value==Round)//round
 	 		{
 	 		if(document.getElementById("slotradio1").checked)
				Picture='images/big/STRAIGHT_GROOVE_ROUND_large.jpg';
			else
				Picture='images/big/T_SLOT_ROUND_large.jpg';
			var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
			window.open(Url,"","menubar=no,width=600,height=400");
			return;
 	 		}
 	 		else
 				if(document.getElementById("inserttype")[selIndInsert].value==Serrated)//seraated
 					{
 	 			
 	 				if(document.getElementById("slotradio1").checked)
						Picture='images/big/STRAIGH_GROOVE_SERRATED_large.jpg';
					else
						Picture='images/big/T_SLOT_SERRATED_large.jpg';
					var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
					window.open(Url,"","menubar=no,width=600,height=400");
					return;
 	 				}
 	 			
		
		}//end slot
	if(document.all.applications[selInd].value==Plunging)
		{Picture='images/big/Plunging.jpg';
		Title="Side Plunging";
		var Url="Picture.jsp?Picture=" + Picture + "&Title="+ Title;
		window.open(Url,"","menubar=no,width=620,height=400");
		return;
		}
		
}
//**********************************************************
function msetPicture()
{
	
	
//	if(document.all.applications.value=="aFullImmersion")
//		{
//		//start
//		
//		if(document.all.inserttype[0].value=="1")//generalShape
//		 	{
//			document.all.aApplicationImg.src='images/full-immersion.jpg';
//			
//			return; 	 
//		 	
//		 	 }
// 		else
// 			if(document.all.inserttype[0].value==Round)//round
// 	 			{
// 	 			document.all.aApplicationImg.src='images/RoundInsertFull.jpg';
//				return;
// 	 			}
// 	 		else
// 				if(document.all.inserttype[0].value==Serrated)//seraated
// 				{
// 	 			
// 	 			document.all.aApplicationImg.src='images/SerrattedInsertFull.jpg';
//				return;
// 	 			}
// 	 		else
// 	 			
// 	 				{
// 	 				document.all.aApplicationImg.src='images/FFWOMTFull.jpg';
//					return;
//					}
// 	 			
// 	 			
//		}
//		
//	if(document.all.applications.value==Shouldering)
//		{
//		if(document.all.inserttype[0].value=="1")//generalShape
//		 	{
//			document.all.aApplicationImg.src='images/shouldering.jpg';
//			return; 	 
//		 	
//		 	 }
// 		else
// 			if(document.all.inserttype[0].value==Round)//round
// 	 		{
// 	 		document.all.aApplicationImg.src='images/RoundInsertS.jpg';
//			return;
// 	 		}
// 	 		else
// 				if(document.all.inserttype[0].value==Serrated)//seraated
// 				{
// 	 			
// 	 			document.all.aApplicationImg.src='images/SerrattedInsertS.jpg';
//				return;
// 	 			
// 	 			
// 	 			}
// 	 			else
// 	 			
// 	 				{
// 	 				document.all.aApplicationImg.src='images/FFWOMTS.jpg';
//					return;
//					}
// 	 			
//		}//end shouldering
//	if(document.all.applications.value==FaceMilling)
//		{
//		if(document.all.inserttype[0].value=="1")//generalShape
//		 	{
//			document.all.aApplicationImg.src='images/face-milling.jpg';
//			return; 	 
//		 	
//		 	 }
// 		else
// 			if(document.all.inserttype[0].value==Round)//round
// 	 		{
// 	 		document.all.aApplicationImg.src='images/RoundInsertFace.jpg';
//			return;
// 	 		}
// 	 		else
// 				if(document.all.inserttype[0].value==Serrated)//seraated
// 					{
// 	 			
// 	 				document.all.aApplicationImg.src='images/SerrattedInsertFace.jpg';
//					return;
// 	 			
// 	 			
// 	 				}
// 	 			else
// 	 			
// 	 				{
// 	 				document.all.aApplicationImg.src='images/FFWOMTFace.jpg';
//					return;
//					}
//		
//		}//end face milling
//	if(document.all.applications.value==Plunging) ///aSidePlunging
//		{
//		document.all.aApplicationImg.src='images/Plunging.jpg';
//			return;
//		}
		
}

function mSelectApplication()
{


var location="";

var applicationName=(document.getElementById("applications").value);

	if(typeof(document.all.aApplicationImg)== "object")
	{
	 	
	   	if(applicationName=="aFullImmersion")//aFullImmersion
	  	{
	  		
	  		location=mSelect_InsertType(applicationName);
	  		
		  	//document.all.aApplicationImg.src='images/small/Full-Immersion.jpg';
		    document.all.inserttype.disabled=false;
		  	
		  
	       
		  
		  	
	  	}
	  	else
	  	if(applicationName==Shouldering)//aShouldering
	  	{
	  		location=mSelect_InsertType(applicationName);
	  		//document.all.aApplicationImg.src='images/small/Shouldering.jpg';
	  		document.all.inserttype.disabled=false; 
	  		
	  		
	  	}
	  	else
	  	if(applicationName==FaceMilling)//aFaceMilling
	  	{
	  		
		 	//document.all.aApplicationImg.src='images/small/face-milling.jpg';	
		 	location=mSelect_InsertType(applicationName);	
		 	document.all.inserttype.disabled=false;  	
		 
	  	}
	  	else
	  	if(applicationName==InternalCircularMilling)//internal
	  	{
	  		
		 	//document.all.aApplicationImg.src='images/small/Shouldering.jpg';	
		 	
		 	location=mSelect_InsertType(applicationName);	
		 	document.all.inserttype.disabled=false;  	
		 
	  	}
	  	else
	  	if(applicationName==ExternalCircularMilling)//external
	  	{
	  		
		 	//document.all.aApplicationImg.src='images/small/Shouldering.jpg';	
		 	location=mSelect_InsertType(applicationName);	
		 	document.all.inserttype.disabled=false;  	
		 
	  	}
	  	else
	  	if(applicationName==SlotMilling)//external
	  	{
	  		
		 	//document.all.aApplicationImg.src='images/small/Shouldering.jpg';	
		 	location=mSelect_InsertType(applicationName);
		 	
		 	document.all.inserttype.disabled=false;  	
		 
	  	}
	  	else
	  	if(applicationName==Plunging)//aSidePlunging
	  	{
	  	
	  		//document.all.aApplicationImg.src='images/small/Plunging.jpg';	
	  		document.all.inserttype.disabled=true;
			var srcHeight=screen.height;
			var srcWidth=screen.width;
			var defaultWidth= 1024;
			var bigResultion="false";
			if(srcWidth==defaultWidth || srcHeight==defaultHeight)
				bigResultion="true";	  		
	  		var ref=keepValue();
	  		var unit_type= document.all.clickUnits.value;
			var home=(document.getElementById("home").value)
	  		location="Main.jsp?Parameters=Module=ML&Application=" + 
	  			applicationName +"&" + ref + "&Home=" + home ;
	  		
			location+="&unittype=" + unit_type + "&Module=ML&Application=" + 
	  			applicationName ;  		
			
 	 		document.getElementById("submitaction").action=location; 		
	  		
			document.getElementById("submitaction").submit();
			
			
	  	}
	
	  	
  }
 
}

//***********************************************
function mSelect_InsertType(applicationName)
{
	
	
	applicationName=document.getElementById("applications").value;

var doc=document.all;
var srcHeight=screen.height;
var srcWidth=screen.width;
var defaultWidth= 1024;
var bigResultion="false";
if(srcWidth==defaultWidth || srcHeight==defaultHeight)
	bigResultion="true"	 ; 

var selInsertInd=document.getElementById("inserttype").selectedIndex

var ref=keepValue();

var location;

 var home=(document.getElementById("home").value)
 
 if(document.getElementById("inserttype")[selInsertInd].value==Quadrilateral)//generalShape
 	{
 	
 	 location="Main.jsp?Parameters=Module=ML&Application=" + applicationName + 
 	 	"&InsertType=1&" + ref + 
 	 	"&Module=ML&Application=" + applicationName  ;
 	
 	 }
 	else
 		if(document.getElementById("inserttype")[selInsertInd].value==Round)//round
 	 		{
 	 		location="Main.jsp?Parameters=Module=ML&Application=" 
 	 		+ applicationName + "&InsertType=" + Round +"&" + ref + 
 	 		"&Module=ML&Application=" + applicationName;
 	 		
 	 		}
 	 	else
 			if(document.getElementById("inserttype")[selInsertInd].value==Serrated)//seraated
 			{
 	 			
 	 			location="Main.jsp?Parameters=Module=ML&Application=" 
 	 		+ applicationName + "&InsertType=" + Serrated + "&" + ref + 
 	 		"&Module=ML&Application=" + applicationName;
 	 			
 	 			
 	 		}
 	 		else
 	 			if(document.getElementById("inserttype")[selInsertInd].value==FF06)//FF WOMT-06 OR FF WOMT-09
 	 				location="Main.jsp?Parameters=Module=ML&Application=" 
 	 				+ applicationName + "&InsertType=" + FF06 +"&" + ref + 
 	 				"&Module=ML&Application=" + applicationName;
 	 				
 	 			else
 	 				if(document.getElementById("inserttype")[selInsertInd].value==FF09)//FF WOMT-06 OR FF WOMT-09
 	 					location="Main.jsp?Parameters=Module=ML&Application=" 
 	 					+ applicationName + "&InsertType=" + FF09+ "&" + ref + 
 	 					"&Module=ML&Application=" + applicationName;
 	 				
 	 	
 	 	
 	 	var unit_type= document.getElementById("clickUnits").value;
 	 	
 	 	location+="&unittype=" + unit_type;
 		location+= "&Home=" + home ;
 	 	document.getElementById("submitaction").action=location;
 	 	
		
		document.getElementById("submitaction").submit();
	
		
		
		
 	return location;
 	
 		
}
function mGetCuttingVelocity(val,unittype)
{
	
	var Diam=document.getElementById("tooldiameter").value;
	
	 //if(typeof(document.getElementById("aUnits"))== "object")
	 //{
	//	 if(document.getElementById("aUnits").value==" inch " || document.getElementById("aUnits").value=="inch" || document.getElementById("unittype").value==" inch " || document.getElementById("unittype").value=="inch")
	//	 	Diam=Diam*25.4*3.2808;
	//}
	
	if(document.getElementById("tooldiameter_lable").innerHTML=="inch")
		Diam=Diam*25.4*3.2808;
	
	
	return mRound(Math.PI* Diam* val/1000,1);
}
//***********************************************
function mUpdateCuttingVelocity(num)
{

 var d=document.all;

 if(typeof(document.getElementById("tooldiameter"))=="object")
 {
	 var Diam=document.getElementById("tooldiameter").value;
	
	 if(typeof(document.getElementById("aUnits"))== "object")
	 {
		
		 if(document.getElementById("unittype").value==" inch " || document.getElementById("unittype").value=="inch" || 
		 	document.getElementById("aUnits").value==" inch " || document.getElementById("aUnits").value=="inch")
		 	{
		 	
		 	Diam=Diam*25.4*3.2808;
		 	}
		 if(document.getElementById("tooldiameter").value=="")
		 	{
		 	alert("You should first type ToolDiameter");
		 	document.getElementById("cuttingvelocity").value="";
		 	document.getElementById("spindelspeed").value="";
		 	}
		 else
		 	{
				if(num==1)
				{
					if(document.getElementById("spindelspeed").value!='')
					{
						
						document.getElementById("cuttingvelocity").value=mRound(Math.PI* Diam* document.getElementById("spindelspeed").value/1000,1) ;
						document.getElementById("cutting_velocity").value=document.getElementById("cuttingvelocity").value;
						document.getElementById("spindel_speed").value=document.getElementById("spindelspeed").value;
						
					}
				}
				else//num=2
				{
					if(document.getElementById("cuttingvelocity").value!='')
						{
							document.getElementById("spindelspeed").value=mRound((document.getElementById("cuttingvelocity").value*1000)/(Math.PI * Diam),1);
							document.getElementById("spindel_speed").value=document.getElementById("spindelspeed").value;
							document.getElementById("cutting_velocity").value=document.getElementById("cuttingvelocity").value;
						}
				}
			}
		}
	}
	
}

function mUpdateCuttingVelocitywithUnit(num,UnitType)
{

 var d=document.all;

 //if(typeof(document.getElementById("tooldiameter"))=="object")
 {
	 var Diam=document.getElementById("tooldiameter").value;
	
	// if(typeof(document.getElementById("aUnits"))== "object")
	 {
		
		// if(document.getElementById("unittype").value==" inch " || document.getElementById("unittype").value=="inch" || 
		// 	document.getElementById("aUnits").value==" inch " || document.getElementById("aUnits").value=="inch")
		     if(UnitType=="inch")
		 	{
		 	
		 	Diam=Diam*25.4*3.2808;
		 	}
		 if(document.getElementById("tooldiameter").value=="")
		 	{
		 	alert("You should first type ToolDiameter");
		 	document.getElementById("cuttingvelocity").value="";
		 	document.getElementById("spindelspeed").value="";
		 	}
		 else
		 	{
				if(num==1)
				{
					if(document.getElementById("spindelspeed").value!='')
					{
						
						document.getElementById("cuttingvelocity").value=mRound(Math.PI* Diam* document.getElementById("spindelspeed").value/1000,1) ;
						document.getElementById("cutting_velocity").value=document.getElementById("cuttingvelocity").value;
						document.getElementById("spindel_speed").value=document.getElementById("spindelspeed").value;
					}
				}
				else//num=2
				{
					if(document.getElementById("cuttingvelocity").value!='')
						{
							document.getElementById("spindelspeed").value=mRound((document.getElementById("cuttingvelocity").value*1000)/(Math.PI * Diam),1);
							document.getElementById("spindel_speed").value=document.getElementById("spindelspeed").value;
							document.getElementById("cutting_velocity").value=document.getElementById("cuttingvelocity").value;
						}
				}
			}
		}
	}
}
//***********************************************
function mSetDisable()
{
	if(typeof(document.all.applications)== "object")
	{
		
		if(document.all.applications[0].value=="aFullImmersion")//fullimmersion
			document.all.cuttingwidth.disabled=true;
		else
			document.all.cuttingwidth.disabled=false; 
			
		if(!document.all.inserttype[0].value==FF06 && !
			document.all.inserttype[0].value==FF09)
		 {
		 if(document.all.applications[0].value==FaceMilling)//face miiling
			document.all.eccentricity.disabled=false;
		else
			document.all.eccentricity.disabled=true; 
		}
	}
	
}

//***********************************************
function mSetApplication()
{
	//alert(parent.MainMachiningPower.document.all);
	
	if(typeof(document.all.application)== "object")
	{
		
		if(document.all.applications[0].value=="aFullImmersion")//fullimmersion
			document.all.application.value="aFullImmersion";
		else
			if(document.all.applications[0].value==Shouldering)//aShouldering
				document.all.application.value=Shouldering;
			else
				if(document.all.applications[0].value==FaceMilling)//aFaceMilling
					document.all.application.value=FaceMilling;
				else
					if(document.all.applications[0].value==Plunging)//aSidePlungin
						document.all.application.value=Plunging;
		document.all.SelectedTabName.value="Milling";
		
		//mSetResult();
	}
}
//***********************************************
function mSetResult()	
{

	if(parent.MainMachiningPower.document.all.application.options[3].selected)//aSidePlungin
		location='MillingPlungingResult.jsp';
	else
		location='MillingResult.jsp';
	
		
}

//***********************************************
function mSetInsertType()
{
	
	if(typeof(document.all.inserttype)== "object")
	{
		if(document.all.inserttype[0].value==Quadrilateral)//generalShape
			document.all.inserttype.value="1";
		else
			if(document.all.inserttype[0].value=Round)//round
			document.all.inserttype.value=Round;
			else
				if(document.all.inserttype[0].value=Serrated)//serrated
			document.all.inserttype.value=Serrated;
				else
					if(document.all.inserttype[0].value=FF06)//aFF WOMT-06
						document.all.inserttype.value=FF06;
					else
						if(document.all.inserttype[0].value=FF09)//aFF WOMT-06
						document.all.inserttype.value=FF09;
	}			
}		
//***********************************************
function mSelectInsertType()
{
	var d=document.all;
	 //remove table
	 
	 var oNode=document.getElementById("tableInsertType");
	 if(oNode!=null)
     oNode.parentNode.removeChild(oNode);
    if(d.inserttype.options[0].selected || d.inserttype.options[1].selected || d.inserttype.options[2].selected )//  not FF WOMT-06 OR FF WOMT-09
	{
	  	
		var oDiv = document.getElementById("oDivInserttype");
	  	 //build new table
	     var oTable = document.createElement("TABLE");
	     oTable.setAttribute('id', "tableInsertType" );
	     oTable.setAttribute('width', "150%" );
	     var oTBody = document.createElement("TBODY");
	     oTable.appendChild(oTBody);
		if(d.inserttype.options[0].selected)
		{
			oTR = document.createElement("TR");
	        mAddTd('Effective rake angle  :','rakeangle',oTR);
	         oTBody.appendChild(oTR);
			
			oTR1 = document.createElement("TR");
	        mAddTd('Lead angle (k) :','leadangle',oTR1);
	        oTBody.appendChild(oTR1);
	         
			
		}
		if(d.inserttype.options[1].selected)//round
		{
			oTR = document.createElement("TR");
	        mAddTd('Effective rake angle  :','rakeangle',oTR);
	         oTBody.appendChild(oTR);
		  	
		  	oTR1 = document.createElement("TR");
	        mAddTd('Insert Diameter (d) :','insertdiameter',oTR1);
	         oTBody.appendChild(oTR1);
	  		
		}
		if(d.inserttype.options[2].selected)//sarated
		{
			oTR = document.createElement("TR");
	        mAddTd('Insert width (w) :','insertwidth',oTR);
	         oTBody.appendChild(oTR);
		  	
		  	oTR1 = document.createElement("TR");
	        mAddTd('Effective rake angle :','rakeangle',oTR1);
	         oTBody.appendChild(oTR1);
	         
	  		oTR2 = document.createElement("TR");
	        mAddTd('Lead angle (k) :','leadangle',oTR2);
	         oTBody.appendChild(oTR2);
		  	
		  	oTR3 = document.createElement("TR");
	        mAddTd('Max. depth of cut (_max) :','maxdepthofcut',oTR3);
	         oTBody.appendChild(oTR3);
		  		  	
			
		}
		
		oDiv.appendChild(oTable);	
	}
	
	
}
//**********************************************************

function mUpdateaCuttingWidthFrame()
{
	

	var selAppInd=document.getElementById("applications").selectedIndex
	if(document.all.applications[selAppInd].value=="aFullImmersion")
  	{
		
		document.all.cuttingwidth.value=document.all.tooldiameter.value;
		
		
  	}
  	if(document.all.spindelspeed.value!="")
	{
		if(document.all.radio1.checked)
  			mUpdateCuttingVelocity(1);
  		else
  			mUpdateCuttingVelocity(2);
  	}
}

function mUpdateaCuttingWidthFrameWithUnit(UnitType)
{
	
	
	
	if(document.all.applications[0].value=="aFullImmersion")
  	{
		
		document.all.cuttingwidth.value=document.all.tooldiameter.value;
		
		
  	}
  	if(document.all.spindelspeed.value!="")
	{
		if(document.all.radio1.checked)
  			mUpdateCuttingVelocitywithUnit(1,UnitType);
  		else
  			mUpdateCuttingVelocity(2,UnitType);
  	}
}

function setCuttingWidth1()
{
	
	document.all.cuttingwidth1.value=document.all.cuttingwidth.value;
	
}
function chkSel(num)
{

if(num==1)
	{
	document.getElementById("cuttingvelocity").disabled=true;
	document.getElementById("spindelspeed").disabled=false;
	}
else
	{
	document.getElementById("cuttingvelocity").disabled=false;
	document.getElementById("spindelspeed").disabled=true;
	}
}


function chkFSel(num)
{

if(num==2)
	{
	document.getElementById("feedpertooth").disabled=true;
	document.getElementById("hmax").disabled=false;
	}
else
	{
	document.getElementById("feedpertooth").disabled=false;
	document.getElementById("hmax").disabled=true;
	}
}
//*******************************************************************************************

function mRound(Original,NOD)
{
	return Math.round(Math.pow(10,NOD)*Original)/Math.pow(10,NOD);
	
}
//**********************************************************************************

function mValidateMillingForm(url,unittype)
{
	//alert(unittype)
	
	var d=document.all;
	var Unit=document.all.aUnits.value;
	//alert("Unit="+ Unit + ",unittype=" + unittype)
	
	//if(Unit!=unittype)
		unittype=Unit
	//document.getElementById("aUnits").value=unittype
	var RO;
	var selAppInd=document.getElementById("applications").selectedIndex
	var selInsertInd=document.getElementById("inserttype").selectedIndex
	
	if(unittype =="mm" || unittype ==" mm ")
		var asInc=1;//unit for inch/mm - update later
	else
		var asInc=25.4;
	
	
	 if( (document.getElementById("tooldiameter").value=="" || document.getElementById("numberofinsert").value == "" ||
	    	 document.getElementById("spindelspeed").value == "" ||  document.getElementById("materialtype").value == ""  ) )
	    	
	    {
	    	alert( "Some data fields were left empty");
	    	return false;
	    }
  
   if( document.getElementById("applications")[selAppInd].value!=Plunging) ///aSidePlunging 
    	{
	    	
	    	if(document.getElementById("feedpertooth").value == "" || document.getElementById("feedpertooth").value=="")
	    	{
	    		alert( "Some data fields were left empty");
	    		return false;
	    	}
	    	
    	}
    else
    {
    	
    	if(document.getElementById("feedperrevolution").value=="" || document.getElementById("predrilledholediameter").value=="")
	    	{
	    		alert( "Some data fields were left empty");
	    		return false;
	    	}
	 } 
	
	    if(document.getElementById("inserttype")[selInsertInd].value!=FF06 && document.getElementById("inserttype")[selInsertInd].value!=FF09)
	    {
	    	
	    	if(typeof(document.getElementById("eccentricity")=="object") & document.getElementById("eccentricity")!=null)
		    	{
		    	if(document.getElementById("eccentricity").value == "" && document.getElementById("applications")[selAppInd].value==FaceMilling)
		    	{
		    	alert( "Some data fields were left empty");
		    	return false;
		    	}
	    	}
	    }
	    
	     if( document.getElementById("applications")[selAppInd].value==InternalCircularMilling || 
	     		document.getElementById("applications")[selAppInd].value==ExternalCircularMilling) ///Circular milling
    	{
	    	
	    	if(document.getElementById("dw").value == "" || document.getElementById("stock").value=="")
	    	{
	    		alert( "Some data fields were left empty");
	    		return false;
	    	}
	    	
    	}
	//1.
	
	if(document.getElementById("inserttype")[selInsertInd].value==FF06 && parseFloat(document.getElementById("depthofcut").value) > mRound((1.5 / asInc),3))
   		{
   		
        alert("ap can not exceed " + mRound((1.5 / asInc), 3) + Unit);
        return false;
        }   
       
	//2.
	
	if(document.getElementById("inserttype")[selInsertInd].value==FF09 && parseFloat(document.getElementById("depthofcut").value) > mRound(2 / asInc))
   		{
        alert("ap can not exceed " + mRound((2 / asInc), 3) + Unit);
        return false;
        }
        
     //3.
   
    
     if(document.getElementById("inserttype")[selInsertInd].value==FF09 || document.getElementById("inserttype")[selInsertInd].value==FF06)
     {
  		
   		RO=mGetRWithUnit(unittype); 
   			
   				var selInd=document.getElementById("applications").selectedIndex
   				
				if(document.getElementById("applications")[selInd].value=="aFullImmersion")//aFullImmersion
				{
					
					document.getElementById("cuttingwidth1").value=mRound(2*RO,2);
					
					document.getElementById("cuttingwidth").value=mRound(2*RO,2);
					
					
					
				}	
				else //not fullimmersion
				    //alert(document.getElementById("cuttingwidth").value)
				   if( document.getElementById("applications")[selAppInd].value!=InternalCircularMilling  && 
        	 			document.getElementById("applications")[selAppInd].value!=ExternalCircularMilling)
        	 		{
						if(parseFloat(document.getElementById("cuttingwidth").value)> mRound(2 * RO,2))
						{
							alert("Cutting Width can not exceed " + mRound(2 * RO, 2) + Unit + " ,Input Cutting Width within the specified limit");
							
							 document.getElementById("cuttingwidth").value="";
							 document.getElementById("cuttingwidth1").value=""
							
							 return false;
						}
					}
		}	
	//4.
	
	if(document.getElementById("inserttype")[selInsertInd].value==Round)
        {var teta;
        var DOut;
      	if(document.getElementById("applications").value!=SlotMilling)
      	{
        teta=mGetTeta();
       
        DOut = mGetDOut(teta)
      
        if(document.getElementById("applications").value=="aFullImmersion")//aFullImmersion
          {	
          	
               document.getElementById("cuttingwidth").value= mRound(DOut, 2);
               document.getElementById("cuttingwidth1").value= mRound(DOut, 2);
               
              
          }
        else if( document.getElementById("applications")[selAppInd].value!=InternalCircularMilling  && 
        	 document.getElementById("applications")[selAppInd].value!=ExternalCircularMilling)
       	
           if(parseFloat(document.getElementById("cuttingwidth").value) > mRound(DOut, 2))
           		{
           		
               	alert("Cutting Width can not exceed " + mRound(DOut, 2) + Unit + 
               	 " ,Input Cutting Width within the specified limit");
               	
                 document.getElementById("cuttingwidth").value="";
                 document.getElementById("cuttingwidth1").value="";
                	return false;
            	}
            }
          }	     
     //5.
     if(parseFloat(document.getElementById("tooldiameter").value) <= 0)
    		{
        	alert("Tool diameter (D) must be positive");
        	return false;
        	}
     //6.
     if( document.getElementById("cuttingwidth")!=null &&  parseFloat(document.getElementById("cuttingwidth").value) <= 0 && 
    	document.getElementById("applications")[selAppInd].value!=InternalCircularMilling  && 
        	 document.getElementById("applications")[selAppInd].value!=ExternalCircularMilling ) 
     		{
        		
        	
        			alert("Cutting width (ae) must be positive");
        			return false;
        	
        	}
     //7.
    
     if (parseFloat(document.getElementById("numberofinsert").value) <= 0)
    		{
       			alert("Number of inserts (z) must be a positive integer");
       			return false;
       		}
     //8.
     
  	 if(document.getElementById("applications")[selAppInd].value!=Plunging)  ////aSidePlunging
  	 		
    		if(document.getElementById("inserttype")[selInsertInd].value!=Round && document.getElementById("applications")[selAppInd].value!=SlotMilling)
    		{
	    		if(parseFloat(document.getElementById("depthofcut").value)<= 0 )//not plunging
	       		{
	       		alert("Depth of cut (ap) must be positive");
	       		return false;
	       		}
       		}
       		
     //9.
     if(document.getElementById("inserttype")[selInsertInd].value==Serrated )//sarated
       		
       		{
	       		if(CheckAp())
	       		{
	         		alert( "Depth of cut (ap) must be greater than or equal to the (W-w)");
	         		return false;
	         	}
	         	
      		}
     //10.

     if(document.getElementById("inserttype")[selInsertInd].value==Serrated  )//sarated
   	   		{
	   	   		if(document.getElementById("applications")[selAppInd].value!=SlotMilling && 
	   	   			document.getElementById("applications")[selAppInd].value!=InternalCircularMilling && 
	   	   			document.getElementById("applications")[selAppInd].value!=ExternalCircularMilling)
	   	   		{
		   	   		if(parseFloat(document.getElementById("depthofcut").value) > parseFloat(document.getElementById("maxdepthofcut").value))  			
		   			 {
		        		alert("Depth of cut (ap) can not exceed Maximum depth of cut (ap_max)");
		        		return false;
		        	}
	        	}
        	}	
     //11.
     if(document.getElementById("inserttype")[selInsertInd].value==Serrated  && (document.getElementById("applications")[selAppInd].value!=SlotMilling && 
	   	   			document.getElementById("applications")[selAppInd].value!=InternalCircularMilling && 
	   	   			document.getElementById("applications")[selAppInd].value!=ExternalCircularMilling))//sarated
       {
      
       var val=document.getElementById("insertwidth").value * Math.sin(document.getElementById("leadangle").value * Math.PI / 180.0);
	       if( val< 
	   			document.getElementById("maxdepthofcut").value / 2.0 )//sarated
	        	{
	        	alert("Insert width (w) can not be less than  ap_max/2sinK");
	        	return false;
	        	}	
	  }
	//12.13
	if(document.getElementById("inserttype")[selInsertInd].value!=FF06 && document.getElementById("inserttype")[selInsertInd].value!=FF09)
     {
	    if(document.getElementById("rakeangle").value >50 || document.getElementById("rakeangle").value<-90 )
	      {
	      	alert("Rake angle must be less than or equal to 50 Deg.");
	    	return false;
	       }
       if(document.getElementById("inserttype")[selInsertInd].value!=Round)
       {
	       if(!LeadAngleCheck()) 
	       {
	       	alert("Lead angle (K) must be positive and less than or equal to 90 Deg.");
	     	return false;
	     	}
	     }
    } 
  
   //14.
 
   if(document.getElementById("inserttype")[selInsertInd].value==Round)
   
   {
   		if(!InsertDiameterCheck())
	       {
	       alert("Insert Diameter (d) must be greater than or equal to the depth of cut (ap)");
	       return false;
	      	}
	  }
     //15.
     if(document.getElementById("cuttingwidth")!=null && parseFloat(document.getElementById("tooldiameter").value) < parseFloat(document.getElementById("cuttingwidth").value) && 
     		document.getElementById("applications")[selAppInd].value!=InternalCircularMilling  && 
        	 document.getElementById("applications")[selAppInd].value!=ExternalCircularMilling) 
        {
        
        alert("The Tool Diameter (D) must be greater then ,or equal to the Cutting Width (ae)");
        return false;
        }  
     //16.
	
     if(document.getElementById("applications")[selAppInd].value==FaceMilling)
    {
	   	
	   	if( !EccentricityCheck(RO))
	   	{
	   	
				if(document.getElementById("inserttype")[selInsertInd].value!=FF06 && document.getElementById("inserttype")[selInsertInd].value!=FF09  && 
					document.getElementById("applications")[selAppInd].value!=InternalCircularMilling  && 
        			 document.getElementById("applications")[selAppInd].value!=ExternalCircularMilling)
				{
		       		
		       		if((document.getElementById("tooldiameter").value-document.getElementById("cuttingwidth").value)/2.0==0)
		            {
		               alert("Eccentricity value(e) is not possible for the current cutting geometry ");
		                document.getElementById("eccentricity").value =0;
		                return false;
		            }
		           else
		                {
		                	alert("Eccentricity value(e) must be less then or equal to (D-ae)/2 ");
		                	return false;
		                }
		         }
	     		else{
		            if(mRound(((2 * RO) -document.getElementById("cuttingwidth").value) / 2.0, 2) ==0)
		            {
		                alert("Eccentricity value(e) is not possible for the current cutting geometry ");
		                 document.getElementById("eccentricity").value =0;
		                 return false;
		                 }
		            else
		                {
		               
		                alert("Eccentricity (e) must be less than or equal to " + mRound((((2 * RO) - document.getElementById("cuttingwidth").value) / 2), 2));
		                return false;
		                }
		         }
	    }//
	   }
	 
	//17.
	
	 if(document.all.applications[selAppInd].value==Plunging)  ////aSidePlunging
	 {
   		if(parseFloat(document.getElementById("predrilledholediameter").value) < 0) //plunging
        {
        alert("Pre-drilled  hole diameter (d) must be positive ");
        return false;
        }
  	}      
   //18.
 
   if(typeof(document.getElementById("leadangle"))=="object" & document.getElementById("leadangle")!=null)
   {
   	
	   if(document.getElementById("leadangle").value!=""  ) 
	        {    
	        		if(parseFloat(document.getElementById("leadangle").value)<= 0)
	                {alert("Lead angle (K) can not be negative");
	                return false;
	                }
	            
	         }
	}
	
	//
	if( document.getElementById("applications")[selAppInd].value==InternalCircularMilling )
	{
		if(document.getElementById("dw").value==document.getElementById("tooldiameter").value)
		{
			alert("Tool diameter can't be equal to work-piece diameter")
				return ;
		}
		
	}
//

  var flag=false;
  //setGraphDisable(flag);

//return true;

if(document.getElementById("RFobj").value=="")
{
	
	document.getElementById("RFobj").value='50'
	}


var ref=keepValue(unittype);

url+="&" + ref;

updateSubmit(url);


document.getElementById("submitmill").value="yes"
var browserName=navigator.appName; 
if(document.getElementById("openPower").value=="1")
	{
	
	
	
	if(browserName=="Microsoft Internet Explorer")
		//mSetPowerGraph('calculate');
	document.getElementById("openPower").value=="1"
	}

if(document.getElementById("openSpindle").value=="1")
	{
	
	if(browserName=="Microsoft Internet Explorer")
	{
		
		//mSetGraph(document.getElementById("RFobj").value,document.all.applications[selAppInd].value);
	}
	document.getElementById("openSpindle").value=="1"
	}
	
return true;  
}
function setunitobj(val)
{
	alert((document.getElementById(unittype))==null)
	if((document.getElementById(unittype))!=null)
	{ 
		document.getElementById(unittype).value=val
		alert(val)
	}

}

function updateSubmit(url)
{
	
	//check if exist unittype & delete it
	/*var str = new String();
	
		
	
	var pos=0;
	pos=url.search(/&unittype=/)
	if(pos>0)
	{
		var length=url.length
		if(pos<length)
		{
		
		url=url.substr(0,pos)
		
		}
	}
	
	var unit_type= document.all.clickUnits.value
	url+="&unittype=" + unit_type;
	*/
	var unit_type= document.getElementById("aUnits").value;
	url+="&unittype=" + unit_type;
	
	document.getElementById("submitaction").action=url;
	
	document.getElementById("submitaction").submit();
}

//*********************************************************************************
function mGetDOut(teta)
{
	 
	var doc=document.all;
	var val=Math.sin(teta);
	
    var val=  document.getElementById("tooldiameter").value - document.getElementById("insertdiameter").value*(1-val);
  
   return val;
}
//******************************************************************************************
function mGetR0(D,b,w)
{
	
	alert(document.getElementById("inserttype").value)
	var d=document.all;
	var R0=0;
	if(document.getElementById("inserttype").options[3].selected)//aFF WOMT-06 
	{
		var Rc=D/2;
		var Ri=Rc-(7.06)
		var tmp=Math.asin((14.4-w)/14.4);
		R0= Ri+(14.4)*Math.cos(tmp);
	}
	else
	if(document.getElementById("inserttype").options[4].selected)//aFF WOMT-09
	{
		var Rc=D/2;
		var Ri=Rc-(10.41)
		var tmp= Math.asin((21.18-w)/21.18);
		 R0= Ri+(21.18)*Math.cos(tmp);
	}
		lR0=R0;
		
		return R0;
	
}
//**************************************************************
function mGetTeta()
{
	 var doc=document.all;
	//alert(document.getElementById("depthofcut").value)
	//alert(document.getElementById("insertdiameter").value)
   var ret= mArcCos((1 - (2 * document.getElementById("depthofcut").value / document.getElementById("insertdiameter").value)));
  
   return ret;
}
//**************************************************************
function mArcCos(num)
{
 var y;
 
    y = -num * num + 1;
    if(y < 0)
        return 0;
    y = Math.sqrt(y);
    if(y==0)
       return  0;
   else
        return Math.atan(-num / y) + 2 * Math.atan(1); 
 }


function mReplaceBackGround()
{
	setInterval("mChangeBackGround()",500);	
}

function mGetAe()
{
	var x=0
	var stock=0
	var dw=0
	var D=0  
	var hmax=0 
	var f=0
	var ae=0
	
	var selAppInd=document.getElementById("applications").selectedIndex
    
    var application=document.getElementById("applications")[selAppInd].value
    if(document.getElementById("stock")!=null)
		stock=document.getElementById("stock").value
	if(document.getElementById("dw")!=null)
		dw=document.getElementById("dw").value
	if(document.getElementById("tooldiameter")!=null)
		D=document.getElementById("tooldiameter").value
	
	if(document.getElementById("feedpertooth")!=null)
		f=document.getElementById("feedpertooth").value
	if(document.getElementById("hmax")!=null)
		hmax=document.getElementById("hmax").value
	
	if(stock!=0 && dw!=0 && D!=0)
	{
		
		if(application==InternalCircularMilling)
		{
			if(D==dw)
			{
				alert("Tool diameter can't be equal to work-piece diameter")
				return 0.00001;
			}
			var temp=1*stock*(stock*1-dw*1)
			
			ae=temp/(D*1-dw*1);
			
		}
		else
		{
			
			var a=(1*(stock) + 1*(dw))
			
			var b=1*stock*a
			
			
			
			ae=(b)/(D*1 + dw*1);
		}
	}
	
	return ae
}
function mUpdateFeedPerTooth(check)
{
	   var ae=mGetAe()
	   
	   if(ae==0.00001)
	   	return;
	   var hmax,x,D,f
	   D=document.getElementById("tooldiameter").value
	   f=document.getElementById("feedpertooth").value
		hmax=document.getElementById("hmax").value
	   //alert(check)
		 //document.getElementById("cuttingwidth").value=ae	
		if(check==1)
		{
			
			x=mArcCos(1-2*ae/D)
			
			
			//alert("x=" + x)
			
			hmax=f*Math.sin(x)
			//alert(hmax)
			hmax=mRound(hmax,4)
			
			document.getElementById("hmax").value=hmax
			
			
		}
		else
		{
			x=mArcCos(1-2*ae/D)
			
			f=hmax/Math.sin(x)
			//alert(hmax)
			f=mRound(f,4)
			document.getElementById("feedpertooth").value=f
		}
	
}
//*******************************************************************************************
function mChangeBackGround()
{
	
	if (inc<bgimages.length-1)
	inc++
	else
	inc=0;
	document.all.GraphTableBackGround.background=pathToImg[inc].src;
}
//************************************************************
function mUpdateApp(AppType) 
{
	//remove table
	var oNode=document.getElementById("tableApp");
    oNode.parentNode.removeChild(oNode);
    //alert("remove table2");
   
  	var oDiv = document.getElementById("oDiv");
  	var oDiv1 = document.getElementById("oDivInserttype");
  	//build new table
    var oTable = document.createElement("TABLE");
    oTable.setAttribute('id', "tableApp" );
    oTable.setAttribute('width', "100%" );
    var oTBody = document.createElement("TBODY");
    oTable.appendChild(oTBody);

        
	if(AppType==1)
	{
		 var oNode1=document.getElementById("tableInsertType");
    	oNode1.parentNode.removeChild(oNode1);	
		oTR = document.createElement("TR");
        mAddTd('Feed per tooth(fz):','feedpertooth',oTR);
         oTBody.appendChild(oTR);
         mSelectInsertType();
      
  	}		
	else//side plunging
	{
		oTR = document.createElement("TR");
        mAddTd('Feed per revolution(f):','feedperrevolution',oTR);
         oTBody.appendChild(oTR);
        oTR1 = document.createElement("TR");
        mAddTd('Pre Drilled Hole diameter(D):','predrilledholediameter',oTR1);
        oTBody.appendChild(oTR1);
        //build insert type table
        //build new table
    	var oTable1 = document.createElement("TABLE");
    	oTable1.setAttribute('id', "tableInsertType" );
    	oTable1.setAttribute('width', "200%" );
    	var oTBody1 = document.createElement("TBODY");
    	oTable1.appendChild(oTBody1);
        
        oTR2 = document.createElement("TR");
        mAddTd('Effective rake angle  :','rakeangle',oTR2);
        oTBody1.appendChild(oTR2);
        oTR3 = document.createElement("TR");
        mAddTd('Lead angle (k) :','leadangle',oTR3);
        oTBody1.appendChild(oTR3);
         oDiv1.appendChild(oTable1);
       
	}//apptype!=1*/
	
      oDiv.appendChild(oTable);
     
}
function mAddTd(title,sname,obj)
{
	var lable=	document.createTextNode(title);
  	var units=	document.createTextNode("mm");
  	var oTD1 = document.createElement("TD");
  	var oTD2 = document.createElement("TD");
  	var oTD3 = document.createElement("TD");
    oTD1.innerHTML = title;
    
  	var el = document.createElement('input');// the input element 
	el.setAttribute('type', 'text');
	el.setAttribute('name', sname );
    el.onkeypress = 'return keyNomericCheck(event, this)';
    el.onchange= 'chkValue(this)';
    oTD2.appendChild(el);
    oTD3.appendChild(units);//the lable text 
    obj.appendChild(oTD1);
    obj.appendChild(oTD2);
	obj.appendChild(oTD3); 
}



//***********************************************************************
function mSetGraph(Rf,app,Tslot)
{
	
	if(Rf=="")
		Rf=50
	var newWindow;
	
	
	if(typeof(document.getElementById("submitmill"))=="object" & document.getElementById("submitmill")!=null )
		var submit=document.getElementById("submitmill").value;
	else
		var submit="yes";
	
	if(submit=="yes")
	{
		var Url="SpindleGraph.jsp?Rf=" + Rf + "&application=" + app;
		if(app==SlotMilling && Tslot=="1")
		Url+="&Application=" + app +"&TSlot=" + Tslot;
		//var windowOptions = 'history=no,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,width=700,height=400,screenX=200,screenY=200';
		
		if(Rf>100)
			alert("Radial force /Tangential force ratio must be positiveand less than or equal to 100% ");
		else
		{
			
			if(typeof(document.getElementById("RFobj"))=="object")
			{
				if(typeof(document.getElementById("RFobj")=="object") & document.getElementById("RFobj")!=null)
				{
					
					document.getElementById("RFobj").value=Rf;
				}
			}
			else
			{
				
				window.opener.document.getElementById("RFobj").value=Rf;
			}
			var browserName=navigator.appName;
			
			if(browserName=="Microsoft Internet Explorer")
				newWindow=window.open(Url, 'SpindleGraph',"status=yes,width=600,height=620,menubar=yes");
			else
				newWindow=window.open(Url, 'SpindleGraph',"status=yes,width=600,height=720,menubar=yes");
			//parent.Header.document.all.openSpindle.value="1"
			//newWindow.location.reload();
			//newWindow.focus();
			
			if(document.getElementById("submitaction")!=null)
			{
			
			document.getElementById("submitaction").action=Url;
 			document.getElementById("submitaction").target="SpindleGraph";
 			
 			document.getElementById("submitaction").submit();
 			
 			document.getElementById("submitaction").target="";
 			newWindow.focus()
 			}
 			else
 			{
 				
 				var new_rf=(document.all.rfTxt.value)
 				
 				newWindow.location="SpindleGraph.jsp?Rf=" + new_rf + "&application=" + app;;
 				
 				//newWindow.location.reload();
 				newWindow.focus()
 			}
		}
		//if(Rf==30)
		//	newWindow.location.reload();
		//newWindow.focus();
	}
	else
	{
		
			alert("Calculate the data");
	}
	
	
}
function mSetGraph1(Rf)
{
	
}
function updateSpindleObj(val)
{
	
	var browserName=navigator.appName;
			
			if(browserName=="Microsoft Internet Explorer")
			{
	if(typeof(window.opener.document.getElementById("openSpindle")=="object"))
		window.opener.document.getElementById("openSpindle").value=val;
		}
		
	
}
function updateForceValue(nVal,lbVal)
{
	
	window.opener.document.getElementById("aMillForce").innerHTML=nVal
	window.opener.document.getElementById("AxialForcelb").innerHTML=lbVal
	
}
function updatePowerObj(val)
{
	
	window.opener.parent.Header.document.all.openPower.value=val;
	
}
//***********************************************************************
function mSetPowerGraph(callbutton,application,Tslot)
{
	var newWindow;
	
	var submit=document.getElementById("submitmill").value;
	
	if(submit=="yes")
	{
	
	
	
	var url="PowerGraph.jsp?callbutton=" + callbutton;
	if(application==SlotMilling && Tslot=="1")
		url+="&Application=" + application +"&TSlot=" + Tslot;
	
	var windowOptions = 'history=no,toolbar=0,location=0,directories=0,status=0,menubar=yes,scrollbars=no,resizable=no,width=600,height=550';
	document.getElementById("submitaction").action=url;
 	document.getElementById("submitaction").target='PowerGraph';
	if(document.getElementById("openPower").value==0)
	{
	
	newWindow=window.open(url, 'PowerGraph',windowOptions);
	}
	else
 		document.getElementById("submitaction").submit();
 	
 	document.getElementById("submitaction").target="";
 	document.getElementById("openPower").value="1";
	//
	if(newWindow!=null)
	{
	if(newWindow.location!=null)
		{
			newWindow.location.reload();
		newWindow.focus();
		}
	}

	}
	else
	{
	
		
			alert("Calculate the data");
	}
	
}

//***********************************************************************
function keyNomericCheck(eventObj, obj)
{
	var keyCode

	// Check For Browser Type
	if (document.all)
	{ 
		keyCode=eventObj.keyCode
	}
	else
		{
			keyCode=eventObj.which
		}

	var str=obj.value

	if(keyCode==46)
	{ 
		if (str.indexOf(".")>0)
		{
			return false
		}
	}

	if((keyCode<48 || keyCode >58)   &&   (keyCode != 46))
	{ // Allow only integers and decimal points
		return false
	}

	return true
}
//***********************************************************************
function setSpindlePicture()
{

switch (document.all.apptext.value)
{
case "aFullImmersion":
	{
	document.all.aGraphImg.src='images/GraphPicture/FullImmersion30.jpg';
	break;
	}
case Shouldering:
	{
	document.all.aGraphImg.src='images/GraphPicture/Shouldering30.jpg';
	break;
	}
case FaceMilling:
	{
	document.all.aGraphImg.src='images/GraphPicture/FaceMilling30.jpg';
	break;
	}
}

		
}

//***********************************************************************
function CheckAp() 
{
var selInsertInd=document.getElementById("inserttype").selectedIndex
var selAppInd=document.getElementById("applications").selectedIndex
    if(document.getElementById("inserttype")[selInsertInd].value!=Serrated)// not sarated
       return false;
    else
    	{
	    	if((document.getElementById("applications")[selAppInd].value!=SlotMilling && 
	   	   			document.getElementById("applications")[selAppInd].value!=InternalCircularMilling && 
	   	   			document.getElementById("applications")[selAppInd].value!=ExternalCircularMilling))
	   	   			{
			    	if( typeof(document.getElementById("maxdepthofcut"))=="object" && document.getElementById("depthofcut").value>= 
			    		(document.getElementById("maxdepthofcut").value - document.getElementById("insertwidth").value * 
			    		Math.sin(document.getElementById("leadangle").value) * Math.PI / 180.0))
			        	return false;
			    	else
		        		return false;
	        		}
        }
}
//***********************************************************************
function LeadAngleCheck() 

   {
   
   var d=document.all;
    if(document.getElementById("inserttype")[0].value==Round)// round
        return true;
    if(document.getElementById("leadangle").value=="" && 
    	document.getElementById("inserttype")[0].value!=FF06 && document.getElementById("inserttype")[0].value!=FF09)
        return false;
    if((document.getElementById("leadangle").value<= 0 ||document.getElementById("leadangle").value > 90) &&
    	(document.getElementById("inserttype")[0].value!=FF06 && document.getElementById("inserttype")[0].value!=FF09))	
        return false;
   else
    	return true;
    }
//***********************************************************************
function InsertDiameterCheck() 
{
	var selInsertInd=document.getElementById("inserttype").selectedIndex
	var selAppInd=document.getElementById("applications").selectedIndex
	
    if(document.getElementById("insertdiameter")=="")
        return true;
     if(document.getElementById("inserttype")[selInsertInd].value!=Round)// round
       return true;
      if(document.getElementById("inserttype")[selInsertInd].value==Round && document.getElementById("applications")[selAppInd].value==SlotMilling)
      	return true;
   if(mRound(document.getElementById("insertdiameter").value) < mRound(document.getElementById("depthofcut").value))
        return false;
   else
   		return true;
  }
 //*********************************************************************** 
 function EccentricityCheck(RO)
{
   var selAppInd=document.getElementById("applications").selectedIndex
   var selInsertInd=document.getElementById("inserttype").selectedIndex
   
    if(document.getElementById("eccentricity").value == "")
        return true;
   if(document.getElementById("applications")[selAppInd].value!=FaceMilling)//aFaceMilling
        return true;
   if(document.getElementById("eccentricity").value > (document.getElementById("tooldiameter").value - document.getElementById("cuttingwidth").value) / 2.0  && 
   		(document.getElementById("inserttype")[selInsertInd].value!=FF06 && document.getElementById("inserttype")[0].value!=FF09 ))
         return false;
    if ((document.getElementById("eccentricity").value) > mRound(((mRound(2 * RO, 2) - document.getElementById("cuttingwidth").value) / 2), 2) && 
    		(document.getElementById("inserttype")[selInsertInd].value==FF06 || document.getElementById("inserttype")[0].value==FF09 )) 
         {
         return false;}
    else
    	return true;
}
//*********************************************************************** 
function chkValue(obj)
{
	alert(obj.value);
}
function mGetR()
{
   
    var Ri;
    var Rc ;
    var AsInc;
	var x;
	var Ret=0;
	
    if(document.all.unittype.value=="mm" || document.all.unittype.value==" mm ")
        AsInc = 1;
    else
        AsInc = 25.4;
        
    
     
   if(document.all.inserttype[0].value==FF06)
        {
        Rc = document.all.tooldiameter.value/2.0;
        Ri = Rc - (7.06/AsInc);
    	 
        var val=(14.4 - (document.all.depthofcut.value * AsInc))/14.4;
        
        x=mArcSin(val);
        
        val=(14.4/AsInc)*Math.cos(x);
        Ret= Ri + val;
        
        }
    else
     {
     	
        Rc = document.all.tooldiameter.value /2.0;
       
        Ri = Rc - (10.41 / AsInc);
        x=mArcSin((21.18 - (document.all.depthofcut.value  * AsInc)) / 21.18);
        val=Math.cos(x);
        val=(21.18 / AsInc) * val;
        Ret=  Ri +val;
    
        }
        
     	return Ret;
}

function mGetRWithUnit(UnitType)
{
   
    var Ri;
    var Rc ;
    var AsInc;
	var x,y;
	var Ret=0;
	var D;
	if(document.all.depthofcut==null)
		return 0;
    if(UnitType=="mm" || UnitType==" mm " )
        AsInc = 1;
    else
        AsInc = 25.4;
   
  
     D=document.all.tooldiameter.value
     
   if(document.all.inserttype[0].value==FF06)
        {
      
        Rc = D/2.0;
   
        Ri = Rc - (7.06/AsInc);
    	
    
        var val=(14.4 - (document.all.depthofcut.value * AsInc))/14.4;
      
        x=mArcSin(val);
        
        val=(14.4/AsInc)*Math.cos(x);
        Ret= Ri + val;
        
        }
    else
     {
     	
        Rc = D /2.0;
       
        Ri = Rc - (10.41 /AsInc);
        
        
        
        y=(21.18 - (document.all.depthofcut.value * AsInc)) / 21.18
       
       
        x=mArcSin(y);
        
        val=Math.cos(x);
        val=(21.18 /AsInc) * val;
       
        Ret=  Ri +val;
    
        }
      
     	return Ret;
}
function mArcSin(X)
{
   
   var Y;
   var ret=0;
    Y = -X * X + 1;
    if(Y < 0)
        ret= 2 * Math.atan(1);
    Y = Math.sqrt(Y);
    if(Y == 0)
        ret= 2 * Math.atan(1);
    else
    	ret=Math.atan(X / Y);
    	
    return ret;
 } 
 function keepValue(unittype)
 {

 var Ref=""
 var toolDiam=0;
 var CuttingWidth=0;
 var NumberOfInsert=0;
 var DepthOfCutt=0;
 var Eccentricity=0;
 var RakeAngle=0;
 var LeadAngle=0;
 var hmax=0;
 var Dw=0;
 var stock=0;
 var hmax=0;
			 
			 toolDiam=document.getElementById("tooldiameter").value;
			 var selAppInd=document.getElementById("applications").selectedIndex
 
    		 var application=document.getElementById("applications")[selAppInd].value
    		 if(application!=InternalCircularMilling && application!=ExternalCircularMilling)
    		 {
				
				 if(document.getElementById("cuttingwidth")!=null)
				 	CuttingWidth=document.getElementById("cuttingwidth").value;
				 
				 
			 }
			 else
				 {
				 	
				 	CuttingWidth=mGetAe();
				 	if(document.getElementById("fradio1")!=null)
				 	{
					 	if(document.getElementById("fradio1").checked)
					 		mUpdateFeedPerTooth("1")
					 	else
					 		mUpdateFeedPerTooth("2")
						hmax=document.getElementById("hmax").value
					}	 	
				 }
			 if(document.getElementById("dw")!=null)
			 		Dw=document.getElementById("dw").value;
			 if(document.getElementById("stock")!=null)
			 	stock=document.getElementById("stock").value;	
			 NumberOfInsert=document.getElementById("numberofinsert").value;
			 var selInsertInd=document.getElementById("inserttype").selectedIndex
			var selAppInd=document.getElementById("applications").selectedIndex
			 if(document.getElementById("inserttype")[selInsertInd].value!=FF06 && 
			 	document.getElementById("inserttype")[selInsertInd].value!=FF09)
			 	{
			 		if(typeof(document.getElementById("rakeangle"))=="object" & document.getElementById("rakeangle")!=null)
			 		{
				 		RakeAngle=document.getElementById("rakeangle").value;
				 		
				 		if(document.getElementById("inserttype")[selInsertInd].value!=Round)
				 		{	if(typeof(document.getElementById("leadangle"))=="object" & document.getElementById("leadangle")!=null)
				 				LeadAngle= document.getElementById("leadangle").value;
				 		}
				 	}
			 	}
			 var spindlespeed=document.getElementById("spindelspeed").value;
			 
			 var cuttingVel=mGetCuttingVelocity(spindlespeed,unittype)
			 
			 Ref="Diameter=" +  toolDiam+ "&Ae=" + CuttingWidth + 
			 	"&Z=" + NumberOfInsert + 
			 	"&spindleSpeed=" + document.all.spindelspeed.value+ 
			 	"&cuttingVelocity=" + cuttingVel + 
			 	"&WorkPiece=" + document.all.materialtype.value + 
			 	"&kc1=" + document.all.kc1_1.value + 
			 	"&Mc=" + document.all.mc.value+ 
			 	"&RakeAngle=" + RakeAngle + "&LeadAngle=" + LeadAngle+
			 	"&Dw=" +Dw + "&Stock=" + stock +"&Hmax=" + hmax ;
			 	
			 	if(document.getElementById("applications")[selAppInd].value==Plunging) ////aSidePlunging
			 		{
			 		
			 		if(typeof(document.getElementById("feedperrevolution"))=="object" && document.getElementById("feedperrevolution")!=null)
				 	{
				 		
				 		var FeedPerRev=document.getElementById("feedperrevolution").value;
				 		
				 		Ref=Ref + "&f=" +FeedPerRev  ;
				 		
				 	}
				 
				 		if(typeof(document.getElementById("predrilledholediameter"))=="object" &  document.getElementById("predrilledholediameter")!=null)
				 		{
				 			var predrill=document.getElementById("predrilledholediameter").value;
				 			Ref+="&d="+ predrill
				 		}
			 		}
			 	
			
			if(document.getElementById("inserttype")[selInsertInd].value==Serrated)
			{
				
				if(typeof(document.getElementById("insertwidth"))=="object" & document.getElementById("insertwidth")!=null)
				{
					var insertwidth=document.getElementById("insertwidth").value;
					Ref+="&w=" + insertwidth 
				}
				if(typeof(document.getElementById("maxdepthofcut"))=="object" & document.getElementById("maxdepthofcut")!=null)
				{
					
					var MaxDept=0;
					if(document.getElementById("applications")[selAppInd].value!=SlotMilling && 
	   	   			document.getElementById("applications")[selAppInd].value!=InternalCircularMilling && 
	   	   			document.getElementById("applications")[selAppInd].value!=ExternalCircularMilling)
						MaxDept=document.getElementById("maxdepthofcut").value
					else
					{
						if(typeof(document.getElementById("depthofcut"))=="object" & document.getElementById("depthofcut")!=null)
			 				MaxDept=document.getElementById("depthofcut").value
					}
					Ref+="&ApMax=" + MaxDept;
				}
			}
			
	var DeptOfCut=0;
	var TSlot=0;
	if(document.getElementById("applications")[selAppInd].value!=SlotMilling && document.getElementById("depthofcut")!=null)
		DeptOfCut=document.getElementById("depthofcut").value
	else
	{
		if(document.getElementById("slotradio1")==null)
			TSlot="0"
		else if( document.getElementById("slotradio1").checked)
			TSlot="0"
		else
			TSlot="1"
		Ref+="&TSlot=" + TSlot;	
		if(document.getElementById("inserttype")[selInsertInd].value!=Round && document.getElementById("depthofcut")!=null)
			DeptOfCut=document.getElementById("depthofcut").value
		else
		{
			if(document.getElementById("insertdiameter")!=null)
		    	DeptOfCut= document.getElementById("insertdiameter").value
		}
	}
	if(typeof(document.getElementById("insertdiameter"))=="object" &  document.getElementById("insertdiameter")!=null)
			 		Ref+="&d=" + document.getElementById("insertdiameter").value;
	
	if(typeof(document.getElementById("eccentricity"))=="object" & document.getElementById("eccentricity")!=null)
			 		Ref+="&e=" + document.getElementById("eccentricity").value;
	
	if(typeof(document.getElementById("feedpertooth"))=="object" & document.getElementById("feedpertooth")!=null)
			 		Ref+="&fz=" + document.getElementById("feedpertooth").value;
			 		
	if(typeof(document.getElementById("depthofcut"))=="object" & document.getElementById("depthofcut")!=null)
			 		Ref+="&Ap=" + DeptOfCut;
			 		
	
	 return Ref;
 }
function runBGSlideShow1(){
 var speed = 200

// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below

switch(window.opener.parent.MachiningPower.document.all.applications[0].value)
{
	case FaceMilling:
	{
	
	Pic[0] = "images/GraphPicture/FaceMilling30.jpg";
	Pic[1] = "images/GraphPicture/FaceMilling60.jpg";
	Pic[2] = "images/GraphPicture/FaceMilling90.jpg";
	break;
	}
	case "aFullImmersion":
	{
	
	Pic[0] = "images/GraphPicture/FullImmersion30.jpg"
	Pic[1] = "images/GraphPicture/FullImmersion60.jpg"
	Pic[2] = "images/GraphPicture/FullImmersion90.jpg"
	break;
	}
	case Shouldering:
	{
	
	Pic[0] = "images/GraphPicture/Shouldering30.jpg"
	Pic[1] = "images/GraphPicture/Shouldering60.jpg"
	Pic[2] = "images/GraphPicture/Shouldering90.jpg"
	break;
	}
}

// do not edit anything below this line

var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < 3; i++){
preLoad[i] = new Image()
preLoad[i].src = Pic[i]

}


 

//if (document.body){
//alert("here");

document.all.pic.src = Pic[j];
j = j + 1
if (j > (p-1)) j=0
t = setTimeout('runBGSlideShow()', speed)
//}
}

 function setGraphDisable(flag)
 {
 
 	//document.all.aPowerGraph.disabled=flag;
 	//document.all.aSpindleGraph.disabled=flag;
 }
 function Reload()
 {
 
 window.location.reload();
 }
 function delay()
 {
 var val="just Delay";
 }
 
 function setReport(applicationName,Home)
 {
	
 	var application;
 	var insertType;
 	
 	var unitType=(window.opener.document.getElementById("aUnits").value);
 	unitType=window.opener.document.getElementById("clickUnits").value
 	
 	if (unitType==" mm " || unitType=="mm")
 		var cvUnit="m/min";
 	else
 		var cvUnit="sfm";
 	if(applicationName=="aFullImmersion")
 		application="Full Immersion";
 	else
 		if(applicationName==FaceMilling)
	 		application="Face Milling";	
	 	else
	 		if(applicationName==Shouldering)
 				application="Shouldering";
 			else if(applicationName==ExternalCircularMilling)
 				application="External Circular Milling ";
 			else if(applicationName==InternalCircularMilling)
 				application="Internal Circular Milling ";
 			else if(applicationName==SlotMilling)
 				application="Slot Milling ";
 
	var selInsertInd=window.opener.document.getElementById("inserttype").selectedIndex
 	var insertType=window.opener.document.getElementById("inserttype")[selInsertInd].value;
 	
 	if(insertType==Quadrilateral)
 		insertType="Quadrilateral";
 	else
 		if(insertType==Round)
 			insertType="Round";
 		else
 			if(insertType==Serrated)
 				insertType=="Serrated";
 				
 			else
 				if(insertType==FF06)
 				{
 					if(Home=="iscar")
 						insertType="H600 WXCU 05";
 					else
 						insertType="Bull Mill XDMX 08";
 				}
 				else
 				{
 					if(Home=="iscar")
 						insertType="H600 WXCU 08";
 					else
 						insertType="Bull Mill XDMX 13";
 				}
 			
 	document.getElementById("applicationtype").innerHTML=application;
 	document.getElementById("inserttype").innerHTML=insertType;
 	//data
 	
 	document.getElementById("tooldiam").innerHTML=window.opener.document.getElementById("tooldiameter").value;
 	if(document.getElementById("cuttingwidth")!=null)
 		document.getElementById("cuttingwidth").innerHTML=window.opener.document.getElementById("cuttingwidth").value;
 	document.getElementById("numberofinsert").innerHTML=window.opener.document.getElementById("numberofinsert").value;
 	if(typeof(window.opener.document.all.feedpertooth)=="object")
	 	document.getElementById("feedper").innerHTML=window.opener.document.getElementById("feedpertooth").value;
	 	
	if(typeof(window.opener.document.all.depthofcut)=="object")
 		document.getElementById("deptofcut").innerHTML=window.opener.document.getElementById("depthofcut").value;
 		
 		
 	document.getElementById("spindlespeed").innerHTML=window.opener.document.getElementById("spindelspeed").value;
 	document.getElementById("cuttingvelocity").innerHTML=window.opener.document.getElementById("cuttingvelocity").value;
 	
 	document.getElementById("workpiece").innerHTML=window.opener.document.getElementById("materialtypes").value;
 	if(insertType=="Quadrilateral" || insertType=="Serrated" || insertType=="Round" )
 	{
	 
	 	document.getElementById("rakeangle").innerHTML=window.opener.document.getElementById("rakeangle").value;
	 	
	 }
 	
 	if(typeof(window.opener.document.getElementById("eccentricity"))=="object" && 
 	window.opener.document.getElementById("eccentricity")!=null)
	 	document.getElementById("eccentricity").innerHTML=window.opener.document.getElementById("eccentricity").value;
 	
 	if(typeof(window.opener.document.getElementById("dw"))=="object" && 
 	window.opener.document.getElementById("dw")!=null)
	 	document.getElementById("dw").innerHTML=window.opener.document.getElementById("dw").value;
	if(typeof(window.opener.document.getElementById("stock"))=="object" && 
 	window.opener.document.getElementById("stock")!=null)
	 	document.getElementById("stock").innerHTML=window.opener.document.getElementById("stock").value;
 	if(insertType=="Quadrilateral" || insertType==Serrated && window.opener.document.getElementById("leadangle")!=null)
	 	document.getElementById("leadangle").innerHTML=window.opener.document.getElementById("leadangle").value;
	 
	 if(insertType=="Round" && document.getElementById("insertdiam")!=null && window.opener.document.getElementById("insertdiameter")!=null)
	 	document.getElementById("insertdiam").innerHTML=window.opener.document.getElementById("insertdiameter").value;
	 if(insertType==Serrated)
	 	{
	 	
	 	document.getElementById("inserttype").innerHTML="Serrated";
	 	//if(document.getElementById("maxdepthofcut")!=null && window.opener.document.getElementById("maxdepthofcut")!=null)
	 	//	document.getElementById("maxdepthofcut").innerHTML=window.opener.document.getElementById("maxdepthofcut").value;
	 	if(document.getElementById("insertwidth")!=null && window.opener.document.getElementById("insertwidth")!=null)		
	 		document.getElementById("insertwidth").innerHTML=window.opener.document.getElementById("insertwidth").value;	
	 	}
	if(document.getElementById("eccentricityunit")!=null) 	
 		document.getElementById("eccentricityunit").innerHTML=unitType;
 	if(document.getElementById("tooldiamunit")!=null)
 		document.getElementById("tooldiamunit").innerHTML=unitType;
 	if(document.getElementById("cuttingwidthunit")!=null)
 		document.getElementById("cuttingwidthunit").innerHTML=unitType;
 	if(document.getElementById("feedperunit")!=null)
 		document.getElementById("feedperunit").innerHTML=unitType;
 	if(document.getElementById("deptofcutunit")!=null)
 		document.getElementById("deptofcutunit").innerHTML=unitType;
 	if(document.getElementById("cuttingvelocityunit")!=null)
 		document.getElementById("cuttingvelocityunit").innerHTML=cvUnit;
 	
 	
 	if(insertType=="Round")
	 	document.getElementById("insertdiamunit").innerHTML=unitType;
	if(insertType=="Serrated")
	{
	 	alert("1")
	 	document.getElementById("maxdepthofcutunit").innerHTML=unitType;
	 	document.getElementById("insertwidthunit").innerHTML=unitType;
	 }
 	//result
 	
 	document.getElementById("aKc").innerHTML=window.opener.document.getElementById("aKc").innerHTML;
 	document.getElementById("aKcKpsi").innerHTML=window.opener.document.getElementById("aKcKpsi").innerHTML;
 	document.getElementById("aNetPowerDemand").innerHTML=window.opener.document.getElementById("aNetPowerDemand").innerHTML;
 	document.getElementById("netpowerhp").innerHTML=window.opener.document.getElementById("netpowerhp").innerHTML;
 	document.getElementById("aMaterialRemovalRate").innerHTML=window.opener.document.getElementById("aMaterialRemovalRate").innerHTML;
 	document.getElementById("MaterialRemovalRateHP").innerHTML=window.opener.document.getElementById("MaterialRemovalRateHP").innerHTML;
 	document.getElementById("aMillForce").innerHTML=window.opener.document.getElementById("aMillForce").innerHTML;
 	document.getElementById("AxialForcelb").innerHTML=window.opener.document.getElementById("AxialForcelb").innerHTML;
 	document.getElementById("aAverageChipThickness").innerHTML=window.opener.document.getElementById("aAverageChipThickness").innerHTML;
 	document.getElementById("AverageChipThicknessInch").innerHTML=window.opener.document.getElementById("aAverageChipThicknessInch").innerHTML;
 	document.getElementById("MeanTorque").innerHTML=window.opener.document.getElementById("aMeanTorque").innerHTML;
 	document.getElementById("MeanTorqueIncnLb").innerHTML=window.opener.document.getElementById("aMeanTorqueIncnLb").innerHTML;
 	
 }
 
 function mOpenReport()
 {
 	
 	var applicationName=document.getElementById("application").value;
 	var application;
 	
 	var url;
 	var home=(document.getElementById("home").value)
 	
 	var insertType=document.getElementById("inserttype")[0].value;
 
 	if(insertType=="1")
 	{
 		url="MillGeneralShapeReport.jsp?ApplicationName=" + applicationName;
 		
 	}
 	else
	 	if(insertType==Round)
	 	{
	 		url="MillRoundReport.jsp?ApplicationName=" + applicationName;
	 		
	 	}
	 	else
		 	if(insertType==Serrated)
		 	{
		 		url="MillSerratedReport.jsp?ApplicationName=" + applicationName;
		 		
		 	}
 		else
 			url="MillFwReport.jsp?ApplicationName=" + applicationName;
 	url+="&Home=" + home
 	document.submitaction.action=url;
 	document.submitaction.target="_blank";
 	document.submitaction.submit();
 	document.submitaction.target="";
 
 }
 
  function mOpenPlungingReport()
 {
 	var applicationName=document.all.application.value;
 	var home=(document.getElementById("home").value)
 	var url="MillPlungingReport.jsp?ApplicationName=" + applicationName+ "&Home=" + home;
 	document.submitaction.action=url;
 	document.submitaction.target="_blank";
 	document.submitaction.submit();
 	document.submitaction.target="";
 }
 
 function setPlungingReport(applicationName)
 {
 	var application="Side Plunging";
 	
 	var unitType=(window.opener.document.all.aUnits.value);
 	if (unitType==" mm ")
 		var cvUnit="m/min";
 	else
 		var cvUnit="sfm";
 	
 				
 	document.getElementById("applicationtype").innerHTML=application;
 	
 	//data
 	
 	document.getElementById("tooldiam").innerHTML=window.opener.document.all.tooldiameter.value;
 	document.getElementById("predrilledholediameter").innerHTML=window.opener.document.all.predrilledholediameter.value;
 	document.getElementById("cuttingwidth").innerHTML=window.opener.document.all.cuttingwidth.value;
 	document.getElementById("numberofinsert").innerHTML=window.opener.document.all.numberofinsert.value;
 	document.getElementById("feedperrevolution").innerHTML=window.opener.document.all.feedperrevolution.value;
 	document.getElementById("spindlespeed").innerHTML=window.opener.document.all.spindel_speed.value;
 	document.getElementById("cuttingvelocity").innerHTML=window.opener.document.all.cutting_velocity.value;
 	document.getElementById("workpiece").innerHTML=window.opener.document.all.materialtypes.value;
	document.getElementById("rakeangle").innerHTML=window.opener.document.all.rakeangle.value;
	document.getElementById("leadangle").innerHTML=window.opener.document.all.leadangle.value;	
 	
 	
 
 	document.getElementById("tooldiamunit").innerHTML=unitType;
 	document.getElementById("predrilledholediameterunit").innerHTML=unitType;
 	document.getElementById("cuttingwidthunit").innerHTML=unitType;
 	document.getElementById("feedperrevolutionunit").innerHTML=unitType;
 	document.getElementById("cuttingvelocityunit").innerHTML=cvUnit;
 
 	
 
 	//result
 	
 	document.getElementById("aKc").innerHTML=window.opener.document.all.aKc.innerHTML;
 	document.getElementById("aKcKpsi").innerHTML=window.opener.document.all.aKcKpsi.innerHTML;
 	document.getElementById("aNetPowerDemand").innerHTML=window.opener.document.getElementById("aNetPowerDemand").innerHTML;
 	document.getElementById("aNetPowerDemandHP").innerHTML=window.opener.document.getElementById("aNetPowerDemandHP").innerHTML;
 	
 	document.getElementById("aMaterialRemovalRate").innerHTML=window.opener.document.getElementById("aMaterialRemovalRate").innerHTML;
 	document.getElementById("aMaterialRemovalRateHP").innerHTML=window.opener.document.getElementById("aMaterialRemovalRateHP").innerHTML;
 	document.getElementById("aMillForce").innerHTML=window.opener.document.getElementById("aMillForce").innerHTML;
 	document.getElementById("aMillForcelb").innerHTML=window.opener.document.getElementById("aMillForcelb").innerHTML;
 	document.getElementById("aMeanTorque").innerHTML=window.opener.document.getElementById("aMeanTorque").innerHTML;
 	
 	document.getElementById("aMeanTorqueIncnLb").innerHTML=window.opener.document.getElementById("aMeanTorqueIncnLb").innerHTML;
 	
 }
 
 function setCuttingWidth()
 {
 	//alert(document.all.applications[selAppInd].value)
 	
 	var selAppInd=document.getElementById("applications").selectedIndex
 	
 	//alert(selAppInd)
	var selInsertInd=document.getElementById("inserttype").selectedIndex
	
 	var submit="yes"
 	
 	if(document.getElementById("submitmill")!=null)
 		submit=(document.getElementById("submitmill").value);
 	var Unit=document.all.aUnits.value;
 	 var RO=mGetRWithUnit(Unit); 
 	//alert(document.all.applications[selAppInd].value)	
 	//alert(document.all.inserttype[selInsertInd].value)
//	if(document.all.applications[0].value=="aFullImmersion" && submit=="yes" )//aFullImmersion
//		{
//	
//			
//			if(document.all.inserttype[0].value!=Round & document.all.inserttype[0].value!=Serrated)
//				document.all.cuttingwidth.value=mRound(2*RO,2);
//			
//		}
//		if(document.all.inserttype[0].value=="1")
//			document.all.cuttingwidth.value=document.all.tooldiameter.value;
		
		if(document.all.applications[selAppInd].value=="aFullImmersion" && submit=="yes" )//aFullImmersion
		{
	
			
			if(document.getElementById("inserttype")[selInsertInd].value!=Round & document.getElementById("inserttype").value!=Serrated)
				document.all.cuttingwidth.value=mRound(2*RO,2);
			
		}
		if(document.getElementById("inserttype")[selInsertInd].value=="1" && document.all.applications[selAppInd].value=="aFullImmersion")
			document.all.cuttingwidth.value=document.all.tooldiameter.value;
		
 }
 function mUpdateUnit(currObjName,mmName,inchName,Unit)
 {
 	
 	var currObj=(eval("document.all." + currObjName))
 	
 	var mmObj=(document.getElementById(mmName))
 	var inchObj=(document.getElementById(inchName))
 	var Unitval=eval("document.all." + Unit + ".innerHTML")
 	var convUnit=1;
 	
 	if(Unitval=="mm" || Unitval==" mm ")
 	{
 		
 		convUnit=1/25.4
 		mmObj.value=currObj.value;
 		inchObj.value=currObj.value*convUnit;
 	}
 	else
 	{
 		
 		convUnit=25.4;
 		mmObj.value=currObj.value*convUnit;
 		inchObj.value=currObj.value;
 	}
 }
 function test()
 {
 alert('hello')
 }
