<!--

// För pop-up med bild.
function viewThis(PATH,WHAT,VALUE,SCROLL){
	var width = 640; var height = 500;
	if (WHAT=='country'){
		width=450;
		height=300;
	}
	if (parseInt(navigator.appVersion) >= 3){
		if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)<5){
			var tools = new Packages.java.awt.Toolkit.getDefaultToolkit();
			screen=tools.getScreenSize();
		}
		x = screen.width; y = screen.height;
	}
	window.open(PATH +"view_"+ WHAT +".asp?id="+ VALUE,"updatesystem"+ WHAT,"top=" + parseInt(y/2-height/2-16) + ",left=" + parseInt(x/2-width/2-5) + ",scrollbars="+ SCROLL +",width=" + width + ",height=" + height).focus();
}

//-----------------------------------------------------------------------------------------------------------------------------------

function insertcode(code,form) {

		if (code=="!DOT") {
			inserttext = prompt(tag_prompt_dot,'');
		}
		else if (code=="B") {
			inserttext = prompt(tag_prompt_bold,'');
		}
		else if (code=="I") {
			inserttext = prompt(tag_prompt_italic,'');
		}
		else if (code=="U") {
			inserttext = prompt(tag_prompt_underline,'');
		}
		else if (code=="HR") {
			inserttext = "";
			document.foo(form).value += " ["+code+"] ";
			document.foo(form).focus();
		}
		else {
			inserttext = prompt(tag_prompt,'');
		}

		if ((inserttext != null) && (inserttext != ""))
			document.foo(form).value += " ["+code+"]"+inserttext+"[/"+code+"] ";
			document.foo(form).focus();
}

//-----------------------------------------------------------------------------------------------------------------------------------

function insertlink(httpURL,form) {
	linktext = prompt(link_text_prompt,"");
		var prompttext;
			prompt_text = link_url_prompt;
			prompt_contents = "http://";
	linkurl = prompt(prompt_text,prompt_contents);
	if ((linkurl != null) && (linkurl != "")) {
		if ((linktext != null) && (linktext != ""))
			document.foo(form).value += "["+httpURL+"="+linkurl+"]"+linktext+"[/"+httpURL+"] ";
		else
			document.foo(form).value += "["+httpURL+"]"+linkurl+"[/"+httpURL+"] ";
		}
	document.foo(form).focus();
}

//-----------------------------------------------------------------------------------------------------------------------------------

function insertlink2(httpURL,form) {
	linktext = prompt(link_text_prompt,"");
		var prompttext;
			prompt_text = link_url_prompt;
			prompt_contents = "http://";
	linkurl = prompt(prompt_text,prompt_contents);
	if ((linkurl != null) && (linkurl != "")) {
		if ((linktext != null) && (linktext != ""))
			document.foo(form).value += "["+httpURL+"="+linkurl+"]"+linktext+"[/"+httpURL+"] ";
		else
			document.foo(form).value += "["+httpURL+"]"+linkurl+"[/"+httpURL+"] ";
		}
	document.foo(form).focus();
}

//-----------------------------------------------------------------------------------------------------------------------------------

tag_prompt_dot = "\nSkriv in den text som hör till punkten:";
tag_prompt_bold = "\nSkriv in den text du vill ska visas med fet stil:";
tag_prompt_italic = "\nSkriv in den text du vill ska visas kursivt:";
tag_prompt_underline = "\nSkriv in den text du vill ska visas understruken:";
link_text_prompt = "Skriv in den text som du vill ska synas på sidan:";
link_url_prompt = "Ange den kompletta URL-adressen, inkl http://";

//-----------------------------------------------------------------------------------------------------------------------------------

messages=new Array(4)
	messages[0]="&nbsp;"
	messages[1]="Infoga text i fet stil.."
	messages[2]="Infoga kursiv text.."
	messages[3]="Infoga understruken text.."
	messages[4]="Infoga horisontell linje.."
	messages[5]="Infoga hyperlänk.."
	messages[6]="Infoga punktlisterad.."

var browser;
if (document.all) {
	layerRef='document.all.'
	styleRef='.style.'
	changeMessages=".innerHTML=messages[num]"
	closeit=""
	browser=true
}

else if (document.layers) {
	layerRef='document.layers.'
	styleRef='.'
	changeMessages='.document.write(" "+messages[num]+" ")'
	closeit=".document.close()"
	browser=true
} 

