var vox = {
    src: '/wp-content/themes/olofolsson.com/vox.swf'
};

//sIFR.useStyleCheck = true;
//sIFR.fixHover = true;
//sIFR.fitExactly = true;

sIFR.activate(vox);



function onLoad() 
{ 
 // Handle all a tags with rel="external" 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) 
 { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 

 // Handle Feedburner e-mail subs pop-up
 var forms = document.getElementsByTagName("form"); 
 for (var i=0; i<forms.length; i++) { 
   var form = forms[i]; 
   if (form.getAttribute("onsubmit")) 
     form.target = "popupwindow";
 } 




} 

function clearText(thefield)
{
  if (thefield.defaultValue==thefield.value)
    thefield.value = ""
}
 
function resetText(thefield)
{
    thefield.value = thefield.defaultValue;
}


function setActiveStyleSheet(title) {
    var i, a, main;
    for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
	if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
	    a.disabled = true;
	    if(a.getAttribute("title") == title) a.disabled = false;
	}
    }
}

function getActiveStyleSheet() {
    var i, a;
    for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
	if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
    }
    return null;
}

function getPreferredStyleSheet() {
    var i, a;
    for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
	if(a.getAttribute("rel").indexOf("style") != -1
	   && a.getAttribute("rel").indexOf("alt") == -1
	   && a.getAttribute("title")
	   ) return a.getAttribute("title");
    }
    return null;
}


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 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;
}




window.onunload = function(e) {
	var title = getActiveStyleSheet();
	createCookie("style", title, 365);
}

window.onload = function(e) {

    var cookie = readCookie("style");
    var title = cookie ? cookie : getPreferredStyleSheet();
    setActiveStyleSheet(title);

    //     onLoad();
sIFR.replace(vox, {
    selector: '#content h2',
    css: [
       '.sIFR-root { color: #222222; }'
      ,'a { text-decoration: none; color: #222222}'
       ,'a:hover {color:#000000 }'
    ]
    , tuneHeight: -5
    , wmode: 'transparent'
    , transparency: true
    , sharpness: 50
    , selectable: true
    , forceWidth: true
    , fitExactly: true
    , ratios: [9,1.16,16,1.09,24,1.06,37,1.04,74,1.02,1.01]
  });

sIFR.replace(vox, {
    selector: '#content h3',
    css: [
       '.comment-nr { color: #555555; }'
      ,'.sIFR-root { color: #555555; }'
      ,'a {color: #222222}'
      ,'a:hover { color:#000000; }'
    ]
    , tuneHeight: -4
    , sharpness: 50
    , selectable: true
    , ratios: [9,1.16,16,1.09,24,1.06,37,1.04,74,1.02,1.01]
  });


sIFR.replace(vox, {
    selector: '#sidebar h2',
    css: [
       '.sIFR-root { color: #333333; }'
      ,'a {color: #333333; text-decoration: none}'
      ,'a:hover { color: #000000 }'
    ]
    , transparent: true
    , forceSingleLine: true
    , tuneHeight: -5
    , sharpness: 0
    , selectable: true
    , ratios: [9,1.16,16,1.09,24,1.06,37,1.04,74,1.02,1.01]
  });


}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

// window.onload = onLoad;