/* Tool: Zebra Tables URL: http://www.alistapart.com/articles/zebratables/ Usage: stripe(tableid, evenColor, oddColor); Example: stripe('playlist', '#fff', '#edf3fe'); */ // this function is need to work around // a bug in IE related to element attributes function hasClass(obj) { var result = false; if (obj.getAttributeNode("class") != null) { result = obj.getAttributeNode("class").value; } return result; } function stripe(id) { // the flag we'll use to keep track of // whether the current row is odd or even var even = false; // if arguments are provided to specify the colours // of the even & odd rows, then use the them; // otherwise use the following defaults: var evenColor = arguments[1] ? arguments[1] : "#fff"; var oddColor = arguments[2] ? arguments[2] : "#eee"; // obtain a reference to the desired table // if no such table exists, abort var table = document.getElementById(id); if (! table) { return; } // by definition, tables can have more than one tbody // element, so we'll have to get the list of child // <tbody>s var tbodies = table.getElementsByTagName("tbody"); // and iterate through them... for (var h = 0; h < tbodies.length; h++) { // find all the <tr> elements... var trs = tbodies[h].getElementsByTagName("tr"); // ... and iterate through them for (var i = 0; i < trs.length; i++) { // avoid rows that have a class attribute // or backgroundColor style if (!hasClass(trs[i]) && ! trs[i].style.backgroundColor) { // get all the cells in this row... var tds = trs[i].getElementsByTagName("td"); // and iterate through them... for (var j = 0; j < tds.length; j++) { var mytd = tds[j]; // avoid cells that have a class attribute // or backgroundColor style if (! hasClass(mytd) && ! mytd.style.backgroundColor) { mytd.style.backgroundColor = even ? evenColor : oddColor; } } } // flip from odd to even, or vice-versa even = ! even; } } } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i0&&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 MM_preloadImages('test.gif'); */ function popup(popurl,width,height,scrollbars,resizable) { var parameters = ''; var screenY = window.screen.availHeight; var screenX = window.screen.availWidth; var pos_left = (screenX - width) / 2; var pos_top = (screenY - height) / 2; parameters = "width="+width+",height="+height+",left="+pos_left+",top="+pos_top; if(scrollbars) parameters += ',scrollbars'; if(resizable) parameters += ',resizable'; winpops = window.open(popurl,"",parameters); } /* Newsletter */ 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,4}|[0-9]{1,4})(\\]?)$"); return (!r1.test(str) && r2.test(str)); } function minLen(str, leng) { return str.length>=leng; } function emailvalidation(entered, alertbox) { with (entered) { apos=value.indexOf("@"); dotpos=value.lastIndexOf("."); lastpos=value.length-1; if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) { if (alertbox) {alert(alertbox);} try {entered.focus()} catch(E) {}; return false;} else {return true;} } } function emptyvalidation(entered, alertbox) { with (entered) { if (value==null || value=="") { if (alertbox!="") alert(alertbox); if (type!="hidden") { try {entered.focus()} catch(E) {} } return false; } else { return true; } } } function doML(str) { location.href = "mailto:"+str.replace(/\.\.\./ig,"@"); } /************************************************************ C2_Popup: ************************************************************/ function C2_Popup() { this.definitions = { } this.AddDefinition("standard", "width=500,height=350,scrollbars=1,resizable=1,toolbar=0,center=1", "_blank", ""); } C2_Popup.prototype.AddDefinition = function(defId, features, target, template) { var definition = new Object(); definition.Features = features; definition.Target = target; definition.Template = template; this.definitions[defId] = definition; } C2_Popup.prototype.Open = function(defId, url) { var definition = this.definitions[defId]; if(definition==null) { definition = this.definitions["standard"]; } var features = this.buildWindowFeatures(definition.Features); var locationUrl = url; // todo: template var target = definition.Target; var handle = window.open(locationUrl, target, features); handle.focus(); } C2_Popup.prototype.buildWindowFeatures = function(definition) { var featureStr = definition; featureStr = featureStr.replace(/center\=1/, this.centeredWindow(definition)); return featureStr; } C2_Popup.prototype.centeredWindow = function(featureStr) { var width, height, featAddition = ""; var hasWidth = (featureStr.indexOf("width")>=0); if(hasWidth) { var width = featureStr.match(/width=([0-9]+),/i)[1]; if(!isNaN(parseInt(width))) { var screenX = window.screen.availWidth; featAddition += "left="+Math.round((screenX - width) / 2); } } var hasHeight = (featureStr.indexOf("height")>=0); if(hasHeight) { var height = featureStr.match(/height=([0-9]+),/i)[1]; if(!isNaN(parseInt(height))) { var screenY = window.screen.availHeight; featAddition += (featAddition.length>0?",":"")+"top="+Math.round((screenY - height) / 2); } } return featAddition; } // var c2popup = new C2_Popup(); // c2popup.AddDefinition(1, "width=400,height=400,scrollbars=1,resizable=1,toolbar=0,center=1", "_blank"); // c2popup.Open(1, "http://www.cirkus.dk/"); /************************************************************ C2_ImageRotater: generisk billedrotation ************************************************************/ function C2_Image(image, url, altText) { this._image = image; this._url = url; this._altText = altText; } var C2_ImageRotater_Style = 1; // 0 = Sequential, 1 = Random var C2_ImageRotater_Delay = 2500; // time in milliseconds between switch var C2_ImageRotater_BetweenImage = new C2_Image("img/samarbejdspartner.gif"); var C2_ImageRotater_Verbose = true; function C2_ImageRotater(elementId, images) { this._element = document.getElementById(elementId); if(this._element==null) { if(C2_ImageRotater_Verbose) window.status = "C2_ImageRotate: Element with ID '"+elementId+"' was not found. Rotation is cancelled."; return; } if(this._element.tagName!="IMG") { if(C2_ImageRotater_Verbose) window.status = "C2_ImageRotate: Element must be IMG type. Rotation is cancelled."; return; } this._style = C2_ImageRotater_Style; this._delay = C2_ImageRotater_Delay; this._betweenImage = C2_ImageRotater_BetweenImage; this._element.C2RotaterInstance = this; if(images==null) { this._images = new Array(); } else { this._images = images; } this._counter = 0; this._seqImageIndex = 0; this._originalAlt = this._element.alt; this._linkElement = null; this._originalHref = null; } C2_ImageRotater.prototype.Start = function() { if(this._images.length>0) { this._timer = window.setTimeout("C2_ImageRotater.Tick('"+this._element.id+"')", this._delay); } else if(C2_ImageRotater_Verbose) { window.status = "C2_ImageRotater: no images defined, will not rotate"; } } C2_ImageRotater.prototype.Stop = function() { if(this._timer!=null) window.clearTimeout(this._timer); } C2_ImageRotater.Tick = function(elementId) { // get target IMG-element var element = document.getElementById(elementId); // get C2_ImageRotater instance var instance = document.getElementById(elementId).C2RotaterInstance; var nextImage = null; // if between image is defined, use this every other tick if(C2_ImageRotater_BetweenImage!=null && instance._counter%2!=0) { nextImage = C2_ImageRotater_BetweenImage; } else { // check whether to choose image random og seq. if(this._style==1) { // random var randomImageIndex = Math.round(instance._images.length*Math.random()); nextImage = instance._images[randomImageIndex]; } else { // sequential instance._seqImageIndex++; if(instance._seqImageIndex>instance._images.length-1) { instance._seqImageIndex = 0; } nextImage = instance._images[instance._seqImageIndex]; } } // change properties on link element.src = nextImage._image; if(nextImage._altText!=null) { element.alt = nextImage._altText; } else { element.alt = instance._originalAlt; } if(instance._linkElement!=null) if(nextImage._url!=null) { instance._linkElement.href = nextImage._url; } else { instance._linkElement.href = instance._originalHref; } // Firefox seems to have problem shifting images, fix here: if(typeof(element.style.MozOpacity)=="string") element.style.MozOpacity = 1-(Math.random()/100); instance.PostTick(); } C2_ImageRotater.prototype.PostTick = function() { // increase internal counter this._counter++; // reset timer for next tick this._timer = window.setTimeout("C2_ImageRotater.Tick('"+this._element.id+"')", this._delay); } /* C2_ImageRotater.OnImageLoad = function() { var element = window.event.srcElement; var instance = element.C2RotaterInstance; if(element.readyState=="complete") { element.onreadystatechange = null; } } */ C2_ImageRotater.prototype.AddImage = function(image, url, altText) { this._images[this._images.length] = new C2_Image(image, url, altText); } C2_ImageRotater.prototype.SetLinkElementByID = function(anchorElementId) { this._linkElement = document.getElementById(anchorElementId); if(this._linkElement==null) { if(C2_ImageRotater_Verbose) window.status = "C2_ImageRotate: LinkElement was not found '"+this._linkElement+"'."; return; } this._originalHref = this._linkElement.href; } /************************************************************ Nifty Corners ************************************************************/ function NiftyCheck(){ if(!document.getElementById || !document.createElement) return(false); isXHTML=/html\:/.test(document.getElementsByTagName('body')[0].nodeName); if(Array.prototype.push==null){Array.prototype.push=function(){ this[this.length]=arguments[0]; return(this.length);}} return(true); } function Rounded(selector,wich,bk,color,opt){ var i,prefixt,prefixb,cn="r",ecolor="",edges=false,eclass="",b=false,t=false; if(color=="transparent"){ cn=cn+"x"; ecolor=bk; bk="transparent"; } else if(opt && opt.indexOf("border")>=0){ var optar=opt.split(" "); for(i=0;i=0) ecolor=optar[i]; if(ecolor=="") ecolor="#666"; cn+="e"; edges=true; } else if(opt && opt.indexOf("smooth")>=0){ cn+="a"; ecolor=Mix(bk,color); } if(opt && opt.indexOf("small")>=0) cn+="s"; prefixt=cn; prefixb=cn; if(wich.indexOf("all")>=0){t=true;b=true} else if(wich.indexOf("top")>=0) t="true"; else if(wich.indexOf("tl")>=0){ t="true"; if(wich.indexOf("tr")<0) prefixt+="l"; } else if(wich.indexOf("tr")>=0){ t="true"; prefixt+="r"; } if(wich.indexOf("bottom")>=0) b=true; else if(wich.indexOf("bl")>=0){ b="true"; if(wich.indexOf("br")<0) prefixb+="l"; } else if(wich.indexOf("br")>=0){ b="true"; prefixb+="r"; } var v=getElementsBySelector(selector); var l=v.length; for(i=0;i=0) lim=2; if(bc) d.className="artop"; else d.className="rtop"; d.style.backgroundColor=bk; for(i=1;i<=lim;i++){ var x=CreateEl("b"); x.className=cn + i; x.style.backgroundColor=color; if(bc) x.style.borderColor=bc; d.appendChild(x); } el.style.paddingTop=0; el.insertBefore(d,el.firstChild); } function AddBottom(el,bk,color,bc,cn){ var i,lim=8,d=CreateEl("b"); if(cn.indexOf("s")>=0) lim=2; if(bc) d.className="artop"; else d.className="rtop"; d.style.backgroundColor=bk; for(i=lim;i>0;i--){ var x=CreateEl("b"); x.className=cn + i; x.style.backgroundColor=color; if(bc) x.style.borderColor=bc; d.appendChild(x); } el.style.paddingBottom=0; el.appendChild(d); } function CreateEl(x){ if(isXHTML) return(document.createElementNS('http://www.w3.org/1999/xhtml',x)); else return(document.createElement(x)); } function getElementsBySelector(selector){ var i,selid="",selclass="",tag=selector,f,s=[],objlist=[]; if(selector.indexOf(" ")>0){ //descendant selector like "tag#id tag" s=selector.split(" "); var fs=s[0].split("#"); if(fs.length==1) return(objlist); f=document.getElementById(fs[1]); if(f) return(f.getElementsByTagName(s[1])); return(objlist); } if(selector.indexOf("#")>0){ //id selector like "tag#id" s=selector.split("#"); tag=s[0]; selid=s[1]; } if(selid!=""){ f=document.getElementById(selid); if(f) objlist.push(f); return(objlist); } if(selector.indexOf(".")>0){ //class selector like "tag.class" s=selector.split("."); tag=s[0]; selclass=s[1]; } var v=document.getElementsByTagName(tag); // tag selector like "tag" if(selclass=="") return(v); for(i=0;i=0){ objlist.push(v[i]); } } return(objlist); } function Mix(c1,c2){ var i,step1,step2,x,y,r=new Array(3); if(c1.length==4)step1=1; else step1=2; if(c2.length==4) step2=1; else step2=2; for(i=0;i<3;i++){ x=parseInt(c1.substr(1+step1*i,step1),16); if(step1==1) x=16*x+x; y=parseInt(c2.substr(1+step2*i,step2),16); if(step2==1) y=16*y+y; r[i]=Math.floor((x*50+y*50)/100); } return("#"+r[0].toString(16)+r[1].toString(16)+r[2].toString(16)); } /********************************/ /* Dictionary */ /********************************/ function GetAbsLeft(element) { var xPos = element.offsetLeft; var tempEl = element.offsetParent; while (tempEl != null) { xPos += tempEl.offsetLeft; tempEl = tempEl.offsetParent; } return xPos; } function GetAbsTop(element) { var yPos = element.offsetTop; var tempEl = element.offsetParent; while (tempEl != null) { yPos += tempEl.offsetTop; tempEl = tempEl.offsetParent; } return yPos; } dicElements = new Array(); function dicLookup(imgEvent,wordId) { var element = dicElements[wordId]; if(element==null) { element = document.createElement("div"); element.className = "dicDescriptionBox"; // element.onmouseover = String(imgEvent.srcElement.onmouseover); // element.onmouseout = String(imgEvent.srcElement.onmouseout); element.innerHTML = "" + dictionary[wordId].Word + ": " + dictionary[wordId].Description; document.body.appendChild(element); dicElements[wordId] = element; } // alert(imgEvent); if(dicElements[wordId].hideTimer!=null) { window.clearTimeout(dicElements[wordId].hideTimer); } var srcElement = (imgEvent.target || imgEvent.srcElement); var curX = GetAbsLeft(srcElement)+11; var curY = GetAbsTop(srcElement)+11; element.style.display = ""; element.style.left = curX+"px"; element.style.top = curY+"px"; } function dicHide(imgEvent,wordId) { if(dicElements[wordId]!=null) { dicElements[wordId].hideTimer = window.setTimeout("dicElements["+wordId+"].style.display = \"none\";dicElements["+wordId+"].hideTimer=null", 200); } } /****************************************/ /* PDK - hover menu pop-up */ /****************************************/ function pdkGetMenuId(element) { var cn = element.className; cn.search(/menu_row([\d]+)/ig); var menuId = RegExp.$1; return menuId; } var noteElement; function pdkMenuOver(element) { /* Disabled var menuId = pdkGetMenuId(element); if(menuId!="") { noteElement = document.getElementById("menuNote"+menuId); noteElement.style.top = (GetAbsTop(element) + element.offsetHeight) + "px"; noteElement.style.left = (GetAbsLeft(element) - (menuId=="1"?0:2)) + "px"; var noteWidth = element.offsetWidth-(menuId=="1"?12:10); noteElement.style.width = noteWidth + "px"; noteElement.style.display = "block"; } */ } function pdkMenuOut(element) { /* Disabled var menuId = pdkGetMenuId(element); if(menuId!="") { var noteElement = document.getElementById("menuNote"+menuId); noteElement.style.display = ""; } */ } /********************************/ /* Decode HTML */ /********************************/ function decodeHTML(html) { var str = html; str = str.replace(/Æ/g, "Æ"); str = str.replace(/æ/g, "æ"); str = str.replace(/Å/g, "Å"); str = str.replace(/å/g, "å"); str = str.replace(/Ø/g, "Ø"); str = str.replace(/ø/g, "ø"); return str; }