function msg(num){
	if(browser){
		eval(layerRef+'moMsg'+changeMessages)
		eval(layerRef+'moMsg'+closeit);
	}
}

//-----------------------------------------------------------------------------------------------------------------------------------

function checkFormCompany(){
	var doc = document.foo;
	if (doc.txPassword.value == "") {
		doc.txPassword.style.background = "red";
		alert("Du måste ange lösenord!");
		doc.txPassword.style.background = "white";
		doc.txPassword.focus();
		return false;
	}
	if (doc.txPassword.value.length < 3) {
		doc.txPassword.style.background = "red";
		alert("Lösenordet måste vara minst 3 tecken!");
		doc.txPassword.style.background = "white";
		doc.txPassword.value = "";
		doc.txPasswordCheck.value = "";
		doc.txPassword.focus();
		return false;
	}
	if (doc.txPassword.value != doc.txPasswordCheck.value) {
		doc.txPassword.style.background = "red";
		doc.txPasswordCheck.style.background = "red";
		alert("Lösenorden måste överensstämma!");
		doc.txPassword.style.background = "white";
		doc.txPasswordCheck.style.background = "white";
		doc.txPassword.value = "";
		doc.txPasswordCheck.value = "";
		doc.txPassword.focus();
		return false;
	}
	if (doc.txCompName.value == "") {
		doc.txCompName.style.background = "red";
		alert("Du måste ange företagsnamn!");
		doc.txCompName.style.background = "white";
		doc.txCompName.focus();
		return false;
	}
	if (doc.txCompAddress.value == "") {
		doc.txCompAddress.style.background = "red";
		alert("Du måste ange postadress!");
		doc.txCompAddress.style.background = "white";
		doc.txCompAddress.focus();
		return false;
	}
	if (doc.txCompBox.value == "") {
		doc.txCompBox.style.background = "red";
		var choice=confirm("Du har inte angivit gatu-/boxnummer. \n\nVill du utelämna fältet, välj OK.\nVill du skriva ett värde, välj Avbryt.")
		doc.txCompBox.style.background = "white";
		if(choice == false){
			doc.txCompBox.focus();
			return false;
		}
		else{
			doc.txCompBox.value = "-";
		}
	}
	if (doc.txCompZip.value == "") {
		doc.txCompZip.style.background = "red";
		alert("Du måste ange postnummer!");
		doc.txCompZip.style.background = "white";
		doc.txCompZip.focus();
		return false;
	}
	if (doc.txCompCity.value == "") {
		doc.txCompCity.style.background = "red";
		alert("Du måste ange postort!");
		doc.txCompCity.style.background = "white";
		doc.txCompCity.focus();
		return false;
	}
	if (doc.txCompPhone.value == "") {
		doc.txCompPhone.style.background = "red";
		alert("Du måste ange telefonnummer!");
		doc.txCompPhone.style.background = "white";
		doc.txCompPhone.focus();
		return false;
	}
	if (doc.txCompFax.value == "") {
		doc.txCompFax.style.background = "red";
		var choice=confirm("Du har inte angivit faxnummer. \n\nVill du utelämna fältet, välj OK.\nVill du skriva ett värde, välj Avbryt.")
		doc.txCompFax.style.background = "white";
		if(choice == false){
			doc.txCompFax.focus();
			return false;
		}
		else{
			doc.txCompFax.value = "-";
		}
	}
	if (doc.txCompEmail.value == "") {
		doc.txCompEmail.style.background = "red";
		alert("Du måste ange e-postadress!");
		doc.txCompEmail.style.background = "white";
		doc.txCompEmail.focus();
		return false;
	}
	if (doc.txCompOrgNum.value == "") {
		doc.txCompOrgNum.style.background = "red";
		alert("Du måste ange organisationsnummer!");
		doc.txCompOrgNum.style.background = "white";
		doc.txCompOrgNum.focus();
		return false;
	}
	if (doc.txHomepage.value == "") {
		doc.txHomepage.style.background = "red";
		var choice=confirm("Du har inte angivit hemsideadress. \n\nVill du utelämna fältet, välj OK.\nVill du skriva ett värde, välj Avbryt.")
		doc.txHomepage.style.background = "white";
		if(choice == false){
			doc.txHomepage.focus();
			return false;
		}
		else{
			doc.txHomepage.value = "-";
		}
	}
	if (doc.txVisitAddress.value == "") {
		doc.txVisitAddress.style.background = "red";
		alert("Du måste ange besöksadress!");
		doc.txVisitAddress.style.background = "white";
		doc.txVisitAddress.focus();
		return false;
	}
	if (doc.txVisitBox.value == "") {
		doc.txVisitBox.style.background = "red";
		var choice=confirm("Du har inte angivit gatunummer. \n\nVill du utelämna fältet, välj OK.\nVill du skriva ett värde, välj Avbryt.")
		doc.txVisitBox.style.background = "white";
		if(choice == false){
			doc.txVisitBox.focus();
			return false;
		}
		else{
			doc.txVisitBox.value = "-";
		}
	}
	if (doc.txVisitZip.value == "") {
		doc.txVisitZip.style.background = "red";
		alert("Du måste ange besökspostnummer!");
		doc.txVisitZip.style.background = "white";
		doc.txVisitZip.focus();
		return false;
	}
	if (doc.txVisitCity.value == "") {
		doc.txVisitCity.style.background = "red";
		alert("Du måste ange besöksort!");
		doc.txVisitCity.style.background = "white";
		doc.txVisitCity.focus();
		return false;
	}
	if (doc.txContactEmail.value == "") {
		doc.txContactEmail.style.background = "red";
		alert("Du måste ange e-postadress för kontaktformuläret!");
		doc.txContactEmail.style.background = "white";
		doc.txContactEmail.focus();
		return false;
	}
	if (doc.txImageCheck.value == "input" && doc.txImage.value == "") {
		var choice=confirm("Du har inte lagt till någon bild. \n\nVill du utelämna fältet, välj OK.\nVill du lägga till en bild, välj Avbryt.")
		if(choice == false){
			return false;
		}
	}
	if (doc.txCompFax.value == "-") doc.txCompFax.value = "";
	if (doc.txHomepage.value == "-") doc.txHomepage.value = "";
}
/*
function checkFormPages(){
	var doc = document.foo;
	if (doc.txTopic.value == "") {
		doc.txTopic.style.background = "red";
		alert("Du måste ange rubrik!");
		doc.txTopic.style.background = "white";
		doc.txTopic.focus();
		return false;
	}
	if (doc.txNews.value == "") {
		doc.txNews.style.background = "red";
		alert("Du måste ange text!");
		doc.txNews.style.background = "white";
		doc.txNews.focus();
		return false;
	}
}

function checkFormNews(){
	var doc = document.foo;
	if (doc.txTopic.value == "") {
		doc.txTopic.style.background = "red";
		alert("Du måste ange rubrik!");
		doc.txTopic.style.background = "white";
		doc.txTopic.focus();
		return false;
	}
	if (doc.txNews.value == "") {
		doc.txNews.style.background = "red";
		alert("Du måste ange text!");
		doc.txNews.style.background = "white";
		doc.txNews.focus();
		return false;
	}
}
*/
function checkFormGallery(){
	var doc = document.foo;
	if (doc.txType.value == "Övriga bilder" && doc.txType2.value == "") {
		alert("Du måste välja ett befintligt galleri eller skapa ett nytt!");
		return false;
	}
	if (doc.txBild.value == "") {
		alert("Du måste välja en bild!");
		return false;
	}
}
/*
function checkFormStaff(){
	var doc = document.foo;
	if (doc.txTitle.value == "") {
		doc.txTitle.style.background = "red";
		alert("Du måste ange befattning!");
		doc.txTitle.style.background = "white";
		doc.txTitle.focus();
		return false;
	}
	if (doc.txName.value == "") {
		doc.txName.style.background = "red";
		alert("Du måste ange namn!");
		doc.txName.style.background = "white";
		doc.txName.focus();
		return false;
	}
}

function checkFormOffers(){
	var doc = document.foo;
	if (doc.txTitle.value == "") {
		doc.txTitle.style.background = "red";
		alert("Du måste ange rubrik!");
		doc.txTitle.style.background = "white";
		doc.txTitle.focus();
		return false;
	}
	if (doc.txContent.value == "") {
		doc.txContent.style.background = "red";
		alert("Du måste ange text!");
		doc.txContent.style.background = "white";
		doc.txContent.focus();
		return false;
	}
	if (doc.txPrice.value == "") {
		doc.txPrice.style.background = "red";
		alert("Du måste ange pris!");
		doc.txPrice.style.background = "white";
		doc.txPrice.focus();
		return false;
	}
}
*/
/*
// Används ej!
function original_checkPrime() { 
	var doc=document;
	if(!doc.prime){
		doc.prime=new Array();
	}
	var i,j=doc.prime.length,a=checkPrime.arguments;
	var foo=a[0]
	var cha;
	for(i=1; i<a.length; i++){
		cha = doc.forms[foo].elements[a[i]].value;
		cha = replacePrime(cha)
		doc.forms[foo].elements[a[i]].value = cha;
	}
	return false;
}
*/	
function replacePrime(entry) {
var out,add,temp,pos
	out = '"';
	add = '&#34;';
	temp = "" + entry;
	while (temp.indexOf(out)>-1) {
		pos= temp.indexOf(out);
		temp = "" + (temp.substring(0, pos) + add + 
		temp.substring((pos + out.length), temp.length));
	}
	return temp;
}

