function Toggle()
{
	if(document.getElementById('Exact').style.display == 'block')
	{
		document.getElementById('Exact').style.display = 'none';
		document.getElementById('Simplified').style.display = 'block';
	}
	else if(document.getElementById('Simplified').style.display == 'block')
	{
		document.getElementById('Exact').style.display = 'block';
		document.getElementById('Simplified').style.display = 'none';
	}
}

function clearTextBox(id)
{
	document.getElementById(id).value = '';
}

function OpenCalculator(type)
{
	var value;
	
	if(type == "Exact")
	{
		if(document.forms[0].Framework_Calculator_exactbox != null)
		{
			value = document.forms[0].Framework_Calculator_exactbox.value;
		}
		else
		{
			// Drift
			value = document.forms[0].ctl00_Calculator_exactbox.value;
			// Local
			//value = document.forms[0]._ctl0_Calculator_exactbox.value;
		}
		
		if(isNaN(value))
		{
			//alert('åäö\n\u00E5\u00E4\u00F6');
			//alert("Du måste ange ett värde för att göra beräkningen.");
			alert("Du m\u00E5ste ange ett numeriskt v\u00E4rde f\u00F6r att g\u00F6ra ber\u00E4kningen.");
			return;
		}
	}
	else if(type == "Simplified")
	{
		for( i = 0; i < document.forms[0].simplifiedradio.length; i++ )
		{
			if( document.forms[0].simplifiedradio[i].checked == true )
			{
				value = document.forms[0].simplifiedradio[i].value;
				break;
			}
		}
	}
	
    var targetUrl = "/Calculator.aspx?keepThis=true&type="+type;
    
    if(value.length > 0)
    {
		targetUrl += "&value="+value;
    }

    //Hide the flash movie
    if (document.getElementById('Experience') != null) {
        document.getElementById('Experience').style.visibility = 'hidden';
    }
    
    //These values must be placed last in the query...
    targetUrl += "&height=520&width=880";
    
    tb_show("", targetUrl, false);
}

function OpenPopup(id, height)
{
	var targetUrl = "/Popup.aspx?id=" + id + "&keepThis=true";
    if(document.getElementById('Experience') != null)
	{
		document.getElementById('Experience').style.visibility = 'hidden';
	}
    if(height=="")
    {
		height = "520";
    }
    
    //These values must be placed last in the query...
    targetUrl += "&height=" + height + "&width=880";
        
    tb_show("", targetUrl, false);
}

function OpenContactPopup(id, height)
{
	var targetUrl = "/ContactPopup.aspx?id=" + id + "&keepThis=true";
    
    if(height=="")
    {
		height = "520";
    }
    
    //These values must be placed last in the query...
    targetUrl += "&height=" + height + "&width=880";
        
    tb_show("", targetUrl, false);
}

function OpenTipPopup(id)
{
	var targetUrl = "/TipPopup.aspx?id=" + id + "&keepThis=true";
    
    height = "520";
    
    //These values must be placed last in the query...
    targetUrl += "&height=" + height + "&width=880";
        
    tb_show("", targetUrl, false);
}

function ClosePopupAndRedirectParent(url)
{
	parent.tb_remove();
	parent.location.href = url;
}

function checkEnter(e, type)
{
	var keynum;
	if(window.event) // IE
	{
		keynum = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}
	
	if(keynum == 13)
	{
		if (window.event)
			window.event.returnValue = null;
		else
			e.preventDefault();
		OpenCalculator(type);
	}
}

function ResizeExperienceArea(sHeight, iSpeed) {
    $("#Experience").animate({ height: sHeight }, iSpeed);
}

function MoveLayer(layer, direction) {
    if (direction == 'down') {
        $(layer).animate({ "top": "+=5px" }, 50);
    }
    else {
        $(layer).animate({ "top": "-=5px" }, 100);
    }
}
