
	
	
	var its;
	var browserName;
	var browserNameLong;
	var browserNew;
	var preloadFlag = false;
	var Macintosh = navigator.userAgent.indexOf('Mac')>0;

	function its() {
		var n = navigator;
		var ua = ' ' + n.userAgent.toLowerCase();
		var pl = n.platform.toLowerCase();
		var an = n.appName.toLowerCase();

		// browser version
		this.version = n.appVersion;
		this.nn = ua.indexOf('mozilla') > 0;

		// 'compatible' versions of mozilla aren't navigator
		if(ua.indexOf('compatible') > 0) {
			this.nn = false;
		}		
		this.opera = ua.indexOf('opera') > 0;
		this.ie = ua.indexOf('msie') > 0;
		this.major = parseInt( this.version );
		this.minor = parseFloat( this.version );

		// platform
		this.mac = ua.indexOf('mac') > 0;
		this.win = ua.indexOf('win') > 0;

		// workaround for IE5 which reports itself as version 4.0
		if(this.ie) {
			if(ua.indexOf("msie 5") > 1) {
			var msieIndex = navigator.appVersion.indexOf("MSIE") + 5;
			this.major = parseFloat(navigator.appVersion.substr(msieIndex,3));
			}
		}

		return this;
	}

	function browserNaming() {
		its = new its();
		range1 	 = "getElementById('";
		range2 	 = "')";
		styleObj = ".style";

		// is it a DOM-enabled browser?
		if (!document.getElementById) {
			browserNew = false;
		}
		else {
			browserNew = true;
		}
		// need the name, too
		if (its.opera) {
			browserName = "Opera";
		}
		else if (its.ie) {
			browserName = "IE";
			range1 	 = "all.";
			range2 	 = "";
			styleObj = ".style";
		}
		else {
			browserName = "NS";
			
			range1 	 = "layers.";
			range2 	 = "";
			styleObj = "";
		}
		// and the number
		browserNameLong = browserName + its.major;
		//alert(browserNameLong + ' ' + browserNew);
	}
	// if, for instance, the browser is IE5, here's what you get:
	// browserNew = true, browserName = IE, browserNameLong = IE5
	
	function spawn(URL,windowName,width,height) {
 		window.open(URL, windowName, "toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,width="+width+",height="+height+",resizable=no" );
	}

	function spawnscroll(URL,windowName,width,height) {
		 window.open(URL, windowName, "toolbar=no,location=no,status=1,menubar=no,scrollbars=1,width="+width+",height="+height+",resizable=yes" );
	}
	
// DOM / GET PROPERTY
// original code from http://www.alistapart.com/
// NOTES:	given an id and a property (as strings), return the given property of that id.
// WORKS:	ie5+, ns6+, opera5+
	function getIdProperty(id,property) {
		var styleObject = document.getElementById( id );
		if (styleObject != null) {
			styleObject = styleObject.style;
				if (styleObject[property]) {
					return styleObject[ property ];
				}
			}
		return (styleObject != null) ?
		styleObject[property] :
		null;
	}

// DOM / SET PROPERTY
// original code from http://www.alistapart.com/
//
// NOTES:	given an id and a property (as strings), set the given property of that id to the value provided.
// WORKS:	ie5+, ns6+, opera5+

	function setIdProperty(id,property,value) {
		var styleObject = document.getElementById( id );
		if (styleObject != null) {
			styleObject = styleObject.style;
			styleObject[ property ] = value;
		}
	}

// does the same, but within a frame
	function setIdPropertyParent(id,property,value) {
		var styleObject = parent.document.getElementById( id );
		if (styleObject != null) {
			styleObject = styleObject.style;
			styleObject[ property ] = value;
		}
	}

// DOM / MASTER MOVE FUNCTION
// original code from http://www.alistapart.com/
// USAGE:	used within other functions
// NOTES:	If additive is true, then move it by xValue dots horizontally and yValue units vertically.
//			If additive is false, then move it to (xValue, yValue).
// WORKS:	ie5+, ns6+, opera5+
	function generic_move(id,xValue,yValue,additive ) {
		var left = parseInt(getIdProperty(id, "left"));
		var top = parseInt(getIdProperty(id, "top"));
		if (additive) {
			setIdProperty(id,"left",left + xValue);
			setIdProperty(id,"top",top + yValue);
		}
		else {
			setIdProperty(id,"left",xValue);
			setIdProperty(id,"top",yValue);
		}
	}