function replaceEt(entry) {
var out,add,temp,pos
	out = "&";
	add = "[AND]";
	temp = "" + entry;
	while (temp.indexOf(out)>-1) {
		pos= temp.indexOf(out);
		temp = "" + (temp.substring(0, pos) + add + 
		temp.substring((pos + out.length), temp.length));
	}
	
	out = "[AND]";
	add = "&#38;";
	temp = "" + entry;
	while (temp.indexOf(out)>-1) {
		pos= temp.indexOf(out);
		temp = "" + (temp.substring(0, pos) + add + 
		temp.substring((pos + out.length), temp.length));
	}
	return temp;
}

function checkPrime(foo){
	var count,str
	for(count=0; count<document.forms[foo].elements.length; count++) {
		if (document.forms[foo].elements[count].name.substring(0,3) == 'ftx') {
			if (document.forms[foo].elements[count].value == "") {
				document.forms[foo].elements[count].style.background = "red";
				alert("Du måste fylla i detta fält!");
				document.forms[foo].elements[count].style.background = "white";
				document.forms[foo].elements[count].focus();
				return false;
			}
		}
		if (document.forms[foo].elements[count].name.substring(0,3) == 'otx') {
			if (document.forms[foo].elements[count].value == "") {
				document.forms[foo].elements[count].style.background = "red";
				var choice=confirm("Du har inte fyllt i detta fält. \n\nVill du utelämna fältet, välj OK.\nVill du skriva ett värde, välj Avbryt.")
				document.forms[foo].elements[count].style.background = "white";
				if(choice == false) {
					document.forms[foo].elements[count].focus();
					return false;
				}
				else {
					document.forms[foo].elements[count].value = "-";
				}
			}
		}
		if (document.forms[foo].elements[count].name.substring(0,4) == 'fetx') {
			if (!checkEmail(document.forms[foo].elements[count].value)) {
				document.forms[foo].elements[count].style.background = "red";
    			alert("Du måste ange en korrekt epostadress! fetx");
				document.forms[foo].elements[count].style.background = "white";
				document.forms[foo].elements[count].focus();
			    return false;
			}
		}
		if (document.forms[foo].elements[count].name.substring(0,4) == 'oetx') {
			if (document.forms[foo].elements[count].value == "") {
				document.forms[foo].elements[count].style.background = "red";
				var choice=confirm("Du har inte fyllt i detta fält. \n\nVill du utelämna fältet, välj OK.\nVill du skriva ett värde, välj Avbryt.")
				document.forms[foo].elements[count].style.background = "white";
				if(choice == false) {
					document.forms[foo].elements[count].focus();
					return false;
				}
				else {
					document.forms[foo].elements[count].value = "-";
				}
			}
			else {
				if (!checkEmail(document.forms[foo].elements[count].value) && document.forms[foo].elements[count].value != "-") {
				document.forms[foo].elements[count].style.background = "red";
    			alert("Du måste ange en korrekt epostadress! oetx++");
				document.forms[foo].elements[count].style.background = "white";
				document.forms[foo].elements[count].focus();
			    return false;
				}
			}
		}
	}
	for(count=0; count<document.forms[foo].elements.length; count++) {
		str = document.forms[foo].elements[count].value;
		str = replaceEt(str)
		str = replacePrime(str)
		document.forms[foo].elements[count].value = str;
		if (document.forms[foo].elements[count].value == "-") document.forms[foo].elements[count].value = "";
	}
}
function checkEmail(txMail) {
	var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
	var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";

	var reg1 = new RegExp(reg1str)
	var reg2 = new RegExp(reg2str)

	return ((!reg1.test(txMail)) && (reg2.test(txMail)))
}

//-----------------------------------------------------------------------------------------------------------------------------------

-->