﻿var agt=navigator.userAgent.toLowerCase();

var is_major = parseInt(navigator.appVersion);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

function list(o,inside){
	var s = "";
	if (typeof(o)=="undefined")s="undefined";
	if (o==null)s="NULL";
	for(var i in o){
		s+= ( ((inside)?("\t"):("")) + i + "=" + o[i] + "\n");
		if (typeof(o[i])=="object" && o[i]!=null){
			s+=list(o[i],1);
		}

	}
	return s;
}

function alertToPopup(o){
	var s = list(o);
	var w = window.open("","","");
	
	w.document.open();
	w.document.write( "<xmp>"+s+"</xmp>");
	w.document.close();
}

function AjaxProOutput(func){	
	return function (ajaxResponse){

		if (ajaxResponse.error!=null){
			alert ("AJAX ERROR:\n\n" + list(ajaxResponse.error));
		}

		if (ajaxResponse.value!=null){
			var str = list(ajaxResponse.value);
			//alert ("AJAX VALUE:\n\n" + str);
			func (ajaxResponse.value);
		}
	}
}

function setHtml(id,html,toAppend){
	if (id=="")return;
	var o = $(id);
	if (o){
		html = html.replace(/\\r\\n/gi,"");
		o.innerHTML = (toAppend)?(o.innerHTML+html):(html);
	}
}

function getFlashCode(url,id,w,h,bgcolor, wmode){
	str = '<embed swLiveConnect="true" quality=best type="application/x-shockwave-flash" menu=false  ' +
		' name="' + id + '" id="' + id + '" ' +
		' src="' + url + '" ' +
		' wmode="'+ wmode +'" ' +
		' bgcolor="' + bgcolor + '" ' +
		' width=' + w + ' height=' + h +
		' swLiveConnect=true ' +
		' allowScriptAccess="sameDomain" ' +
		' type="application/x-shockwave-flash" ' +
		' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" ></embed>';
	//alert (containerId + ":" + $(containerId) + str);
	return str;
}

function addFlashInside (containerId, url,id,w,h,bgcolor, wmode){
	var str = getFlashCode(url,id,w,h,bgcolor, wmode);
	setHtml(containerId,str,false);
}

function addFlash(url,id,w,h,bgcolor, wmode){
	var str = getFlashCode(url,id,w,h,bgcolor, wmode);

	document.write (str);
}

function replaceClass(id,str1,str2){
	if (id=="")return;
	var o = $(id);
	if (o){
		o.className = (o.className!="")?(o.className.replace (str1,str2)):(str2);
	}
}

function onContent(f){//(C)webreflection.blogspot.com
var a=onContent,b=navigator.userAgent,d=document,w=window,c="onContent",e="addEventListener",o="opera",r="readyState",
s="<scr".concat("ipt defer src='//:' on",r,"change='if(this.",r,"==\"complete\"){this.parentNode.removeChild(this);",c,".",c,"()}'></scr","ipt>");
a[c]=(function(o){return function(){a[c]=function(){};for(a=arguments.callee;!a.done;a.done=1)f(o?o():o)}})(a[c]);
if(d[e])d[e]("DOMContentLoaded",a[c],false);
if(/WebKit|Khtml/i.test(b)||(w[o]&&parseInt(w[o].version())<9))(function(){/loaded|complete/.test(d[r])?a[c]():setTimeout(arguments.callee,1)})();
else if(/MSIE/i.test(b))d.write(s);
};
