

// Kollar maxlängden på ett textarea **********************'

/*
Form field Limiter script- By Dynamic Drive
For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
This credit MUST stay intact for use
*/

var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}


function displaylimit(theform,thelimit){
var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> tecken kvar.'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}


// ===============================================



function radfarg(rad,koll,radfarg){
	if(koll=="over"){
		var obj = document.getElementById(rad);
		obj.style.backgroundColor='#999999';
	}
	else{
		var obj = document.getElementById(rad);
		obj.style.backgroundColor=radfarg;
	}
}
  
function globconf(mess){
if(confirm(mess)){
return true;
}
else{
return false;
}
}

// Kollar om broesern godkänner cookies
function kollaKAKA(){
// Kontrollerar om läsaren tar cookies
kaka = navigator.cookieEnabled;
if(kaka){
	return true;
}
else{
	return false;
}
}

// Skriver ut en epost med @-bild
function antiEmailRobot(imgsrc, name, domain, klass){
document.write("<a href=" + "mail" + "t" + "o:" + name + "@" + domain + " class=" + klass + ">" + name + "<img valign=absmiddle src=" + imgsrc + " border=0>" + domain + "<"+"/"+"a>")
}

// Öppnar ett pop-up
function oppnafonster(lank,namn,fonsterVar){
	window.open( lank, namn, fonsterVar );
}

// Tar bort det fula runt klickade länkar
function fixUglyIE()
{
for (a in document.links) document.links[a].onfocus = document.links[a].blur;
}
if (document.all)
{
document.onmousedown = fixUglyIE;
}

// Skickar upp ett pop-up fönster med angiven bild
function BildPopUp(filename,winFoto,winText) 
{
    var myImage = new Image();
    myImage.src=filename;
    properties='height=30,width=30,scrollbars=yes,menubar=no,status=no';
    var imgWindow = window.open('','',properties);
    
    html = '<html>';
    html += '<head>';
    html += '<title>Foto: '+winFoto+'</title>';
    html += '</head>';
    html += '<body topmargin="10" marginheight="10" leftmargin="10" marginwidth="10" onload="focus();" bgcolor="#000000">';
    html += '<center>';
	html += '<table width="30" border="0" cellpadding="2" ><tr><td valign="top">';
    html += '<img src="'+myImage.src+'" onLoad="resizeTo(document.bild.width+80,document.bild.height+150);" name="bild" id="bild" alt="Klicka på bilden för att stänga" OnClick="self.close();"><br>';
	html += '</td></tr>';
	if(winText!=""){
		html += '<tr  bgcolor="#ffffff"><td valign="top">';
		html += '<font color="#000000" size="1" face="verdana">';  
		html += winText;  
		html += '</font>';
		html += '</td></tr>';	
	}
	if(winFoto!=""){
		html += '<tr  bgcolor="#ffffff"><td valign="top" align="right">';
		html += '<font color="#000000" size="1" face="verdana">';  
		html += '<b>Foto: '+winFoto+'</b>';  
		html += '</font>';
		html += '</td></tr>';	
	}
	html += '</table>';
	html += '</center>';
    html += '</body>';
    html += '</html>';
    
    imgWindow.document.write(html);
}


// Ändrar bakgrundsfargen på en angen rad, skicka med koll=over då det är mouseover
function AndraRadfarg(radid,koll,radfarg){
	if(koll=="over"){
		var obj = document.getElementById(radid);
		obj.style.backgroundColor=radfarg;
	}
	else{
		var obj = document.getElementById(radid);
		obj.style.backgroundColor='';
	}
}


// Koll om man vill radera något?
function return_raderakoll(){
if(confirm('Vill du radera posten?')){
	return true;
}
else{
	return false;
}
}


// Ändrar färgen på ett inputfält
function andraInputfarg(fo,inp,farg) {
	var obj = document.getElementById(inp);
	if(farg!=""){
		obj.style.background = farg;
	}
	else{
		obj.style.background = "#FFFFFF";
	}
}

function BrowserCheck() {
  var b = navigator.appName
  if (b=="Netscape") this.b = "ns"
  else if (b=="Microsoft Internet Explorer") this.b = "ie"
  else this.b = "ie";

  this.v = parseInt(navigator.appVersion)
  this.ns = (this.b=="ns" && this.v==4)
  this.ns4 = (this.b=="ns" && this.v==4)
  this.ie = ((this.b=="ie" && this.v>=4)||(this.b=="ns" && this.v>=5))
  this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
  this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
  this.moz = (this.b=="ns" && this.v>=5)

  if (this.ie5) this.v = 5
  this.min = (this.ns||this.ie)

  if(!this.ns) this.ie=true;
}


