//--- frame destroya --------------------------------------

function noFrames() {
	if (top.location != self.location) {
		top.location.href = self.location.href;
	}
}



//--- 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('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.8") \n');
        document.write('IF 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 = "michael rog (dot) com";
}
window.onload = startUp;



//--- FORMS -------------------------------------

// copyright 1999 Idocs, Inc. http://www.idocs.com
// Distribute this script freely but keep this notice in place
function numbersonly(myfield, e, dec) {
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;

keychar = String.fromCharCode(key);

// control keys and punctuation
if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) || (key==45) || (key==46) || (key==120) || (key==45) || (key==40) || (key==41) || (key==32) || (key==43))
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == ".")) {
   myfield.form.elements[dec].focus();
   return false;
}
else return false;
}

function validEmail(email) {
	invalidChars = " /:,;";
	if (email == "") {
		return false;
	}
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i);
		if (email.indexOf(badChar,0) != -1) {
			return false;
		}
	}
	atPos = email.indexOf("@",1);
	if (atPos == -1) {
		return false;
	}
	if (email.indexOf("@",atPos+1) != -1) {
		return false;
	}
	periodPos = email.indexOf(".",atPos);
	if (periodPos == -1) {
		return false;
	}
	if (periodPos+3 > email.length)	{
		return false;
	}
	return true;
}

function validate_SubscriptionInfo() {
	// var messg = "You have left the following required fields blank or\n" + "incomplete. Please correct them before continuing:\n\n";
	var error = "" ;
	
	if ((document.forms['subscriptioninfo'].fullname.value=='') || (document.forms['subscriptioninfo'].fullname.value=='your name')) {
		// messg += "your name/alias\n" ;
		error += "name " ;
		document.forms['subscriptioninfo'].fullname.className = "error" ; }
		else { document.forms['subscriptioninfo'].fullname.className = "tr" ; }
	if (!validEmail(document.forms['subscriptioninfo'].email.value)) {
		// messg += "\nPlease provide a valid E-mail address (eg. name@example.com)" ;
		error += "email" ;
		document.forms['subscriptioninfo'].email.className = "error" ; }
		else { document.forms['subscriptioninfo'].email.className = "tr" ; }
	if (error != "") return false ;
	return true ;
}

function validate_ContactMe() {
	// var messg = "You have left the following required fields blank or\n" + "incomplete. Please correct them before continuing:\n\n";
	var error = "" ;
	
	if ((document.forms['contactme'].fullname.value=='') || (document.forms['contactme'].fullname.value=='your name')) {
		// messg += "your name/alias\n" ;
		error += "name " ;
		document.forms['contactme'].fullname.className = "error" ; }
		else { document.forms['contactme'].fullname.className = "tr" ; }
/*	if ((document.forms['contactme'].name.value=='') || (document.forms['contactme'].name.value=='your name')) {
		// messg += "your name/alias\n" ;
		error += "name " ;
		document.forms['contactme'].name.className = "error" ; }
		else { document.forms['contactme'].name.className = "tr" ; } */
	if (!validEmail(document.forms['contactme'].email.value)) {
		// messg += "\nPlease provide a valid E-mail address (eg. name@example.com)" ;
		error += "email " ;
		document.forms['contactme'].email.className = "error" ; }
		else { document.forms['contactme'].email.className = "tr" ; }
	if ((document.forms['contactme'].message.value=='') || (document.forms['contactme'].message.value=='your message')) {
		// messg += "your message\n" ;
		error += "message " ;
		document.forms['contactme'].message.className = "error" ; }
		else { document.forms['contactme'].message.className = "tr" ; }
	if (error != "") return false ;
	return true ;
}