if( top != self )
{
	//alert(top.location.href);
	//alert('The URL you enterred -\n'+ top.location.href +'\nor the link you clicked is NOT the owner of this site\n\rThe site is being displayed in a frame on an unauthorized web site.\n\r\n\rClick OK to jump out of this frame and display the correct URL in the Browser');
	top.location=self.document.location;
}
function Window_onload()
{
    var boxes = document.getElementsByTagName("input");
	for (var i=0; i< boxes.length; i++)
	{
		if (boxes[i].type=="text")
		{
			if (document.all)
				boxes[i].onkeypress = Check_IE;
			else
				boxes[i].onkeypress = Check_NS;	
		}
	}
}
function Check_IE()
{
	var v = event.keyCode;
	if ((v > 47 && v < 58) || v==0 || v==8)
		return true;
	return false;
}
function Check_NS(e)
{
	var v = e.which;
	if ((v > 47 && v < 58) || v==0 || v==8)
		return true;
	e.preventDefault();
}
function BtnCalculate_Click()
{
    if (! CheckLimit())
        return;
    document.getElementById("btnCalculate").disabled = true;
    setTimeout("ReactivateButton()", 3000);
    document.images["imgLoading"].style.display = "block";
    var wide = parseInt(document.getElementById("ddWidthInches").value) * 32 + parseInt(document.getElementById("ddWidthFrac").value);
    var url = "";
    if (document.getElementById("cbFullTemplate").checked)     
        url = "ImageGen/DovetailRadialEng.ashx?w=";
    else
        url = "ImageGen/DovetailRadialTailsEng.ashx?w=";
    url += wide;
    url+= "&t=" + document.getElementById("ddTailThickFrac").value;
    url+= "&st=" + document.getElementById("ddSocketThickFrac").value;
    url+= "&tls=" + document.getElementById("ddTails").value;
    var radiusOffset = parseInt(document.getElementById("ddOffsetInches").value) * 32 + parseInt(document.getElementById("ddOffsetFrac").value);
    url+= "&ro=" + radiusOffset;
    url+= "&pgr="+ document.getElementById("ddRatio").value;
    url += "&c="+ document.getElementById("cbColor").checked;
    document.images["imgDovetail"].src = url;
}
var imgBuff;
function FadeImage()
{
    //setTimeout("FadeDelay()", 200);
}
function FadeDelay()
{
    if (document.all) 
	{
		document.images["imgDovetail"].filters.blendTrans.Apply();
	}
	document.images["imgDovetail"].src = document.images["imgBuffer"].src;
	if (document.all) 
	{ 
		document.images["imgDovetail"].filters.blendTrans.Play(); // fade it
	}
}
function ReactivateButton()
{
    document.getElementById("btnCalculate").disabled = false;
    document.images["imgLoading"].style.display = "none";
}
function ConEng(h, useFeet)
{	
	var ts = Math.round(h);
	// TO CHECK IN 32nds, UNCOMMENT BELOW
	var f=0, i=0, ft=0, fb=32;
	var eng = "";
	if (ts >= 384 && useFeet) // its longer than 1 foot
	{
		f = Math.floor(ts/384);
		ts-= (f*384); // take out the feet
		eng+=  f.toString() +"'";
	}
	var hasInch = false;
	if (ts >= 32) // we have inches left over
	{
		i = Math.floor(ts/32);
		ts-= (i*32);
		eng+=i.toString();
		hasInch = true;
	}
	if (Math.floor(ts) > 0) // it has a fraction
	{
		hasInch = true;
		if (i >0) // only if the fraction follows an inches measurement
			eng+= "~";
		
		ft = Math.floor(ts);
		fb = 32;
		
		while (ft%2 == 0 && ft > 1 && ft < 32) // it can be halved and its > 1
		{
			ft/=2; // loop  till smallest
			fb/=2;
		}
		eng+= ft.toString() +"/"+ fb.toString();
	}
	if (hasInch)
		eng+= "\"";
	
	return eng;
}