// NON-DOM / MASTER MOVE FUNCTION
// USAGE:	used within other functions
// NOTES:	If additive is true, then move it by xValue dots horizontally and yValue units vertically.
//			If additive is false, then move it to (xValue, yValue).
// WORKS:	ie4, ns4
	function generic_move_nondom(id,xValue,yValue,additive) {
		// gets the id
		if (browserName == "NS") {
			var thisLayer = document.layers[id];
		}
		else {
			var thisLayer = document.all[id].style;
		}
		// gets the present values
		thisLayer.xpos = parseInt(thisLayer.left);
		thisLayer.ypos = parseInt(thisLayer.top);
		// move to, or move by?
		if (additive) {
			thisLayer.xpos += xValue;
			thisLayer.ypos += yValue;
			thisLayer.left = thisLayer.xpos;
			thisLayer.top = thisLayer.ypos;
		}
		else {
			thisLayer.left = xValue;
			thisLayer.top = yValue;
		}
	}


//  Move a given id to position (xValue, yValue)
// original code from http://www.alistapart.com/	
	function moveTo(id,x,y) {
		if (browserNew) {
			generic_move(id,x,y,false);
		}
		else {
			generic_move_nondom(id,x,y,false);
		}
	}

// Move a given id to (currentX + xValue, currentY + yValue)
// original code from http://www.alistapart.com/
	function moveBy(id,x,y) {
		if (browserNew) {
			generic_move(id,x,y,true);
		}
		else {
			generic_move_nondom(id,x,y,true);
		}
	}


// HIDE AND SHOW LAYERS (ON THE SAME PAGE)
// USAGE:	show('layername'); hide('layername');
// WORKS:	ie4+, ns4+, opera

	function hide(id) {
		if (browserNew) {
			setIdProperty(id,"visibility","hidden");
		}
		else {
			if (browserName == "NS") { 
				document.layers[id].visibility = "hide"; 
			}
			else { 
				document.all[id].style.visibility = "hidden"; 
			}
		}
	}

	function show(id) {
		if (browserNew) {
			setIdProperty(id,"visibility","visible");
		}
		else {
			if (browserName == "NS") { 
				document.layers[id].visibility = "show"; 
			}
			else { document.all[id].style.visibility = "visible"; }
		}
	}


// HIDE AND SHOW LAYERS (IN ANOTHER FRAME)
// USAGE:	showToo('layername'); hideToo('layername');
// WORKS:	ie4+, ns4+, opera

	function showToo(id) {
		if (browserNew) {
			setIdPropertyParent(id,"visibility","visible");
		}
		else {
			parent.document.all[id].style.visibility = "visible";
		}
	}

	function hideToo(id) {
		if (browserNew) {
			setIdPropertyParent(id,"visibility","hidden");
		}
		else {
			parent.document.all[id].style.visibility = "hidden";
		}
	}

	// getObj('lager1,lager2',true) <--- Detta blir ett och samma objekt i alla browsers
	// only to be used in emergency cases...
	function getObj(divs,haveStyle) {
		var tmpObj = "";
		var Arrobj = divs.split(",");

		if ((browserName == "NS") && (!browserNew) && Arrobj.length > 1) {
			for (var i=0; i < Arrobj.length-1; i++) {
				tmpObj += "document."+ range1 + Arrobj[i] +".";
			}
		}
		var mainTarget = Arrobj[Arrobj.length-1];
		if (typeof divs == "string") {
			if ((haveStyle) &! (browserName == "NS")) {
				tmpObj = eval("document." + range1 + mainTarget + range2 + styleObj)
			}
			else {
				tmpObj = eval(tmpObj +"document." + range1 + mainTarget + range2);
			}
		}
		else {
			tmpObj = obj;
		}
		return tmpObj;
	}

	
	function writeDiv(obj,str) {
		var element;
		if (browserNew) {
		  element=document.getElementById(obj);
		  element.innerHTML = str;
		}
		else if ((browserName == "NS") && (!browserNew)) {
			element = getObj(obj,false);
			element.document.open();
			element.document.write(""+ str +"");
			element.document.close();
		}
	}
	




//  preload('m5on','/img/m5on.gif');
function preload(imgObj,imgSrc) {
	if (document.images) {
    	eval(imgObj+' = new Image()');
        eval(imgObj+'.src = "'+imgSrc+'"');
    }
}

//var preloadFlag = false;
function rolla(bild,ny) {
	if ((document.images) && (preloadFlag))  {
		document.images[bild].src = eval(ny+'.src');
	}
}

function emptyInput(str,obj) {
  if (obj.value== str) {
    obj.value = '';
	return true;
  }
}

function refillInput(str,obj) {
  if (obj.value=='') {
    obj.value = str;
	return true;
  }
}

function checkEmail(field) {
	//if (field.value.indexOf("@") == -1) {
	if (isEmail(field.value) != true) {
    	alert("please enter a valid email-address");
		field.focus();
		field.blur();
		field.select();
		return false;
  	}
}

function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) {
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  }
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
  
}