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 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 displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> characters remaining'
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 get_date()
{
    //put the return of php's show_now func
    //to the javascript show_me func as a parameter
    x_show_now(show_me);
    //do it every 1 second
    setTimeout("get_date()", 1000);
    
    x_show_curr_online(show_curr);
    //do it every 1 second
    setTimeout("get_curr()", 1000);
}

function show_me(date_server)
{
   document.getElementById("date_div").innerHTML = "<font color='white'>"+ date_server +"</font>";
   
}

function show_curr(curr_user)
{
   document.getElementById("curr_div").innerHTML = "<font color='white'>"+ curr_user +"</font>";
   
}
// - AJAX END- Show current users
<!--
function KW_s(r, g, b, el) {
    d=document;hr=r.toString(16);hg=g.toString(16);hb=b.toString(16);
	hr=(hr.length==1)?"0"+hr:hr;hg=(hg.length==1)?"0"+hg:hg;hb=(hb.length==1)?"0"+hb:hb;
	if (d.getElementById) d.getElementById(el).style.color="#"+hr+hg+hb;
}

function KW_c(a,b,s,i) { return Math.floor(a*((s-i)/s)+b*(i/s)) }

function KW_fade(r,g,b,e,n,l,s,o){
    for(i=0;i<=s;i++)setTimeout("KW_s("+KW_c(r,e,s,i)+","+KW_c(g,n,s,i)+","+KW_c(b,l,s,i)+",'"+o+"');",i*s);
}

function checkBroswer(){
	
		if(navigator.userAgent.indexOf("Firefox") != -1)
		{
		   document.write('<link rel="stylesheet" type="text/css" href="include/ff.css">');
		}
		else if(navigator.userAgent.indexOf("MSIE") != -1)
		{
		   document.write('<link rel="stylesheet" type="text/css" href="include/style.css">');
		}
		else if(navigator.userAgent.indexOf("Netscape") != -1)
		{
		   document.write('<link rel="stylesheet" type="text/css" href="include/style.css">');
		}
		else
		{
		   document.write('<link rel="stylesheet" type="text/css" href="include/style.css">');
		}
	
}


//SELECT MENY
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}

//Gästboks-check
function Gb(){
	if (document.gbook.namn.value.length < 2){
		alert("You forgot your name!");
		return false;
	} else if (document.gbook.msg.value.length < 5){
		alert("You forgot the message!");
		return false;
	}
}

//Gästboks-check
function nlCheck(){
	if (document.nl.email.value.indexOf(' ') >= 0){
	 alert("Email addresses cannot have spaces in them");
	     return false;
	}else if (document.nl.email.value.indexOf('@') == -1){
	 	alert("A valid email address must have an @ in it");
		return false;
	}

}

//CreateUser Check
function createUser(){
	if (document.create.fname.value.length < 2){
		alert("You forgot your first name!");
		return false;
	} else if (document.create.lname.value.length < 2){
		alert("You forgot the last name!");
		return false;
	} else if (document.create.email.value.length < 2){
		alert("You forgot the email address!");
		return false;
	}else if (document.create.email.value.indexOf(' ') >= 0){
	        alert("Email addresses cannot have spaces in them");
	        return false;
	  }else if (document.create.email.value.indexOf('@') == -1){
	        alert("A valid email address must have an @ in it");
	       	return false;
   } else if (document.create.address.value.length < 2){
		alert("You forgot the address!");
		return false;
	 }else if (document.create.postal.value.length < 2){
		alert("You forgot the postal!");
		return false;
	}else if (document.create.city.value.length < 2){
		alert("You forgot the city!");
		return false;
	} else if (document.create.country.value.length < 2){
		alert("You forgot the country!");
		return false;
	} else if (document.create.password.value != document.create.password2.value){
		alert("You must type the password the same twice!");
		return false;
	}
	

}

//Mail Check
function checkMail(mail)
{
	 if(mail.length > 0)
   {
     if (mail.indexOf(' ') >= 0)
     {
        alert("email addresses cannot have spaces in them");
        return false;
     }
     else if (mail.indexOf('@') == -1)
     {
        alert("a valid email address must have an @ in it");
       	return false;
     }
   }
}

//Kolla om utskrift är gjord
function CheckIfPrintexists() {
		var pr=(window.print)?1:0;
		if (pr) return true;
		else return false;
}
//-->

//Lyrics-POP-UP
function popup(page){
popup = window.open(page,"" ,"height=350,width=350,scrollbars=yes,left=15, top=15");
}

//POP-UP
function topWindow(){
popup = window.open("flash/flash_mp3_player/flash_mp3_player/mp3player.html","" ,"height=320,width=370,scrollbars=no,left=650, top=0");
}
// End -->

//popup
function Bilden(filename,winTitle) 
{
    var myImage = new Image();
    myImage.src=filename;
    properties='height=10,width=10';
    var imgWindow = window.open('','',properties);
    
    html = '<html>';
    html += '<head>';
    html += '<title>'+winTitle+'</title>';
    html += '</head>';
    html += '<body topmargin="0" marginheight="0" leftmargin="0" marginwidth="0">';
    html += '<img src="'+myImage.src+'" onLoad="resizeTo(document.bild.width+25,document.bild.height+35);" name="bild" OnClick="self.close();">';
    html += '</body>';
    html += '</html>';
    
    imgWindow.document.write(html);
}
//-->

//SWAP IMAGES


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->

<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

//DISABLE FORM
function disableForm(theform) {
if (document.all || document.getElementById) {
for (i = 0; i < theform.length; i++) {
var tempobj = theform.elements[i];
if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
tempobj.disabled = true;
}
setTimeout('alert("Formuläret skulle ha skickats nu men detta är en demo. Skicka-knappen (submit-button) är nu avaktiverad för att förhindra att formuläret skickas flera gånger. Använd tangenten F5 för att uppdatera webläsaren om du vill prova igen.")', 1000);
return false;
}
else {
alert("Formuläret skulle ha skickats nu men detta är en demo. Du använder IE 4+ eller NS 6 och submit-knappen avaktiverades då inte.");
return false;
}
}
// End -->