//showHide, MM_openBrWindow, AddText, helptext, textareaSize, textSIze

function showHide(fieldName) {
	if (document.getElementById(fieldName).style.display == "none") {
		document.getElementById(fieldName).style.display = "";
		document.getElementById( fieldName + "_btn" ).src = "bilder/cms/minus.gif";
	} else {
		document.getElementById(fieldName).style.display = "none";
		document.getElementById( fieldName + "_btn" ).src = "bilder/cms/plus.gif";
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function AddText(Action){
	var AddTxt="";
	var txt="";
	
	if(Action == 1){  
		txt = prompt("Ange den text som ska vara understruken.\n[u]xxx[/u]","");      
		if(txt != null) {
			AddTxt = "[u]" + txt + "[/u]";
		}
	}

	if(Action == 2){  
		txt = prompt("Ange den text som ska vara bold.\n[b]xxx[/b]","");      
		if(txt!=null) {
			AddTxt = "[b]" + txt + "[/b]";
		}
	}
	
	if(Action == 3){  
		txt = prompt("Ange den text som ska vara italic (kursiv).\n[i]xxx[/i]","");      
		if(txt!=null) {
			AddTxt = "[i]" + txt + "[/i]";
		}
	}
	
	if(Action == 4) {  
		txt = prompt("Ange den text som ska vara under-rubrik.\n[ur]xxx[/ur]","");      
		if(txt!=null) {
			AddTxt = "[ur]" + txt + "[/ur]";
		}
	}
	
	if(Action == 5) {  
		txt = prompt("Ange adressen för länken.\n[link=xxx][/link]","http://");      
		if(txt != null) {          
			AddTxt = "[link=" + txt + "]";              
			txt = prompt("Ange den synliga texten för länken.\n[link=" + txt + "]xxx[/link]","");              
			AddTxt += "" + txt + "[/link]\r\n";         
		}
	}
	
	if(Action == 6) AddTxt="\r\n[line]\r\n";
	
	if(Action == 7) {  
		txt = prompt("Ange den text som ska vara centrerad.\n[center]xxx[/center]","");      
		if(txt!=null) {
			AddTxt = "[center]" + txt + "[/center]";
		}
	}

	if(Action == 8) {  
		txt = prompt("Ange vems citatet är.\n[right]xxx[/right]","");      
		if(txt != null) {          
			AddTxt = "[right]" + txt + "[/right]";      
		}
	}
	
	if(Action == 9) {  
		txt = prompt("Ange adressen för bilden.\n[img=xxx]","");      
		if(txt != null) {          
			AddTxt = "[img=" + txt + "]";      
		}
	}

	if(Action == 10) {  
		txt = prompt("Ange mejl-adressen.\n[mail=xxx@xxx.xxx]xxx[/mail]","");      
		if(txt != null) {          
			AddTxt = "[mail=" + txt + "]";              
			txt = prompt("Ange den klickbara texten för länken.\n[mail=" + txt + "]xxx[/mail]","");              
			AddTxt += txt + "[/mail]\r\n";         
		}
	}
	
	if(Action == 11) {  
		txt = prompt("Ange bredden för tabellen i pixlar.\n[table w=xxx xxx][/table]","");
		if(txt != null) {
			AddTxt = "[table w=" + txt;              
			txt = prompt("Ange den horisontella justeringen: left/center/right/[blank].\n" + AddTxt + " xxx][/table]","");      
			AddTxt += " " + txt + "]\n\r\n\r[/table]";
		}
	}
	
	if(Action == 12) AddTxt="[row]\n\r[/row]";
	
	if(Action == 13) {  
		txt = prompt("Ange bredden för cellen i pixlar.\n[cell w=xxx xxx xxx][/cell]","");
		if(txt != null) {
			AddTxt = "[cell w=" + txt;              
			txt = prompt("Ange den horisontella justeringen: left/center/right/[blank].\n" + AddTxt + " xxx xxx][/cell]","");              
			AddTxt += " " + txt;
			txt = prompt("Ange den vertikala justeringen: top/center/bottom/[blank].\n" + AddTxt + " xxx][/cell]","");              
			AddTxt += " " + txt + "][/cell]";
		}
	}
	
	if(Action == 14) {  
		txt = prompt("Ange bredden för rubrikfältet.\n[title w=xxx]","");
		if(txt != null) {
			AddTxt = "[title w=" + txt + "]";
		}
	}
	
	if(Action == 15) {  
		txt = prompt("Ange bredden för brödtext-fältet.\n[body w=xxx]","");
		if(txt != null) {
			AddTxt = "[body w=" + txt + "]";
		}
	}
	
	if(Action == 16) {  
		txt = prompt("Ange bredden för bildtext-fältet.\n[imgtext w=xxx xxx]","");
		if(txt != null) {
			AddTxt = "[imgtext w=" + txt;
			txt = prompt("Ange den horisontella justeringen: left/center/right/[blank].\n" + AddTxt + " xxx]","");              
			AddTxt += " " + txt + "]";
		}
	}
	
	if(Action == 17) {  
		txt = prompt("Ange bredden för bild-fältet.\n[image w=xxx h=xxx xxx]","");
		if(txt != null) {
			AddTxt = "[image w=" + txt;
			txt = prompt("Ange höjden för bild-fältet.\n" + AddTxt + " h=xxx xxx]","");
			AddTxt += " h=" + txt;
			txt = prompt("Ange om bilden ska beskäras eller anpassas till fältet: beskär/anpassa.\n" + AddTxt + " xxx]","");              
			AddTxt += " " + txt + "]";
		}
	}
	
	if(Action == 18) {  
		txt = prompt("Ange bredden för bild-fältet.\n[image2 w=xxx h=xxx xxx]","");
		if(txt != null) {
			AddTxt = "[image2 w=" + txt;
			txt = prompt("Ange höjden för bild-fältet.\n" + AddTxt + " h=xxx xxx]","");
			AddTxt += " h=" + txt;
			txt = prompt("Ange om bilden ska beskäras eller anpassas till fältet: beskär/anpassa.\n" + AddTxt + " xxx]","");              
			AddTxt += " " + txt + "]";
		}
	}
	
	if(Action == 19) {  
		txt = prompt("Ange bredden för bild-fältet.\n[image3 w=xxx h=xxx xxx]","");
		if(txt != null) {
			AddTxt = "[image3 w=" + txt;
			txt = prompt("Ange höjden för bild-fältet.\n" + AddTxt + " h=xxx xxx]","");
			AddTxt += " h=" + txt;
			txt = prompt("Ange om bilden ska beskäras eller anpassas till fältet: beskär/anpassa.\n" + AddTxt + " xxx]","");              
			AddTxt += " " + txt + "]";
		}
	}
	
	if(Action == 20) {  
		txt = prompt("Ange bredden för bild-fältet.\n[image4 w=xxx h=xxx xxx]","");
		if(txt != null) {
			AddTxt = "[image4 w=" + txt;
			txt = prompt("Ange höjden för bild-fältet.\n" + AddTxt + " h=xxx xxx]","");
			AddTxt += " h=" + txt;
			txt = prompt("Ange om bilden ska beskäras eller anpassas till fältet: beskär/anpassa.\n" + AddTxt + " xxx]","");              
			AddTxt += " " + txt + "]";
		}
	}
	
	if(Action == 21) {  
		txt = prompt("Ange bredden för bild-fältet.\n[image5 w=xxx h=xxx xxx]","");
		if(txt != null) {
			AddTxt = "[image5 w=" + txt;
			txt = prompt("Ange höjden för bild-fältet.\n" + AddTxt + " h=xxx xxx]","");
			AddTxt += " h=" + txt;
			txt = prompt("Ange om bilden ska beskäras eller anpassas till fältet: beskär/anpassa.\n" + AddTxt + " xxx]","");              
			AddTxt += " " + txt + "]";
		}
	}
	
	if(Action == 22) {  
		txt = prompt("Ange bredden för spacern.\n[spacer w=xxx h=xxx]","");
		if(txt != null) {
			AddTxt = "[spacer w=" + txt;
			txt = prompt("Ange höjden för spacern.\n" + AddTxt + " h=xxx]","");
			AddTxt += " h=" + txt + "]";
		}
	}
	
	if(Action == 23) {
		AddTxt = "[table w=380 ]\r\n[row][cell][/cell][/row]\r\n[/table]";
	}
	
textForm.body.value += AddTxt;
}

function helptext(helpId) {
	if (helpId == 1) { 
		textForm.helpbox.value = "Understruken text: [u]xxx[/u]";
	}
	
	if (helpId == 2) { 
		textForm.helpbox.value = "Bold: [b]xxx[/b]";
	}
	
	if (helpId == 3) { 
		textForm.helpbox.value = "Kursiv stil: [i]xxx[/i]";
	}
	
	if (helpId == 4) { 
		textForm.helpbox.value = "Under-rubrik: [ur]xxx[/ur]";
	}
	
	if (helpId == 5) { 
		textForm.helpbox.value = "Länk: [link=http://xxx]xxx[/link]";
	}
	
	if (helpId == 6) { 
		textForm.helpbox.value = "Horiontell linje: [line]";
	}
	
	if (helpId == 7) { 
		textForm.helpbox.value = "Centrerad text: [center]xxx[/center]";
	}
	
	if (helpId == 8) { 
		textForm.helpbox.value = "Högerställd text: [right]xxx[/right]";
	}
	
	if (helpId == 9) { 
		textForm.helpbox.value = "Högerställd text: [img=http://xxx]";
	}
	
	if (helpId == 10) { 
		textForm.helpbox.value = "Mejl-länk: [mail=xxx@xxx.xxx]xxx[/mail] Tips: mejladresser blir automatiskt klickbara.";
	}
	
	if (helpId == 11) { 
		textForm.helpbox.value = "Tabell: [table w=300 right][/table]";
	}
	
	if (helpId == 12) { 
		textForm.helpbox.value = "Tabell-rad: [row][/row]";
	}
	
	if (helpId == 13) { 
		textForm.helpbox.value = "Tabell-cell: [cell w=150 right top][/cell]";
	}
	
	if (helpId == 14) { 
		textForm.helpbox.value = "Rubrik-fält: [title w=250]";
	}
	
	if (helpId == 15) { 
		textForm.helpbox.value = "Brödtext-fält: [body w=250]";
	}
	
	if (helpId == 16) { 
		textForm.helpbox.value = "Bildtext-fält: [imgtext w=250 xxx]";
	}
	
	if (helpId == 17) { 
		textForm.helpbox.value = "Bild-fält: [image(+2-5) w=90 h=90 beskär/anpassa]";
	}
	
	if (helpId == 22) {
		textForm.helpbox.value = "Spacer (genomskinlig .gif): [spacer w=1 h=10]";
	}
	
	if (helpId == 23) {
		textForm.helpbox.value = "Startkitt: [table w=380 ][row][cell][/cell][/row][/table]";
	}
}

function textareaSize(direction) {
  var txtarea = document.textForm.body;
  var bildtxtarea = document.textForm.bildtext;
  if (direction == 1) {
    txtarea.rows = txtarea.rows + 5;
	bildtxtarea.rows = bildtxtarea.rows + 3;
  } else {
    txtarea.rows = txtarea.rows - 5
	bildtxtarea.rows = bildtxtarea.rows - 3;
  }
}


function textSize(id, direction) {
	if (direction == 1) {
    	document.textForm.body.style.fontWeight = 'bold';
		document.textForm.body.style.fontSize = '12px';
		document.textForm.bildtext.style.fontWeight = 'bold';
		document.textForm.bildtext.style.fontSize = '12px';
		document.textForm.title.style.fontSize = '24px';
	} else {
		document.textForm.body.style.fontWeight = 'normal';
		document.textForm.body.style.fontSize = '10px';
		document.textForm.bildtext.style.fontWeight = 'normal';
		document.textForm.bildtext.style.fontSize = '10px';
		document.textForm.title.style.fontSize = '18px';
	}
}

function validRequired(formField,fieldLabel)
{
	var result = true;
	
	if (formField.value == "")
	{
		alert('<%= sAlert %>');
		formField.focus();
		result = false;
	}
		
	return result;
}

function validateForm(theForm)
{
	// Customize these calls for your form

	// Start ------->
	if (!validRequired(theForm.namn,"<%= sNamn %>"))
		return false;
	
	if (!validRequired(theForm.email,"email"))
		return false;

	if (!validRequired(theForm.body,"text"))
		return false;

	// <--------- End
	
	return true;
}