/*
     Javascript functions file for barnehagenmin.no
     Author : Kim Steinhaug
     Url : http://www.steinhaug.com/
     Email : firma@steinhaug.com
     
	 $Id: bhm.functions.js,v 1.6 2005/04/06 18:57:55 Administrator Exp $			
*/
function $(o) {
  if (typeof(o) == "string")
    return document.getElementById(o)
    else
    return o;
};

var swlib = {
  addCSSClass : function(elm, cls) {
    this.removeCSSClass(elm, cls);
    var ar = this.explode(' ', elm.className);
    ar[ar.length] = cls;
    elm.className = ar.join(' ');
  },
  removeCSSClass : function(elm, cls) {
    var ar = this.explode(' ', elm.className);

    for (var i=0; i<ar.length; i++) {
      if (ar[i] == cls)
        ar[i] = '';
      }

    elm.className = ar.join(' ');
  },
  explode : function(d, s) {
    var ar = s.split(d);
    var oar = new Array();

    for (var i = 0; i<ar.length; i++) {
      if (ar[i] != "")
        oar[oar.length] = ar[i];
    }
      return oar;
    }
}; 


function findObj(n, d) { //v4.0
  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=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}


	function chkData() {
		if(document.sw.usr.value <= 0)
			{alert("Skriv inn ditt brukernavn");
			document.sw.usr.value = '';
			document.sw.usr.focus();
			return false;}
		if(document.sw.pas.value <= 0)
			{alert("Skriv inn ditt passord");
			document.sw.pas.value = '';
			document.sw.pas.focus();
			return false;}
	}

function zoom(header,alt,url,Xvalue,Yvalue,scroll) {
	Xvalue = Number(Xvalue) + 20;
	Yvalue = Number(Yvalue) + 60;
	if (scroll) {
        i = open("", "EUindow","top=50,left=50,width="+Xvalue+",height="+Yvalue+",status=no,toolbar=no,menubar=no,resize=no,dependent=yes,scrollbars=yes");
	}
	else {
        i = open("", "EUindow","top=50,left=50,width="+Xvalue+",height="+Yvalue+",status=no,toolbar=no,menubar=no,resize=no,dependent=yes,scrollbars=no");
	}
	i.focus();
        i.document.open();
        i.document.write('<html>\n')
        i.document.write('<head>\n')
        i.document.write('<title>EasyWebshop bilde forhåndsvisning</title>\n')
        i.document.write('<style><!--\n')
        i.document.write('body { \n')
        i.document.write('margin : 0px 0px 0px 0px;\n')
        i.document.write('}\n')
        i.document.write('--></style>\n')
        i.document.write('<\head>\n')
        i.document.write('<body bgcolor="#ffffff" text="#000000">\n')
        i.document.write('<center>\n')
        i.document.write('<div style="font-size:14px; font-weight:bold; font-family:verdana,arial,sans-serif,helvetica;">',header,'</div><a href="javascript:window.close();"><img src="',url,'" border="2" style="border:2px solid white;" alt="',alt,'"></a>\n')
        i.document.write('<div style="font-size:10px;font-family:verdana;color:#808080;">&copy; Barnehagenmin (c) Steinhaug Webdevelopment</div></center>\n')
        i.document.write('</body>\n')
        i.document.write('</html>\n');
        i.document.close();
}
function easyCMS_zoom(header,alt,url,Xvalue,Yvalue,scroll) {
	Xvalue = Number(Xvalue) + 20;
	Yvalue = Number(Yvalue) + 60;
	if (scroll) {
        i = open("", "EUindow","top=50,left=50,width="+Xvalue+",height="+Yvalue+",status=no,toolbar=no,menubar=no,resize=no,dependent=yes,scrollbars=yes");
	}
	else {
        i = open("", "EUindow","top=50,left=50,width="+Xvalue+",height="+Yvalue+",status=no,toolbar=no,menubar=no,resize=no,dependent=yes,scrollbars=no");
	}
	i.focus();
        i.document.open();
        i.document.write('<html>\n')
        i.document.write('<head>\n')
        i.document.write('<title>Easy CMS - ' + alt + '</title>\n')
        i.document.write('<style><!--\n')
        i.document.write('body { \n')
        i.document.write('margin : 0px 0px 0px 0px;\n')
        i.document.write('}\n')
        i.document.write('--></style>\n')
        i.document.write('<\head>\n')
        i.document.write('<body bgcolor="#ffffff" text="#000000">\n')
        i.document.write('<center>\n')
        i.document.write('<div style="font-size:14px; font-weight:bold; font-family:verdana,arial,sans-serif,helvetica;">',header,'</div><a href="javascript:window.close();"><img src="',url,'" border="2" style="border:2px solid white;" alt="',alt,'"></a>\n')
        i.document.write('<div style="font-size:10px;font-family:verdana;color:#808080;">&copy; Easy CMS 2004</div></center>\n')
        i.document.write('</body>\n')
        i.document.write('</html>\n');
        i.document.close();
}
function ValidateEmail(theinput)
{
	s=theinput.value
	if(s.search)
	{
		return (s.search(new RegExp("^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,4}$","gi"))>=0)
	}
	if(s.indexOf)
	{
		at_character=s.indexOf('@')
		if(at_character<=0 || at_character+4>s.length)
			return false
	}
	if(s.length<6)
		return false
	else
		return true
}
function swPOP(url,Xvalue,Yvalue,scroll) {
  var w = 480, h = 340;if (document.all || document.layers) { w = screen.availWidth;h = screen.availHeight; }
  var popW = Xvalue, popH = Yvalue;var leftPos = (w-popW)/2, topPos = (h-popH)/2;
  if (scroll) { i = open(url, "displayWindow","top="+topPos+",left="+leftPos+",width="+Xvalue+",height="+Yvalue+",status=no,toolbar=1,menubar=no,resize=no,dependent=yes,scrollbars=yes");} else { i = open(url, "displayWindow","top="+topPos+",left="+leftPos+",width="+Xvalue+",height="+Yvalue+",status=1,toolbar=1,menubar=0,resize=no,dependent=yes,scrollbars=no");}
}

