function startList() {
	if (document.all && document.getElementById) {
		var navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				};
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				};
			}
		}
	}
}

function isDefined( checkVar ) {

    return ( typeof window[ checkVar ] == "undefined" ? false : true );
}

function highlight_artist(artist_id){

	elm = document.getElementById(artist_id);
	elm.style.color="#996633";
	
}

function outlight_artist(artist_id){
	elm = document.getElementById(artist_id);
	elm.style.color="#99cccc";

}

function setFocus(aField) {
document.getElementById("email").aField.focus();
}

function validate_nyhetsbrev(){
	
if(!isAnEmailAddress(document.getElementById("email").epost)){
	alert("Du m� skrive inn en gyldig epost adresse!");
	document.getElementById("email").epost.focus();
	return false;
}
 document.getElementById("email").submit();
 return true;
}

function isAnEmailAddress(epost) {
	// 1+@3+ [or x@x.x] is as close as we will test

	if (epost.value.length<5) {
	return false;
	}
	else if (epost.value.indexOf("@") < 1) {
	return false;
	}
	else if (epost.value.length -
	 epost.value.indexOf("@") < 4) {
	return false;
	}
	else { return true; }
	}

function validate_tips(){
if(!isAnEmailAddress(document.getElementById("email").epost1)){
	alert("Du m� skrive inn en gyldig epost adresse!");
	document.getElementById("email").epost1.focus();
	return false;
}else if(!isAnEmailAddress(document.getElementById("email").epost2)){
	alert("Du m� skrive inn en gyldig epost adresse!");
	document.getElementById("email").epost2.focus();
	return false;
	
}
 document.forms[0].submit();
 return true;
}




function image_preload(color){
	var img1 = new Image();
	img1.src = '/site_images/' + color + '/scroll.png';
	var elm = document.getElementById('dragimg');
	elm.src = img1.src;
}

function show_page(hider){
	var elm = document.getElementById(hider);
	elm.style.visibility = "hidden";
}

function opacity(hider,x){
	var elm = document.getElementById(hider);
	var op = x;
	
	if(op>=0){
		op = op - 0.01;
		elm.style.opacity = op;
		setTimeout("opacity('hider'," + op + ")",100);		
	}else if(op===0){show_page('hider');}
}

function pausecomp(Amount)
{
d = new Date(); //today's date
while (1)
{
mill=new Date(); // Date Now
diff = mill-d; //difference in milliseconds
if( diff > Amount ) {break;}
}
}

function breakout(){
	if (parent.frames.length > 0) {parent.location.href = location.href;}
}

function change_gallery_height(elm){
	alert(document.body.offsetHeight);
	alert(document.getElementById(elm).offsetHeight);
}

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin !== 0) {return null;}
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}
/**
*Gj�r om rel="external" til target="_blank"
*/
function externalLinks() {
 if (!document.getElementsByTagName) {return;}
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external"){
     anchor.target = "_blank";
   }
 }
} 