// <script type="text/javascript" src="tools.js"><./script><!--SetCookie, getMailto, Mailto, writeMail, writeMailLink, popup, popPlayer, fixpng-->


var ie_5_6 = (/MSIE (5|6)/.test(navigator.userAgent));
if(navigator.userAgent.indexOf('Opera')>0) ie_5_6=false;

function SetCookie(name,value) { //you can supply "days" as 3rd arg.
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var days = (argc > 2) ? argv[2] : 720; //default 720
  var date = new Date();
  date.setTime(date.getTime()+(days*24*60*60*1000));
  var expires = "; expires="+date.toGMTString();
  document.cookie = name+"="+value+expires+"; path=/";
}

function GetCookie(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 getMailto(name,host) {
	var h=64;
	h = name.replace(':','.') + String.fromCharCode(h) + host.replace(':','.');
  return h;
}
// sample: <a href="javascript:Mailto('meatie','icode:se')">
// Use ":" in place of "."!
function Mailto(name,host) {
	location.href='mailto'+String.fromCharCode(58)+getMailto(name,host);	
}
// sample: <script language="JavaScript">writeMail('meatie','icode:se')<./script>
// Use ":" in place of "."!
function writeMail(name,host) {
	document.write(getMailto(name,host));
}

// produces a complete link and prints the email in it.
// sample: <script language="JavaScript">writeMailLink('meatie','icode:se')<./script>
// Use ":" in place of "."!
function writeMailLink(name,host) {
	var m=getMailto(name,host);
	document.write('<a href="mailto:'+m+'">'+m+'</a>');
}

function popup(url,w,h,name) {
	if(!name) name="_blank";
	return window.open(url, name, "width="+w+",height="+h+",scrollbars=yes,resizable=yes");
}

function popPlayer(st){
	if (st==8002) st='8002.htm';
	else if (st==8008) st='8008.htm';
	else if (st==800580) st='port80.htm';
	else if (st==800280) st='port80ch2.htm';
	else if (st==800880) st='port80ch3.htm';
	else if (st==801080) st='port80ch4.htm';
	else st = '';
	window.open('tune/'+st,'efmplayer','scrollbars=no,width=290,height=151,resizable=yes');
}

function fixpng(img) { // manual transparency fixing of an img tag, for ie5,6. Give it obj or ID
	if(!ie_5_6) return;
	if(typeof img=="string") img = document.getElementById(img);
	if(!img) return;
  var imgName = img.src.toUpperCase();
  if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
    var imgID = (img.id) ? "id='" + img.id + "' " : "";
    var imgClass = (img.className) ? "class='" + img.className + "' " : "";
    var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
    var imgStyle = "display:inline-block;" + img.style.cssText;
    if (img.align == "left") imgStyle = "float:left;" + imgStyle;
    if (img.align == "right") imgStyle = "float:right;" + imgStyle;
    if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
    var strNewHTML = "<span " + imgID + imgClass + imgTitle
    + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
    + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
    + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
    img.outerHTML = strNewHTML;
  }
}

