var activeElement = 1;
function seltab(n) 
{		
	var selElement = document.getElementById("tabstopsel"+activeElement);
	var unselElement = document.getElementById("tabstop"+activeElement);
	var contentElement = document.getElementById("content"+activeElement);
	
	selElement.style.display = "none";
	contentElement.style.display = "none";
	unselElement.style.display = "";
	
	activeElement = n;
	
	selElement = document.getElementById("tabstopsel"+activeElement);
	unselElement = document.getElementById("tabstop"+activeElement);
	contentElement = document.getElementById("content"+activeElement);
	
	selElement.style.display = "";
	contentElement.style.display = "";
	unselElement.style.display = "none";
}

function toggleValue(input, txt){
 if(input.value==txt){ input.value=''; }
 else if(input.value==''){ input.value=txt; }
}

function OpenWindow(url, w, h, attr)
{
	var m_attr = "toolbar=1,location=0,directories=0,status=0,menubar=yes,scrollbars=yes,resizable=yes";
	if (attr)
	{
		m_attr = attr;
	}	
	window.open(url, "", m_attr+",width="+w+",height="+h);
}

function PreviewImage(imageid, w, h, autoresize)
{
	OpenWindow("/Forms/PreviewImage.aspx?imageid="+imageid+"&autoresize="+autoresize, w, h, "toolbar=0,location=0,directories=0,status=0,menubar=no,scrollbars=yes,resizable=yes");
}

function PrintPage() {
	var loc = location.href;
	if (loc.indexOf("#")>0) {
		loc = loc.substring(0, loc.indexOf("#"));
	}
	var pri = "?print=1";
	if (loc.indexOf("?")>0) {
		pri = "&print=1";
	}
	OpenWindow(loc+pri, 760, 400);
}

function SendPage(id) {
	var loc = "/layouts/sendpage.aspx?pageid="+id;
	OpenWindow(loc, 320, 250, "toolbar=0,location=0,directories=0,status=0,menubar=no,scrollbars=no,resizable=no");
}

function CheckForm(form)
{
	if (form.from.value == "" || form.to.value == "")
	{
		if (form.from.value == "")
		{
			document.getElementById('error1').style.display = "inline";
		}
		if (form.to.value == "")
		{
			document.getElementById('error2').style.display = "inline";
		}
		return false;
	}
	else
	{
		return true;
	}
}

function SetPostAction(val)
{
	var sUrl = val;
	if (sUrl.indexOf("/")<0) {
		sUrl = "/forms/"+sUrl;
	}
	if (sUrl.indexOf(".aspx")<0) {
		sUrl = sUrl + ".aspx";
	}
	//var ctl = document.all["postaction"];
	//ctl.value = val;
	document.forms[0].action = sUrl;
}

function doSearch(fld, target) 
{
    var uri = target + '?action=' + 1 + '&search=' + eval("document.forms[0]." + fld).value;
    location.href = encodeURI(replaceforurl(uri));
}

function replaceforurl(url) {
    url.replace('å', 'aa');
    url.replace('ø', 'oe');
    url.replace('æ', 'ae');
    return url;
}

function doKeySearch(evt, fld, target) 
{	
	if (evt.keyCode==13) {
	    var uri = target + '?search=' + eval("document.forms[0]." + fld).value;
	    window.document.forms[0].action = encodeURI(replaceforurl(uri));
		evt.returnValue = null;
		evt.cancelBubble = true;
		
		doSearch(fld, target);		
	}
	return false;
}

function Cancel()
{
	alert("ser");
	return false;
}



// show flash

function doFlash(file, width, height, query, altimage, altlink)
{
	var oeTags = "";
	var hasCorrectVersion = DetectFlashVer(8, 0);
	if (hasCorrectVersion) {
		oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
		+ 'width="'+width+'" height="'+height+'"'
		+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"><param name="allowScriptAccess" value="sameDomain" />'
		+ '<param name="movie" value="' + file + '?' + query + '" /><param name="quality" value="high" /><param name="allowfullscreen" value="true" /><param name="bgcolor" value="#FFFFFF" /><param name="wmode" value="transparent" />'
		+ '<embed src="'+file+ '?' + query +'" quality="high" bgcolor="#FFFFFF" '
		+ 'width="'+width+'" height="'+height+'" name="detectiontest" aligh="middle" '
		+ 'play="true" '
		+ 'loop="false" '
		+ 'quality="high" '
		+ 'allowfullscreen="true" '
		+ 'wmode="transparent" '
		+ 'allowScriptAccess="sameDomain" '
		+ 'type="application/x-shockwave-flash" '
		+ 'pluginspage="http://www.macromedia.com/go/getflashplayer">'
		+ '<\/embed>'
		+ '<\/object>';
	} else if (altimage!="" && altlink!="") {
		oeTags = '<a href="' + altlink + '"><img src="' + altimage + '" border="0" width="'+width+'" height="'+height+'" /></a>';
	} else if (altimage!="" && altlink=="") {
		oeTags = '<img src="' + altimage + '" border="0" width="'+width+'" height="'+height+'" />';
	}
	document.write(oeTags);
}


function ValidateMail(email, loginID, returnID)
{
	var RegExp = /^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.[a-z]{2,6}$/i;
	if (RegExp.test(email) == true)
	{
		document.forms[0].action = "/forms/forgotpass.aspx?lid=" + loginID + "&rid=" + returnID;
		document.forms[0].submit();
	}
	else
	{
		document.getElementById("errornouser").style.display = 'inline';
	}
}

function Subscribe()
{	
	document.getElementById("errorname").style.display = 'none';
	document.getElementById("erroremail").style.display = 'none';
	var checked = false;
	var foundAny = false;
	
	var RegExp = /^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.[a-z]{2,6}$/i;
	if (document.forms[0].name.value == "")
	{				
		document.getElementById("errorname").style.display = '';
		document.forms[0].name.focus();
		return false;
	}
	if (RegExp.test(document.forms[0].email.value) != true)
	{		
		document.getElementById("erroremail").style.display = '';
		document.forms[0].email.focus();
		return false;
	}
		
	for (i=0; i<document.forms[0].getElementsByTagName("input").length; i++)
	{		
		if (document.forms[0].getElementsByTagName("input")[i].type == "checkbox")
		{
			foundAny = true;
			if (document.forms[0].getElementsByTagName("input")[i].checked == true)
			{
				checked = true;
			}
		}				
	}
	if (checked || !foundAny)
	{
		return true;
	}
	document.getElementById("errormailinglist").style.display = '';
	return false;
}

function CheckEmail()
{
	document.getElementById("erroremail").style.display = 'none';

	var RegExp = /^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.[a-z]{2,6}$/i;
	if (RegExp.test(document.forms[0].email.value) != true)
	{
		document.getElementById("erroremail").style.display = '';
		document.forms[0].email.focus();
		return false;
	}

	return true;
}
