function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function getStyle(oElm, strCssRule){
    var strValue = "";
    if(document.defaultView && document.defaultView.getComputedStyle){
        strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
    }
    else if(oElm.currentStyle){
        strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
            return p1.toUpperCase();
        });
        strValue = oElm.currentStyle[strCssRule];
    }
    return strValue;
}

function toggleLayer(whichLayer)
{
	if (document.getElementById) {
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
	} else if (document.all) {
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
	} else if (document.layers) {
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
	} else {
		var style2 = document.getElementById(whichLayer).style;
	}

	if (style2.display == "block"){
		style2.display = "none";
	} else if(style2.display == "none") {
		style2.display = "block";
	} else {
		style = getStyle(document.getElementById(whichLayer), "display");
		if (style == "block"){
			style2.display = "none";
		} else if(style == "none") {
			style2.display = "block";
		} else {
			style2.display = "block";
		}
	}
}

function showLayer(whichLayer)
{
	if (document.getElementById) {
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
	} else if (document.all) {
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
	} else if (document.layers) {
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
	} else {
		var style2 = document.getElementById(whichLayer).style;
	}

	style2.display = "block";
}

function hideLayer(whichLayer)
{
	if (document.getElementById) {
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
	} else if (document.all) {
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
	} else if (document.layers) {
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
	} else {
		var style2 = document.getElementById(whichLayer).style;
	}
	style2.display = "none";
}

function setInnerHTML(whichLayer, txt)
{
    if (document.getElementById) {
        // this is the way the standards work
        var element = document.getElementById(whichLayer);
    } else if (document.all) {
        // this is the way old msie versions work
        var element = document.all[whichLayer];
    } else if (document.layers) {
        // this is the way nn4 works
        var element = document.layers[whichLayer];
    } else {
        var element = document.getElementById(whichLayer);
    }
    
    element.innerHTML = txt;
}


function changeBackground(whichLayer, color)
{
	if (document.getElementById) {
		var style3 = document.getElementById(whichLayer).style;
	} else if (document.all) {
		var style3 = document.all[whichLayer].style;
	} else if (document.layers) {
		var style3 = document.layers[whichLayer].style;
	} else {
		var style3 = document.getElementById(whichLayer).style;
	}

	style3.background = color;
}

//	var star = document.getElementByID("starscore1");
//  var select = document.getElementByID(name);
//	document.starscore1.src = "images/staroff.gif";
//	document.img.src = "images/staroff.gif";

function Browser() {
  var agent;
  var app;
  var i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  agent = navigator.userAgent;

  app = "MSIE";
  if ((i = agent.indexOf(app)) >= 0){
    this.isIE = true;
  } else {
    this.isNS = true;
  }
}

var browser = new Browser();
var dragObj = new Object();
dragObj.zIndex = 0;

function startDrag(event, div) {

  var el;
  var x, y;
  
  dragObj.elNode = document.getElementById(div);

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  } else {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = window.event.clientX - 10;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = window.event.clientY - 10;
 
  // dragObj.elNode.style.zIndex = ++dragObj.zIndex;
                          
  if (browser.isIE) {
    document.attachEvent("onmousemove", drag);
    document.attachEvent("onmouseup",   stopDrag);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  } else {
    document.addEventListener("mousemove", drag,   true);
    document.addEventListener("mouseup",   stopDrag, true);
    event.preventDefault();
  }
}

function drag(event) {

  var x, y;
  
  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  } else {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }   

  dragObj.elNode.style.left =
    (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  =
    (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }else {
    event.preventDefault();
  }
}

function stopDrag(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", drag);
    document.detachEvent("onmouseup",   stopDrag);
  } else {
    document.removeEventListener("mousemove", drag,   true);
    document.removeEventListener("mouseup",   stopDrag, true);
  }
}

<!--************************************************************************-->
<!--* Drag functions above are inspired by a tutorial:                     *-->
<!--* Generic Drag Demo                                                    *-->
<!--*                                                                      *-->
<!--* Copyright 2001 by Mike Hall                                          *-->
<!--* Please see http://www.brainjar.com for terms of use.                 *-->
<!--************************************************************************-->

function toggleLayerTop(div){
	toggleLayer(div);
	toTopScreen(div);
}

function toTopScreen(div){
	
	if (browser.isIE) {
	    y = document.documentElement.scrollTop + document.body.scrollTop;
	 } else {
	    y = window.scrollY;
	 }

	box = document.getElementById(div);
	box.style.top = (y + 90) + "px";
}

function getElement(whichLayer)
{
    if (document.getElementById) {
        // this is the way the standards work
        return document.getElementById(whichLayer);
    } else if (document.all) {
        // this is the way old msie versions work
        return document.all[whichLayer];
    } else if (document.layers) {
        // this is the way nn4 works
        return document.layers[whichLayer];
    } else {
        return document.getElementById(whichLayer);
    }
}

function utf8_decode (str_data) {
    // Converts a UTF-8 encoded string to ISO-8859-1  
    // 
    // version: 1109.2015
    // discuss at: http://phpjs.org/functions/utf8_decode
    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +      input by: Aman Gupta
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Norman "zEh" Fuchs
    // +   bugfixed by: hitwork
    // +   bugfixed by: Onno Marsman
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: utf8_decode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'
    var tmp_arr = [],
        i = 0,
        ac = 0,
        c1 = 0,
        c2 = 0,
        c3 = 0;
 
    str_data += '';
 
    while (i < str_data.length) {
        c1 = str_data.charCodeAt(i);
        if (c1 < 128) {
            tmp_arr[ac++] = String.fromCharCode(c1);
            i++;
        } else if (c1 > 191 && c1 < 224) {
            c2 = str_data.charCodeAt(i + 1);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
            i += 2;
        } else {
            c2 = str_data.charCodeAt(i + 1);
            c3 = str_data.charCodeAt(i + 2);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
            i += 3;
        }
    }
 
    return tmp_arr.join('');
}

function utf8_encode (argString) {
    // Encodes an ISO-8859-1 string to UTF-8  
    // 
    // version: 1109.2015
    // discuss at: http://phpjs.org/functions/utf8_encode
    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: sowberry
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman
    // +   improved by: Yves Sucaet
    // +   bugfixed by: Onno Marsman
    // +   bugfixed by: Ulrich
    // +   bugfixed by: Rafal Kukawski
    // *     example 1: utf8_encode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'
    if (argString === null || typeof argString === "undefined") {
        return "";
    }
 
    var string = (argString + ''); // .replace(/\r\n/g, "\n").replace(/\r/g, "\n");
    var utftext = "",
        start, end, stringl = 0;
 
    start = end = 0;
    stringl = string.length;
    for (var n = 0; n < stringl; n++) {
        var c1 = string.charCodeAt(n);
        var enc = null;
 
        if (c1 < 128) {
            end++;
        } else if (c1 > 127 && c1 < 2048) {
            enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
        } else {
            enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
        }
        if (enc !== null) {
            if (end > start) {
                utftext += string.slice(start, end);
            }
            utftext += enc;
            start = end = n + 1;
        }
    }
 
    if (end > start) {
        utftext += string.slice(start, stringl);
    }
 
    return utftext;
}

