
// PARSES QUERY STRING INTO VARIABLES

if (location.search.length != 0) {
var get_vars = new Object();
get_vars.varName = new Array();
get_vars.varValue = new Array();
var q_str = location.search.substring(1);
var temp_var = q_str.split("&");
for (x=0;x<temp_var.length;x++) {
parts = temp_var[x].split("=");
get_vars.varName[x] = parts[0];
if (isNaN(parseFloat(parts[1]))) {
get_vars.varValue[x] = '"' + parts[1] + '"';
} else get_vars.varValue[x] = parts[1];
eval(get_vars.varName[x] + "=" + get_vars.varValue[x]);
}
}

var HOST = 'orange-blog.com';

function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
    document.cookie = curCookie;
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}


// BEGIN STYLESWITCHER SCRIPTS

  var now = new Date();
  fixDate(now);
  now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);

function setActiveStyleSheet(title) {
  setCookie('style', title, now, '/', HOST, '');
  var selfhref = self.location.href;
  if (selfhref.indexOf('#') > -1) {
     var selfhref_array = selfhref.split('#');
     self.location.replace(selfhref_array[0]+'?styleswitch');
  } else {
     self.location.replace(selfhref);
  }
}

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

var cookie = getCookie("style");
if (swfobject.hasFlashPlayerVersion("7.0.0") && !cookie) {
  	setCookie('style', 'live', now, '/', HOST, '');
	var cookie = getCookie("style");
}

var currentstyle = cookie;
var title = cookie ? cookie : getPreferredStyleSheet();

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

// END STYLE SWITCHER SCRIPTS

// BEGIN WEBCAM

function renderWebCam (epoch,weather,hour) {
	var headerSWF;

	headerSWF  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="698" height="158">';
	headerSWF += '	<param name="movie" value="/blog/swfs/webcam.swf" />';
	headerSWF += '	<param name="FlashVars" value="hour='+hour+'&weather='+weather+'" />';
	headerSWF += '	<embed src="/blog/swfs/webcam.swf" width="698" height="158" FlashVars="hour='+hour+'&weather='+weather+'" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" />';
	headerSWF += '<'+'/object>';
	document.getElementById('header').innerHTML = headerSWF;
}

// END WEBCAM

// BEGIN GENERIC FLASH EMBED

function showFlash (url,elementId,width,height,baseurl) {

		var genericSWF;
		if (baseurl == null) {
			baseurl = ".";
		}

		genericSWF  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + width + '" height="' + height + '">';
		genericSWF += '	<param name="movie" value="' + url + '" />';
		genericSWF += '	<param name="base" value="' + baseurl + '" />';
		genericSWF += '	<embed base="'+baseurl+'" src="' + url + '" width="' + width + '" height="' + height + '" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" />';
		genericSWF += '<'+'/object>';
		document.getElementById(elementId).innerHTML = genericSWF;

}

// END GENERIC FLASH EMBED

// BEGIN POLL FUNCTIONS

