﻿
function antiEmailRobot2(imgsrc, name, domain, klass){
  document.write("<a href=" + "'/dagen/Email.aspx?till=" + name + "' class=" + klass + ">" + name + "<img valign=absmiddle src=" + imgsrc + " border=0>" + domain + "<"+"/"+"a>")
}
function antiEmailRobot(imgsrc, name, domain, klass){
  document.write("<a href=" + "'/dagen/Email.aspx?till=" + name + "' class=" + klass + ">" + name + "<img valign=absmiddle src=" + imgsrc + " border=0>" + domain + "<"+"/"+"a>")
}

function MestLasta(div)
{
    $("#mostread_now, #mostread_week, #mostread_month").hide();
    $("#"+div).show();

    if (div == 'mostread_now')
        $("#MostReadLink").html("<a href='/dagen/MostRead.aspx?typ=now'>Mest lästa</a>");
    else if (div == 'mostread_week')
        $("#MostReadLink").html("<a href='/dagen/MostRead.aspx?typ=week'>Mest lästa</a>");
    else if (div == 'mostread_month')
        $("#MostReadLink").html("<a href='/dagen/MostRead.aspx?typ=month'>Mest lästa</a>");
}

function SenasteNytt(div)
{
    $("#senastenytt_alla, #senastenytt_tt, #senastenytt_dagense").hide();
    $("#" + div).show();
}

function WebbTVArkiv(div)
{
    $("#webbarkiv_kat, #webbarkiv_dat").hide();
    $("#" + div).show();
}


function popup(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=500,left = 200,top = 200');");
}

function emo_ajax(URL) {

    $.ajax({
        url: URL,
        success:function(data){
            if(data.substring(4,0) == "#OK#")
                $("#artikel_emo").html(data.replace('#OK#', ''));
            else
                $("#artikel_emo").html("Ett fel har uppstått");
        },
        error:function(){
            $("#artikel_emo").html("Ett fel har uppstått");
        }
    });
}

var tx_of = "";
var in_of = "";


function Zoom(f) {

    tx_elem = document.getElementById('text');
    pretx_cf = parseInt(tx_elem.style.fontSize);
    if (isNaN(pretx_cf)) { tx_of = '12px'; }
    else { tx_of = pretx_cf + 'px' }
    
    tx_cf =  parseInt(tx_of);
    
    tx_FS = parseInt(tx_cf) + f;
    tx_LH = tx_FS + 2;
    
    tx_elem.style.fontSize = tx_FS + 'px'; 
    tx_elem.style.lineHeight = tx_LH + 'px';
    
    tx_of = tx_cf;
    
    
    in_elem = document.getElementById('ingress');
    prein_cf = parseInt(in_elem.style.fontSize);
    if (isNaN(prein_cf)) { in_of = '14px'; }  
    else { in_of = prein_cf + 'px'; }
    
    in_cf = parseInt(in_of);
        
    in_FS = parseInt(in_cf) + f;
    in_LH = in_FS + 2;
    
    in_elem.style.fontSize = in_FS + 'px'; 
    in_elem.style.lineHeight = in_LH + 'px';
    
    in_of = in_FS;
    
}


function ZoomByElementId(f, id) {

    tx_elem = document.getElementById(id);
    pretx_cf = parseInt(tx_elem.style.fontSize);
    if (isNaN(pretx_cf)) { tx_of = '12px'; }
    else { tx_of = pretx_cf + 'px' }

    tx_cf = parseInt(tx_of);

    tx_FS = parseInt(tx_cf) + f;
    tx_LH = tx_FS + 2;

    tx_elem.style.fontSize = tx_FS + 'px';
    tx_elem.style.lineHeight = tx_LH + 'px';

    tx_of = tx_cf;

}

function clickButton(e, buttonid){ 
  var evt = e ? e : window.event;
  var bt = document.getElementById(buttonid);

  if (bt){ 
      if (evt.keyCode == 13){ 
            bt.click(); 
            return false; 
            } 
        } 
    }
    
 function Func_musik_sok()
 {
 var in_str = document.getElementById("musik_sok").value;
 document.location = "http://musiksajten.dagen.se/Search.aspx?searchValue=" + in_str;
 }
 
 function arkiv_on(value)
 {
    $.cookie("arkiv", value);
    
    $("#arkiv_off").hide();
    $("#arkiv_on").show();
 }
 
 function check_if_arkiv_on(value)
 {
     if ($.cookie("arkiv") == value)
        arkiv_on(value);
 }
 
 function arkiv_ar_on(blogg, ar)
 {
    $.cookie("arkiv" + blogg + "_" + ar, "on")

    $("#arkiv_" + ar + "_off").hide();      
    $("#arkiv_" + ar + "_on").show();
 }
 
  function arkiv_ar_off(blogg, ar)
 {
    $.cookie("arkiv" + blogg + "_" + ar, "off")

    $("#arkiv_" + ar + "_off").show();
    $("#arkiv_" + ar + "_on").hide();
 }
 
 
 function check_if_arkiv_ar_on(blogg, ar)
 {
    if ($.cookie("arkiv" + blogg + "_" + ar) == "on")
        arkiv_ar_on(blogg, ar);
    else
        arkiv_ar_off(blogg, ar);
 }

 function faq_init(containerId) {
     $('#' + containerId + ' .faq_question').toggle(
			function () {
			    $(this).addClass('open').siblings('.faq_answer').slideDown(200);
			},
			function () {
			    $(this).removeClass('open').siblings('.faq_answer').slideUp(200);
			}
		);
}

function resizeBannerIframe(iframeObj) {
    if (iframeObj.contentDocument) {
        if ($(iframeObj).height() != $(iframeObj.contentDocument.body).height())
            $(iframeObj).height($(iframeObj.contentDocument.body).height());
    } else {
        if ($(iframeObj).height() != $(iframeObj.contentWindow.document.body).height())
            $(iframeObj).height($(iframeObj.contentWindow.document.body).height());
    }
}

function LoadAds() {
    var $adContainers = $('iframe.AdContainer[rel]');

    for(var i=0; i < 5; i++)
        LoadAd($adContainers[i]);

    if($adContainers.length >= 5){
        setTimeout(LoadAds, 10);
    }
}

function LoadAd(obj) {
    //var $tmpIframe = $('<iframe frameborder="0" scrolling="no" class="AdContainer" id="'+ $(obj).attr('id') +'" style="height:'+ $(obj).height() +'px;" src="/blank.html">');
    var loc = $(obj).attr('rel');
    $(obj).removeAttr('rel');
    //obj.location.replace(loc);
    $(obj).attr('src', loc);
    $(obj).load(function () {
        resizeBannerIframe(obj);
    });

    //$(obj).replaceWith($tmpIframe);

    //setTimeout(function () {
        //$tmpIframe.attr('src', loc);



    //}, 5);
}

function triggerEniroText(lnk) {
    $.fancybox({
        type: 'iframe',
        showNavArrows: false,
        href: $(lnk).attr('href'),
        onStart: function () {
            $('embed:visible,object:visible,select:visible').addClass('noVisibility');
        },
        onClosed: function () {
            $('embed,object,select').removeClass('noVisibility');
        }
    });

    return false;
}
