
function doIframe(){
	o = document.getElementsByTagName('iframe');
	for(i=0;i<o.length;i++){
		if (/\bautoHeight\b/.test(o[i].className)){
			setHeight(o[i]);
			addEvent(o[i],'load', doIframe);
		}
	}
}

function setHeight(e){
	if(e.contentDocument){
		e.height = e.contentDocument.body.offsetHeight + 35;
	} else {
		e.height = e.contentWindow.document.body.scrollHeight;
	}
}

function addEvent(obj, evType, fn){
	if(obj.addEventListener)
	{
	obj.addEventListener(evType, fn,false);
	return true;
	} else if (obj.attachEvent){
	var r = obj.attachEvent("on"+evType, fn);
	return r;
	} else {
	return false;
	}
}

if (document.getElementById && document.createTextNode){
 addEvent(window,'load', doIframe);	
}

jQuery.url=function(){var segments={};var parsed={};var options={url:window.location,strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};var parseUri=function(){str=decodeURI(options.url);var m=options.parser[options.strictMode?"strict":"loose"].exec(str);var uri={};var i=14;while(i--){uri[options.key[i]]=m[i]||""}uri[options.q.name]={};uri[options.key[12]].replace(options.q.parser,function($0,$1,$2){if($1){uri[options.q.name][$1]=$2}});return uri};var key=function(key){if(!parsed.length){setUp()}if(key=="base"){if(parsed.port!==null&&parsed.port!==""){return parsed.protocol+"://"+parsed.host+":"+parsed.port+"/"}else{return parsed.protocol+"://"+parsed.host+"/"}}return(parsed[key]==="")?null:parsed[key]};var param=function(item){if(!parsed.length){setUp()}return(parsed.queryKey[item]===null)?null:parsed.queryKey[item]};var setUp=function(){parsed=parseUri();getSegments()};var getSegments=function(){var p=parsed.path;segments=[];segments=parsed.path.length==1?{}:(p.charAt(p.length-1)=="/"?p.substring(1,p.length-1):path=p.substring(1)).split("/")};return{setMode:function(mode){strictMode=mode=="strict"?true:false;return this},setUrl:function(newUri){options.url=newUri===undefined?window.location:newUri;setUp();return this},segment:function(pos){if(!parsed.length){setUp()}if(pos===undefined){return segments.length}return(segments[pos]===""||segments[pos]===undefined)?null:segments[pos]},attr:key,param:param}}();

function qTableColorer(id) {
	$(id+" > tbody > tr").hover( function(){ $(this).addClass("over"); }, function(){ $(this).removeClass("over"); });
//	$(id+" > tbody > tr").click( function(){ $(this).toggleClass("select"); } );
	$(id+" > tbody > tr:odd").addClass("odd");
}


function prettyForm(){
	$("input").each( function(){ $(this).addClass($(this).attr("type")); });
	$("input,textarea,select").focus( function(){ $(this).addClass("selected"); } );
	$("input,textarea,select").blur( function(){ $(this).removeClass("selected"); } );
}

function rand(min, max){
	return Math.floor(Math.random() * (max + 1 - min)) + min;
};

function pngFix(){
	if(!jQuery.browser.msie) return;
	if(jQuery.browser.version<5.5) return;

	$('img[src*=".png"]').each(function(){
		var imgID = (this.id) ? "id='" + this.id + "' " : "";
		var imgClass = (this.className) ? "class='" + this.className + "' " : "";
		var imgTitle = (this.title) ? "title='" + this.title + "' " : "title='" + this.alt + "' ";
		var imgStyle = "display:inline-block;" + this.style.cssText;
		if (this.align == "left") imgStyle = "float:left;" + imgStyle;
		if (this.align == "right") imgStyle = "float:right;" + imgStyle;
		if (this.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
		this.outerHTML = "<span " + imgID + imgClass + imgTitle
		+ " style=\"" + "width:" + this.width + "px; height:" + this.height + "px;" + imgStyle + ";"
		+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		+ "(src=\'" + this.src + "\', sizingMethod='scale');\"></span>";
	});
}

function resizewindow() {
	var height = $(document).height();
	var minheight = $('body').attr('id')=='index'?730:550;
	$("#w4").height((height>minheight?height:minheight));
};


$(document).ready(function(){	
	
	$page = jQuery.url.attr("file");
	if(!$page) { $page = 'index.html'; }
	$('#menu>li>a').each(function(){
		var $href = $(this).attr('href');
		if ( ($href == $page) || ($href == '') ) {
			$(this).parent().addClass('active');
		}
	});
	$('#menu>li>ul>li>a').each(function(){
		var $href = $(this).attr('href');
		if ( ($href == $page) || ($href == '') ) {
			$(this).css('text-decoration','underline').parent().parent().parent().addClass('active');
		}
	});

	resizewindow();
});




var resizeTimer = null;
	
$(window).bind('resize', function() {	
	if (resizeTimer) clearTimeout(resizeTimer);
    resizeTimer = setTimeout(resizewindow, 100);
});