function getHTML(divId,url){var method='GET';var data;var process=executeHTML;var async;var dosend;return new AJAXRequest(method,url,data,process,async,dosend,divId);}function executeHTML(AJAX,divId){if(AJAX.readyState==4){if(AJAX.status==200){document.getElementById(divId).innerHTML=AJAX.responseText;}}}var _ms_XMLHttpRequest_ActiveX="";function AJAXRequest(method,url,data,process,async,dosend,extraObj){var self=this;if(window.XMLHttpRequest){self.AJAX=new XMLHttpRequest();}else if(window.ActiveXObject){if(_ms_XMLHttpRequest_ActiveX){self.AJAX=new ActiveXObject(_ms_XMLHttpRequest_ActiveX);}else {var versions=["Msxml2.XMLHTTP.7.0","Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];for(var i=0;i<versions.length;i++){try{self.AJAX=new ActiveXObject(versions[i]);if(self.AJAX){_ms_XMLHttpRequest_ActiveX=versions[i];break;}}catch(objException){};};}}if(typeof process=='undefined'||process==null){process=executeReturn;}self.process=process;self.AJAX.onreadystatechange=function(){self.process(self.AJAX,extraObj);}
if(!method){method="POST";}method=method.toUpperCase();if(typeof async=='undefined'||async==null){async=true;}self.AJAX.open(method,url,async);if(method=="POST"){self.AJAX.setRequestHeader("Connection","close");self.AJAX.setRequestHeader("Content-Type","application/x-www-form-urlencoded");self.AJAX.setRequestHeader("Method","POST"+url+"HTTP/1.1");}if(dosend||typeof dosend=='undefined'){self.AJAX.send(data);}return self.AJAX;}

// END POLL FUNCTIONS

// BEGIN WINDOW FUNCTIONS

var kingy = null;

function FullScreener(url) {
  if (window.screen) {
  var chasm = screen.availWidth;
  var mount = screen.availHeight;
  kingy = window.open(url,'k1','top=0,left=0,width=' + (chasm - 10) + ',height=' + (mount - 30));

  }
}

function blowOut() {
  if (kingy != null && kingy.open) kingy.close();
}

// END WINDOW FUNCTIONS


// BEGIN SLIDESHOW FUNCTIONS

var navline;
function loadPhoto (num) {
	document.getElementById('galleryphoto').src = '/blog/images/galleries/2004-08-seafair/'+eval('photo'+num)[0];
	document.getElementById('gallerydesc').innerHTML = eval('photo'+num)[1];
	navline = '';
	for (i=1; i <= photos; i++) {
		if (i != num) {
			navline += '<a href="?#'+i+'" onclick="loadPhoto('+i+'); return false">'+i+'</a>';
		} else {
			navline += i;
		}
		if (i < photos) {
			navline += ' | ';
		}
	}
	document.getElementById("gallerynav").innerHTML = navline;
}


// END SLIDESHOW FUNCTIONS

// BEGIN COMM

function md_comm () {
	document.getElementById('md_comm').action = "http://www.mikeindustries.com/md_comm";
}

// END COMM

// BEGIN FONT SELECTOR FUNCTIONS

function renderReadability () {

	var typefaces = new Array('Lucida Grande', 'Verdana', 'Helvetica', 'Gill Sans', 'Trebuchet', 'Georgia', 'Times');
	document.write('<h4>Readability:<\/h4><form>');
	document.write('<span id="fontsizemenu">Size:<select name="fontsize" style="font-size: 10px; margin: 2px 0 2px 3px" onChange="changeFontSize(this.options[selectedIndex].value);">');
	for ( var x=9; x <= 24; x++) {
		if (Number(x) == Number(fontsize)) {
			document.write('<option value="'+x+'" selected="selected">'+x+'<\/option>');
		} else {
			document.write('<option value="'+x+'">'+x+'<\/option>');
		}
	}
	document.write('<\/select><\/span>');
	document.write('<span id="fontfamilymenu"><br />Font:<select name="fontfamily" style="width: 95px; font-size: 10px; margin: 2px 0 2px 3px" onChange="changeFontFamily(this.options[selectedIndex].value);">');
	for (i=0; i<typefaces.length; i++) {
		if (fontfamily == typefaces[i]) {
			var notcustom = true;
			document.write('<option value="'+ typefaces[i]+'" selected="selected">'+typefaces[i]+'<\/option>');
		} else {
			document.write('<option value="'+ typefaces[i]+'">'+typefaces[i]+'<\/option>');
		}
	}
	if (!notcustom) {
		document.write('<option value="'+ fontfamily+'" selected="selected">'+fontfamily+'<\/option>');
	}
	document.write('<\/select><\/span><\/form>');
	document.write('<br \/><form onsubmit="changeFontFamily(escape(document.getElementById(\'customfontfield\').value)); return false;"><a href="#" onclick="document.getElementById(\'customfont\').style.display = \'block\'; document.getElementById(\'fontfamilymenu\').style.display = \'none\'; return false" style="text-decoration: underline">Or, specify your own...<\/a>');
	document.write('<div id="customfont" style="display: none; margin: 0; padding: 0">Font: <input id="customfontfield" name="customfontfield" size="8" style="width: 50px; font-size: 10px; margin: 6px 6px 0 0" /><input type="submit" value="Set" style="font-size: 10px" /><\/div>');
	document.write('<\/form>');
}

var fontfamily = getCookie('fontfamily');
var fontsize = getCookie('fontsize');

if (!fontfamily && navigator.userAgent.toLowerCase().indexOf("mac") > -1) {
	var fontfamily = 'Lucida Grande';
} else if (!fontfamily) {
	var fontfamily = 'Verdana';
}
if (!fontsize) {
	var fontsize = 11;
}



function changeFontFamily (fontfamily) {
	setCookie('fontfamily', fontfamily.replace(/%20/g,unescape('%20')), now, '/', HOST, '');
	self.location.href = self.location.href;
}

function changeFontSize (fontsize) {
  setCookie('fontsize', fontsize, now, '/', HOST, '');
  self.location.href = self.location.href;
}

var fontfamilyadjusted;

	if (fontfamily == 'Times') {
		fontfamilyadjusted = '"Times New Roman", Times';
	} else if (fontfamily == 'Trebuchet') {
		fontfamilyadjusted = '"Trebuchet MS", Trebuchet';
	} else {
		fontfamilyadjusted = '"'+fontfamily+'"';
}

document.write('<style type="text/css">');
document.write('#mainpane {font-family:'+fontfamilyadjusted+'; font-size:'+fontsize+'px; line-height: 1.6em}');
document.write('<\/style>');
