﻿//dart-id
var d = new Date();
var h = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds();
var ms = d.getMilliseconds();
var timeformatted = h.toString() + m.toString() + s.toString() + ms.toString();  


//Radio-player
function openPlayer(kanal) {
    var nrkPrefix = 'nrk_';
    if (kanal.match(nrkPrefix)) { NRKplayer(kanal.replace(nrkPrefix,'')); }
    else {                        NWRplayer(kanal);                       }
}
function NWRplayer(kanal) {
    var url = "http://player.minradio.no/Player.aspx?playerkey=sol_no&stationkey=" + kanal;
    var nwrPlayer = window.open(url, "NWRPlayer", "width=565,height=500,scrollbars=no,resizable=no");
    nwrPlayer.focus();
}
function NRKplayer(kanal) {
    var url = "http://nettradio.nrk.no/default.php?kanal=" + kanal;
    var nrkPlayer = window.open(url, "NRKPlayer", "width=628,height=377,scrollbars=no,resizable=no")
    nrkPlayer.focus();
}


//External search in the global body-footer
function externalSearch(form) {
    if (form.what[0].checked) {
        url = "http://www.caplex.no/web/artikkel/artliste.asp";
        queryName = "soketekst";
    } else
    if (form.what[1].checked) {
        url = "http://www.dokpro.uio.no/perl/ordboksoek/ordbok.cgi";
        queryName = "OPP";
    } else
    if (form.what[2].checked) {
        url = "http://www.britannica.com/search";
        queryName = "query";
    } else
    if (form.what[3].checked) {
        url = "http://www.imdb.com/find";
        queryName = "q";
    }
    form.action = "http://go.sol.no/go/s/sok_foot_div/" + url;
    form.elements[4].name  = queryName;
}


// SURVEY
/*
function surveyRadio(form, id, width, height) {
    if (!width)  { width  = 370 }
    if (!height) { height = 300 }
    for (var i=0; i<form.answer_id.length; i++) {
        if (form.answer_id[i].checked) {
            var answerID = form.answer_id[i].value;
        }
    }
    var url = 'http://www.sol.no/survey2/register_vote.fcgi?popup=1&question_id='+id+'&answer_id='+answerID;
    launchPopup(url, 'survey', width, height, 'yes', 'yes', 'no', 'no') 
}
*/
function surveySelect(form, id, width, height) {
    if (!width)  { width  = 370 }
    if (!height) { height = 300 }
    answerID = form.answer_id[form.answer_id.selectedIndex].value;
    var url = 'http://sol.staging.sol.no/survey2/register_vote.cgi?popup=1&question_id='+id+'&answer_id='+answerID;
    launchPopup(url, 'survey', width, height, 'yes', 'yes', 'no', 'no') 
}


// POPUPGUDE
var popupguideCloned = "false";
function popupguide() {
    if (popupguideCloned == "false") {
        var popupContainer = document.getElementById('popupguide');
        var bottomContent = document.getElementById('solsearchBottom')
        var popupContent = bottomContent.cloneNode(true);
        popupContainer.appendChild(popupContent);
        popupguideCloned = "true";
    }
    document.getElementById('popupguide').style.display='block';
}
function popupguideClose() {
    document.getElementById('popupguide').style.display='none';
}


// AD      -----må teste på om adContainer og ad får verdier før en går videre
function adStart(adIDs) {
    var length=adIDs.length;
    for (var i=0; i<length; i++) {
        var adContainer = document.getElementById('ad'+adIDs[i]);
        var ad = document.getElementById('ad'+adIDs[i]+'c');
        adContainer.appendChild(ad);
        ad.style.display='block';
    }
}


  
  // *******************************************
 // *  div small functions
// *******************************************

// SOL Ratings-code
function getRatings(id) {
    var Nnv=navigator;
    var Nna=Nnv.appName;
    var Nd=document;
    Nd.cookie="b=b";
    var Nc=0;
    if(Nd.cookie)Nc=1;
    var Nn=(Nna.substring(0,2)=="Mi")?0:1;
    var Ns=screen;
    var Npx=(Nn==0)?Ns.colorDepth:Ns.pixelDepth;
    var str='<img alt="" src="http://c.sol.no/' + id + ';'+Ns.width+'x'+Ns.height+';'+Npx+';'+Nc+';'+escape(Nd.referrer)+';'+Math.random()+'" />';
    document.write('<a href="http://www.sol.no/sgo/solratings/http://ratings.sol.no/" target="_top">'+str+'</a>');
}


//function autoSubmit(form, element)  { //select onchange="autoSubmit(this.form, 0)"
//    if (form.elements[element].selectedIndex > 0) {form.submit();}
//}
function autoSubmit(element)  { //select onchange="autoSubmit(this)"
    if (element.selectedIndex > 0) { element.form.submit(); }
}


function launchPopup(url, name, width, height, resizable, scrollbars, toolbar, location) {
    var left = (screen.width-width)/2; 
    var top = (screen.height-height)/2;
    popup_sol = window.open(url,name,'width=' +width+',height=' +height+',resizable='+resizable+',scrollbars='+scrollbars+',toolbar='+toolbar+',location='+location+',left='+left+',top='+top);
    popup_sol.focus();
}

//Er det behov for denne?
// as above, but does not put focus on the windov
//function launchPopupNoFocus(url, name, width, height, resizable, scrollbars, toolbar, location) {
//    var left = (screen.width-width)/2; 
//    var top = (screen.height-height)/2;
//    window.open(url,name,'width=' +width+',height=' +height+',resizable='+resizable+',scrollbars='+scrollbars+',toolbar='+toolbar+',location='+location+',left='+left+',top='+top);
//}

