//--- frame destroya --------------------------------------

function noFrames() {
	if (top.location != self.location) {
		top.location.href = self.location.href;
	}
}

//--- Popup windows ----------------------------------

function defaultPopup(url, name, w, h) {  // status bar, scroll bars, resizable
	var winW = (screen.width - w) / 2;
	var winH = (screen.height - h) / 2;
	var win1 = window.open(url,name,'width='+w+',height='+h+',top='+winH+',left='+winW+',toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');
	win1.focus();
}

function blogPopup(url, name, w, h) {  // no status bar, no scroll bars, resizable
	var winW = (screen.width - w) / 2;
	var winH = (screen.height - h) / 2;
	var win1 = window.open(url,name,'width='+w+',height='+h+',top='+winH+',left='+winW+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes');
	win1.focus();
}

function portiPopup(url, name, w, h, mode) {  // no status bar, scroll bars, resizable
	var w = w - 0;
	var h = h - 0;

	if (mode == "fullscreen") {
		var winW = 0;
		var winH = 0;
		w = screen.width;
		h = screen.height;
	}
	else {
		var winW = (screen.width - w) / 2;
		var winH = (screen.height - h) / 2;
		w += 30;
		h += 30;
	}
	var win2 = window.open(url,name,'width='+w+',height='+h+',top='+winH+',left='+winW+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
	win2.focus();
}

//--- show/hide ----------------------------------

function showhide(div) {
	var styleObj = document.getElementById(div);
	if (styleObj.style.visibility == "visible")
		styleObj.style.visibility = "hidden";
	else styleObj.style.visibility = "visible";
}

function hide(div) {
	var styleObj = document.getElementById(div);
	styleObj.style.visibility = "hidden";
}

//--- divwrite ----------------------------------------

function divwrite(div) {
	var newcontent = document.getElementById(div).innerHTML;
	document.getElementById('content').innerHTML = newcontent;
}

function divswap(div1, div2) {
	var oldcontent = document.getElementById(div1).innerHTML;
	var newcontent = document.getElementById(div2).innerHTML;
	document.getElementById(div1).innerHTML = newcontent;
	document.getElementById(div2).innerHTML = oldcontent;
}

//--- skinner ----------------------------------------
// adapted from www.idontsmoke.co.uk

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

//--- noder --------------------------------------------
// http://www.markup.co.nz/dom/styleClass_with_dom.htm

clssNodeArr = new Array();

// e element
// v class value
function createClassNodeArr(e) {
   var nodes = document.getElementsByTagName(e);
   var max = nodes.length;
   for (var i = 0; i < max; i++) {
      var nodeObj = nodes.item(i);
      var attrMax = nodeObj.attributes.length;
      for (var j = 0; j < attrMax; j++) {
		  var x = nodeObj.attributes.item(j).nodeValue;
          clssNodeArr[clssNodeArr.length] = nodeObj;
	  }
    }
}

var size = 10;

function styleByClass(mode) {
  var i, a, x;
  var b = document.getElementsByTagName("HTML").item(0);
//  for (i=0; (a = document.getElementsByTagName("div")[i]); i++) {
	if (mode == 'bigger') {
		x = eval(size + 1);
  		b.style.fontSize = x + "px";
	}
	else {
		x = eval(size - 1);
	 	b.style.fontSize = x + "px";
	}
//  }
  if (mode == 'bigger') size += 1;
  else size -= 1;
}

//--- div mouseover --------------------------------------------

function Swap(obj, new_style) {
    obj.className = new_style;
}

//--- select drop-downs ----------------------------------------

function QuickJump(n,f) {
	field = eval("document.forms['" + f + "']." + n + ".options[document.forms['" + f + "']." + n + ".selectedIndex].value");
	if (field != "none")
		location = field;
}

//--- spam destroya --------------------------------------------

function nospam(ahost,auser) {
	window.document.location.href = "mailto:"+auser+"@"+ahost;
}

//--- switchMenu ------------------------------------------
// Script by Martial Boissonneault  2001-2003 http://getElementById.com

function switchMenu(obj) {
	if (document.getElementById) {
		var el = document.getElementById("sub"+obj);
		//var ar = document.getElementById("subcategory").getElementsByTagName("ul");
		el.style.display = (el.style.display == "none") ? "block" : "none";
			/*for (var i=0; i < ar.length; i++) {
				if (obj != i)
					document.images[imgArr[i]].src = outArr[i].src;
				ar[i].style.display = "none";
			}*/
	}
}
//document.onselectstart = new Function("return false");

//--- Flash plugin detection -------------------------------

function detectFlash() {
  var browser = navigator.userAgent.toLowerCase();
  flashVersion = 0;    
    // NS3+, Opera3+, IE5+ Mac
    if (navigator.plugins != null && navigator.plugins.length > 0) {
        var flashPlugin = navigator.plugins['Shockwave Flash'];
        if (typeof flashPlugin == 'object') { 
			if ( flashPlugin.description.indexOf('9.') != -1 ) flashVersion = 9;
            else if ( flashPlugin.description.indexOf('8.') != -1 ) flashVersion = 8;
			else if ( flashPlugin.description.indexOf('7.') != -1 ) flashVersion = 7;
            else if ( flashPlugin.description.indexOf('6.') != -1 ) flashVersion = 6;
            else if ( flashPlugin.description.indexOf('5.') != -1 ) flashVersion = 5;
            else if ( flashPlugin.description.indexOf('4.') != -1 ) flashVersion = 4;
            else if ( flashPlugin.description.indexOf('3.') != -1 ) flashVersion = 3;
        }
    } // IE4+ Win32 (VBscript)
    else if (browser.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && browser.indexOf("win")!= -1 && browser.indexOf("16bit")== -1) {
      document.write('<scr' + 'ipt language="VBScript"\> \n');
        document.write('on error resume next \n');
        document.write('DIM obFlash \n');
        document.write('SET obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.9") \n');
        document.write('IF IsObject(obFlash) THEN \n');
        document.write('flashVersion = 9 \n');
		document.write('ELSE SET obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.8") END IF \n');
        document.write('IF flashVersion < 9 and IsObject(obFlash) THEN \n');
        document.write('flashVersion = 8 \n');
		document.write('ELSE SET obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.7") END IF \n');
        document.write('IF flashVersion < 8 and IsObject(obFlash) THEN \n');
        document.write('flashVersion = 7 \n');
        document.write('ELSE SET obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.6") END IF \n');
        document.write('IF flashVersion < 7 and IsObject(obFlash) THEN \n');
        document.write('flashVersion = 6 \n');
        document.write('ELSE SET obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.5") END IF \n');
        document.write('IF flashVersion < 6 and IsObject(obFlash) THEN \n');
        document.write('flashVersion = 5 \n');
        document.write('ELSE SET obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.4") END IF \n');
        document.write('IF flashVersion < 5 and IsObject(obFlash) THEN \n');
        document.write('flashVersion = 4 \n');
        document.write('ELSE SET obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.3") END IF \n');
        document.write('IF flashVersion < 4 and IsObject(obFlash) THEN \n');
        document.write('flashVersion = 3 \n');
        document.write('END IF');
      document.write('</scr' + 'ipt\> \n');
  } // no Flash
  else {
    flashVersion = 0;
  }
return flashVersion;
}

function noFlash() {
	document.write('<div class="noflash"><a href="http://www.macromedia.com/go/getflashplayer" title="get flash player"><img src="/pics/global/get_flash_player.gif" width="88" height="31" style="border:0;" alt="get flash player" /></a>');
	document.write('<p>The latest version of the <a href="http://www.macromedia.com/go/getflashplayer" title="get flash player">Macromedia Flash Player</a> is required to view this content.</p></div>');
}

//--- Start me up! --------------------------------------

function startUp() {
	noFrames();
	window.status = "codito ergo sum ... I code, therefore I am";
}
window.onload = startUp;