function autoLocation(element, goTag) {
    if (!goTag) { goTag = '' }
    if (element.selectedIndex > 0) {
        location=goTag + element.options[element.selectedIndex].value;
    }
}


//Er det behov for denne?
//function autoRedirect(url, goTag) {
//    if (!goTag) { goTag = '' }
//    location=goTag + url;
//}


// used to remove default values in text-input field
// ie. on the input-field: onfocus="removeDefault(this, 'Fornavn');"
function removeDefault(element, value) {
    if (element.value == value) {element.value = ""}
}


// used when more than one search is used in one form
// u=url value;  q=query name; e=elements[]-counter  t=tempArray;   a=Array
// hidden-fields in the xslt-code must be placed after the submit-button
function fuseSearches(form, u1, q1, u2, q2, u3, q3, u4, q4, u5, q5, u6, q6) {
    var t = new Array([u1,q1], [u2,q2], [u3,q3], [u4,q4], [u5,q5], [u6,q6]);
    var a = new Array();
    for (var index in t) {
        if (t[index][0]) {
            a.push([ t[index][0], t[index][1] ]);
        }
    }

    var u, q, e=0, l=a.length;
    for (var i=0; i<l; i++) {
        if (form.elements[e].tagName == 'FIELDSET') { e++ }
        if (form.elements[e].checked) {
            u = a[i][0];
            q = a[i][1];
        }
        e++;
    }
    if (form.elements[e].tagName == 'FIELDSET') { e++ }

    var result = form.action.match(/^(.*go\/)(\w*\/)http.*$/);
    form.action = result[1] + result[2] + u;
    form.elements[e].name  = q;
}




  // *******************************************
 // *  Set at homepage  &  set as a favorite  *
// *******************************************
function sniffClient(){
    var agt=navigator.userAgent.toLowerCase();
    this.opera = (agt.indexOf("opera") != -1);
    this.opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    this.opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    this.opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    this.opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    this.opera5up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4);
    this.is_mac = (agt.indexOf("mac") != -1);
    IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
    IE6 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)) ? true : false;
    IE7 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 7.")!=-1)) ? true : false;
}

function setHomepage(t_link, front){
    sniffClient();
    if ((IE5 || IE6 || IE7) && !this.opera5up && !this.is_mac) {
        if (front) {
            var homepage = "http://barn.sol.no";
        } else {
            var homepage = document.location.href;
        }
        t_link.style.behavior = 'url(#default#homepage)';
        t_link.setHomePage(homepage);
    }
    else if (this.is_mac) {
        alert('Beklager, denne funksjonen fungerer bare i Internet Explorer (IE) for Windows');  //burde ikke også denne bruke sol.no/start?
    }
    else {
        location.href="http://www2.sol.no/start/";
    }
}

//function setFavorite(){
//    sniffClient();
//    if ((IE5 || IE6 || IE7) && !this.opera5up  && !this.is_mac) {
//        window.external.AddFavorite(document.location.href, document.title);
//    }
//    else {
//        alert('Beklager, denne funksjonen fungerer bare i Internet Explorer (IE) for Windows');
//    }
//}


  // ******************************************************************
 // *  the compained frontpage header- and subpages footer search
// ******************************************************************

function divSearch(form) {
    var url = "http://search.eniro.no/partnersearch";
    if (form.divSearchMap.checked) {  // if it is a map-search
        url = "http://www.kvasir.no/kart/searchResult.html";
        form.divSearchText.name    = "q";
        form.divSearchExtra1.name  = "what";
        form.divSearchExtra1.value = "amap";


//        divSearchMap(form);
    }
    else {
        url = "http://search.eniro.no/partnersearch";
        form.divSearchText.name    = "query";
        form.divSearchExtra1.name  = "";
        form.divSearchExtra1.value = "";
    }

    if (form.action.match('go/')) {                                      // if the url includes a go-tag it should not be removed
        form.action = form.action.substr(0, form.action.indexOf('go/')+5) + url;
    } else {
        form.action = url;
    }
}

function divSearchMap(form) {
    // first break down the string
    var street = num = city = "";
    var array = form.divSearchText.value.split(/\s+/i);
    var counter = 0;
    var regExp = /\d+/i;
    while (!regExp.test(array[counter]) && (counter < array.length)) {   // parse the array until the element includes a number or we have parsed through it all
        street += array[counter] + " ";
        counter++;
    }
    street = street.substring(0, street.length - 1); // remove the last space
    if (array.length > counter) {                                        // if there is more elements left in the array the next one should include a streetnumber
        num = array[counter];
        counter++;
    }
    while (counter < array.length) {                                     // if there is even more elements it should be the name of the city
        city += array[counter] + " ";
        counter++;
    }
    city = city.substring(0, city.length - 1); // remove the last space

    // then manipulate the form
    form.divSearchText.name    = "string";                               //must not be named 'q' here.  Then the search wont work.
    form.divSearchExtra1.name  = "streetname";
    form.divSearchExtra1.value = street;
    form.divSearchExtra2.name  = "streetnumber";
    form.divSearchExtra2.value = num;
    form.divSearchExtra3.name  = "city";
    form.divSearchExtra3.value = city;
}


  // *******************************************
 // *  FLASH 
// *******************************************
/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
/** end SWFObject **/
