var IE = (/msie/i).test(navigator.userAgent);
var sess = null;
var vars = [];
var dfd;
var image_list = [];
var dr = 0;
var res = 0;
var stylesheets = [];
var initial_data;
var layout = null;
//var lastURL = window.location.href;
//var pollID = window.setInterval("pollHash();",1000);
//var popup = openWin("debug.html","popup");

function object(o)
{
	function F() {}
	F.prototype = o;
	return new F();
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function pollHash()
{
	var req = createRequest();
	req.open("POST","test/geturl.php",false);
	req.send(null);
	var URL = (IE) ? document.URL : window.location.href;
	if (lastURL != URL)
	{
	//alert(lastURL + "\n" + URL);
		//alert('hash has changed...');
		if (!URL.match(new RegExp("#","i")))
		{
			//URL
		}
	}
	lastURL = URL;
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function bodyLoad(evt)
{
	//windowResize(null);
	//window.onresize = function() { windowResize(evt); };
	if (IE)
	{
		try
		{
			document.execCommand("BackgroundImageCache",false,true);
		}
		catch(e)
		{
		}
	}
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function dataframeLoad(evt)
{
	try
	{
		dfd = (window.frames.dataframe.document || dgi('dataframe').contentDocument);
		if (initial_data)
		{
			dfd.getElementById('dataframe_data').value = initial_data;
			initial_data = null;
		}
		data = (dfd.getElementById('dataframe_data').value || "");
		data_input = (dfd.getElementById('dataframe_data_input').value || "");
		if (data.length > 0 && data_input.length > 0)
		{
			request("POST","?",data + "&history=true");
		}
	}
	catch (ex)
	{
	}
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function fileframeLoad(evt)
{
	var s;
	try
	{
		ffd = (window.frames.fileframe.document || dgi('fileframe').contentDocument);
		s = ffd.getElementById("response").value;//.replace(new RegExp("\<\/?(head|title|body)\>","gi"),"");
		if (s.length > 0)
		{
			process(s);
		}
	}
	catch (ex)
	{
	}
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function disableStyle(ssArray)
{
	var t;
	var disable = "(t=='" + ssArray.join("' || t=='") + "')";
	for (var i = 0; i < stylesheets.length; i++)
	{
		t = stylesheets[i].title;
		if (eval(disable))
		{
			if (!stylesheets[i].disabled)
			{
				stylesheets[i].disabled = true;
			}
		}
	}	
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function applyStyle(ssArray,overwrite)
{
	var t;
	var enable = "(t=='" + ssArray.join("' || t=='") + "')";
	for (var i = 0; i < stylesheets.length; i++)
	{
		t = stylesheets[i].title;
		if (eval(enable))
		{
			if (stylesheets[i].disabled)
			{
				stylesheets[i].disabled = false;
				//alert("ENABLED " + stylesheets[i].title);
			}
		}
		else if (overwrite)
		{
			if (!stylesheets[i].disabled)
			{
				stylesheets[i].disabled = true;
				//alert("DISABLED " + stylesheets[i].title);
			}
		}
	}
} 

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function saveHistory(data)
{
	dfd.getElementById('dataframe_data_input').value = data;	
	dfd.getElementById('dataframe_form').submit();
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function makeRequest(evt, sender, method, url, data, save)
{
	//saveHistory(data);
	request(method, url, data);
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function openWin(url,name)
{
	features = "height=300,width=600,location=no,menubar=no,toolbar=no,resizable=yes,scrollbars=yes,status=no";
	popup = window.open(url,name,features);
	popup.focus();
	return popup;
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function popup(url,name,settings)
{
	var ht = settings.height || 300;
	var wd = settings.width || 600;
	var lb = settings.location || 'no';
	var mb = settings.menubar || 'no';
	var tb = settings.toolbar || 'no';
	var rs = settings.resizable || 'no';
	var sb = settings.scrollbars || 'yes';
	var st = settings.status || 'no';
	features = 'height=' + ht + ',width=' + wd + ',location=' + lb + ',menubar=' + mb + ',toolbar=' + tb + ',resizable=' + rs + ',scrollbars=' + sb + ',status=' + st + '';
	var p = window.open(url,name,features);
	p.focus();
	return p;
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function windowResize(evt)
{
	if (IE)
	{
		removeFocusOnAllLinks();
		resizeStrict(document);
	}
	
	switch (layout)
	{
		case "normal" :
			positionFooter();
			break;
		case "fill" :
			break;
		case "fixed" :
			break;
		case "normal-fill" :
			break;
	}
	document.documentElement.style.visibility = 'visible';
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function positionFooter()
{
	var p = dgi('page');
	var f = dgi('footer');
	var lm = dgi('leftmenu');
	var rm = dgi('rightmenu');
	var e = dgi('everything');
	
	var bottomOfLeftmenu = (parseInt(lm.offsetHeight,10) || 0) + (parseInt(style(lm).top,10) || 0);
	var bottomOfRightmenu = (parseInt(rm.offsetHeight,10) || 0) + (parseInt(style(rm).top,10) || 0);
	var bottomOfPage = (parseInt(p.offsetHeight,10) || 0) + (parseInt(style(p).top,10) || 0);
	
	var lowestPoint = Math.max(Math.max(bottomOfRightmenu,bottomOfLeftmenu),bottomOfPage);
	var anchorPosition = document.documentElement.clientHeight - extraHeight(style(e))/2 - (parseInt(style(f).height,10) || 0);
	f.style.display = "block";
	if (anchorPosition > lowestPoint)
	{
		//dgi('footer').style.top = "auto";
		//dgi('footer').style.bottom = "0px";
		dgi('footer').style.top = lowestPoint + "px";
	}
	else
	{
		dgi('footer').style.top = lowestPoint + "px";
	}	
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function debug(msg,__FILE__,__LINE__)
{
	if (typeof popup != "undefined")
	{
		/*
		d = document.createElement("div");
		d.innerHTML = "<span style='color:#cccccc;'>" + now() + "</span> : " + msg;
		s = "<div style='padding:5px 0px;";
		if (++dr % 2 == 0)
		{
			s += ";background:#eeeeee;";
		}
		s += "'><span style='color:#cccccc;'>" + now() + "</span> : " + msg + "</div>";
		popup.document.body.innerHTML += s;
		*/
		popup.document.write(msg);
	}
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function now()
{
		re = new RegExp("^([0-9]){1}$","i");
		var d = new Date();
		var Y = d.getFullYear().toString();
		var M = d.getMonth().toString().replace(re,"0$1");
		var D = d.getDay().toString().replace(re,"0$1");
		var h = d.getHours().toString().replace(re,"0$1");
		var m = d.getMinutes().toString().replace(re,"0$1");
		var s = d.getSeconds().toString().replace(re,"0$1");
		var f = d.getMilliseconds().toString();
		if (f.length == 1)
		{
			f = '00' + f;
		}
		else if (f.length == 2)
		{
			f = '0' + f;
		}
		return Y + "-" + M + "-" + D + " " + h + ":" + m + ":" + s + "." + f;
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function timestamp()
{
		var d = new Date();
		var u = d.getFullYear().toString() + "-" + d.getMonth().toString() + "-" + d.getDay().toString() + " " + d.getHours().toString() + ":" + d.getMinutes().toString() + ":" + d.getSeconds().toString() + "." + d.getMilliseconds().toString();
		return (d.getHours()*3600000 + d.getMinutes()*60000 + d.getSeconds()*1000 + d.getMilliseconds());
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function unique()
{
		var r1 = Math.round(Math.random()*1000000);
		var r2 = Math.round(Math.random()*1000000);
		return r1.toString() + timestamp().toString() + r2.toString();
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function parametersToArray(parameterString)
{
    var splitIndex;
    var x = [];
    var parameterArray = [];
    var eq;
    
    if (parameterString.charAt(0) == "#" || parameterString.charAt(0) == "?")
    {
        splitIndex = 1;
    }
    else
    {
        splitIndex = 0;
    }
    
    if (parameterString.indexOf("&") >= 0)
    {
        x = parameterString.slice(splitIndex).split("&");
    }
    else
    {
        x.push(parameterString);
    }
    
    for (i in x)
    {
        eq = x[i].indexOf("=");
        parameterArray[x[i].slice(0,eq)] = x[i].slice(eq+1);
    }
    return parameterArray;
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function showFormData(formName)
{
	var formData = [];
	var f = dgi(formName);
	var amp = "";
	var p = "";
	if (f)
	{
		for (i=0; i<(f.elements.length || 0); i++)
		{
			p = getInputData(f.elements[i]);
			if (p)
			{
				formData.push(p);
			}
		}
		if (formData.length > 0)
		{
			amp = "&";
		}
		return amp + formData.join("&");
	}
	else
	{
		return "";
	}
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function getInputData(input)
{
	var data = "";
	var n = input.name;
	var v = input.value;
	var t = input.type.toUpperCase();
	var normal = (t=="HIDDEN" || t=="TEXT" || t=="PASSWORD" || t=="SUBMIT" || t=="BUTTON" || t=="RESET" || t=="SELECT-ONE" || t=="TEXTAREA" || t=="IMAGE");
	var checkable = (t=="RADIO" || t=="CHECKBOX");
	var multiple = (t=="SELECT-MULTIPLE");
	var file = (t=="FILE");

	if (n)
	{
		if (normal)
		{
			data = encode(n) + "=" + encode(v);
		}
		else if	(checkable)
		{
			if (input.checked)
			{
				data = encode(n) + "=" + encode(v);
			}
		}
		else if	(multiple)
		{
			d = [];
			for (c=0; c<input.options.length; c++)
			{
				if (input.options[c].selected || (/_selected/i).test(input.id))
				{
					d.push(encode(n) + "=" + encode(input.options[c].value));
				}
			}
			data = d.join("&");
		}
		else if	(file)
		{
			data = "";
		/*
			data = n + "=" + v;
			ff = document.createElement("form");
			ff.setAttribute("enctype","multipart/form-data");
			ff.setAttribute("action",window.location.href);
			ff.setAttribute("method","post");
			ff.setAttribute("target","fileframe");
			ff.setAttribute("style","display:block;");
			ff.setAttribute("name","binaryForm");
			ff.setAttribute("id","binaryForm");

			_f = document.createElement("input");
			_f.setAttribute("type","hidden");
			_f.setAttribute("name","f");
			_f.setAttribute("value","propertyImageCommit");
			ff.appendChild(_f);

			_ajax = document.createElement("input");
			_ajax.setAttribute("type","hidden");
			_ajax.setAttribute("name","ajax");
			_ajax.setAttribute("value","1");
			ff.appendChild(_ajax);

			_maxfilesize = document.createElement("input");
			_maxfilesize.setAttribute("type","hidden");
			_maxfilesize.setAttribute("name","MAX_FILE_SIZE");
			_maxfilesize.setAttribute("value","100000000");
			ff.appendChild(_maxfilesize);

			p = input.parentNode;
			newinput = input.cloneNode(false);
			ff.appendChild(input);
			p.appendChild(newinput);
			
			document.body.appendChild(ff);
			ff.submit();
		*/
		}
	}
	return data;
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function runScripts(code)
{
	var s = code;
	scriptOpen = s.match(new RegExp("<script[^>]*>","i"));
	scriptClose = s.match(new RegExp("<\/script>","i"));
	var scripts = "";
	while (scriptOpen && scriptClose)
	{
		script = s.slice(s.indexOf(scriptOpen[0])+scriptOpen[0].length,s.indexOf(scriptClose[0]));
		eval(script);
		s = s.slice(s.indexOf(scriptClose[0])+scriptClose[0].length);
		scriptOpen = s.match(new RegExp("<script[^>]*>","i"));
		scriptClose = s.match(new RegExp("<\/script>","i"));
	}
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function getResponseTag(s)
{
	re = new RegExp("<responsetag>.+</responsetag>","im");
	matches = re.exec(s);
	if (matches)
	{
		for (i=0; i<matches.length; i++)
		{
			id = matches[i].replace(/(<responsetag>)(.+)/i,"$2").replace(/<\/responsetag>/i,"");
			return id;
		}
	}
	return null;
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function removeFocusOnAllLinks()
{
	for(i=0 ; i < document.links.length ; i++)
	{
		document.links[i].onfocus = blurLink;
	}
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function blurLink()
{
	if (IE)
	{
		this.blur();
	}
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function encodeParameterString(s)
{
	var d = [];
	var pairs = s.split("&");
	for (var i=0; i<pairs.length; i++)
	{
		nv = pairs[i].split("=");
		d.push(encodeURIComponent(nv[0]) + "=" + encodeURIComponent(nv[1]));
	}
	return d.join("&");
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function encode(s)
{
	return encodeURIComponent(s);
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function hide(evt,id)
{
	dgi(id).style.display = 'none';
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function show(evt,id)
{
	dgi(id).style.display = 'block';
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function list(e)
{
	var q = (arguments.length > 1) ? arguments[1] : "";
	var d = [];
	var re, p;
	for (p in e)
	{
		try
		{
			re = new RegExp(q,"gi");
			if (!q || re.test(p))
			{
				d.push(" [ " + (typeof e[p]) + " ] " + p + " = " + e[p]);
			}
		}
		catch (ex)
		{
			//alert(ex.name + " : " + ex.message);
		}
	}
	return d;
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function style(e)
{
	var s = null;
	if (window.getComputedStyle)
	{
		try
		{
			s = window.getComputedStyle(e,null);
		}
		catch(ex)
		{
			alert(e.nodeName + " '" + e.id + "'\n\n" + ex.message);
		}
	}
	
	if (s)
	{
		return s;
	}
	else if (e.currentStyle)
	{
		return e.currentStyle;
	}
	else
	{
		return null;
	}
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function positionedParent(e)
{
	var pn = e.parentNode;
	while (pn.nodeType == 1 && style(pn) && !style(pn).position.match(new RegExp("absolute|relative|fixed","i")))
	{
		pn = pn.parentNode;
	}
	return pn;
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function extraWidth(css)
{
	return	(parseInt(css.borderLeftWidth,10) || 0) +
			(parseInt(css.borderRightWidth,10) || 0) +
			(parseInt(css.paddingLeft,10) || 0) +
			(parseInt(css.paddingRight,10) || 0) +
			(parseInt(css.marginLeft,10) || 0) +
			(parseInt(css.marginRight,10) || 0) +
			(parseInt(css.left,10) || 0) +
			(parseInt(css.right,10) || 0);
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function extraHeight(css)
{
	return	(parseInt(css.borderTopWidth,10) || 0) +
			(parseInt(css.borderBottomWidth,10) || 0) +
			(parseInt(css.paddingTop,10) || 0) +
			(parseInt(css.paddingBottom,10) || 0) +
			(parseInt(css.marginTop,10) || 0) +
			(parseInt(css.marginBottom,10) || 0) +
			(parseInt(css.top,10) || 0) +
			(parseInt(css.bottom,10) || 0);
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function width(e)
{
	var css = style(e);
	var pn = positionedParent(e);
	var pnw = (pn.clientWidth) ? pn.clientWidth : e.clientWidth;
	var ew = extraWidth(css);
	if (!(parseInt(css.width,10) >= 0) && (parseInt(css.left,10) >= 0 && parseInt(css.right,10) >= 0))
	{
		return Math.max(pnw - ew,0) + "px";
	}
	else
	{
		return css.width;
	}
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function height(e)
{
	var css = style(e);
	var pn = positionedParent(e);
	var pnh = (pn.clientHeight) ? pn.clientHeight : e.clientHeight;
	var eh = extraHeight(css);	
	if (!(parseInt(css.height,10) >= 0) && (parseInt(css.top,10) >= 0 && parseInt(css.bottom,10) >= 0))
	{
		return Math.max(pnh - eh,0) + "px";
	}
	else
	{
		return css.height;
	}
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function left(e)
{
	var css = style(e);
	var pn = positionedParent(e);
	var pnw = (pn.clientWidth) ? pn.clientWidth : e.clientWidth;
	var ew = extraWidth(css);
	if (css.marginLeft == "auto" && css.marginRight == "auto")
	{
		return Math.max(Math.round((pnw - (parseInt(css.width,10) || 0) - ew) / 2),0) + "px";
	}
	else
	{
		return e.style.left;
	}
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function resize(e)
{
	resetInlineStyle(e);
	e.style.width = width(e);
	e.style.height = height(e);
	e.style.left = left(e);
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function resizeStrict(p)
{
	if (p.nodeType == 1 && style(p) && style(p).position.match(new RegExp("absolute","i")))
	{
		resize(p);
	}
		
	for (var i = 0; i < p.childNodes.length; i++)
	{
		if (p.childNodes[i].nodeType == 1 && !p.childNodes[i].nodeName.match(new RegExp("img","i")))
		{
			resizeStrict(p.childNodes[i]);
		}
	}
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function resetInlineStyle(e)
{
	e.style.cssText = null;
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function loadImages(evt,images,last_image)
{
	if (images)
	{
		alert(image_list.join("\n"));
	}
	for (i in image_list)
	{
		if ((image_list[i].match(new RegExp(last_image,"i")) || !last_image) && image_list[i+1])
		{
			dgi('image_bucket').src = image_list[i+1];
		}
	}
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function histAnchor(evt, u)
{
	a = document.createElement("a");
	a.setAttribute("id",u);
	a.setAttribute("name",u);
	//a.setAttribute("onclick","return false;");
	a.style.display = "block";
	t = document.createTextNode("history link for hash " + u);
	a.appendChild(t);
	return a;
}

//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
function process(response)
{
	e = dgi(getResponseTag(response));
	if (e)
	{
		e.innerHTML = response;
		runScripts(response);
	}
}

function dgi(id)
{
	return document.getElementById(id);
}

function dgtn(tag)
{
	return document.getElementsByTagName(tag);
}

function dce(tag)
{
	return document.createElement(tag);
}

function dct(text)
{
	return document.createTextNode(text);
}

function loading()
{
	var w = parseInt(dgi('readystate').style.width,10);
	if (w < parseInt(style(dgi('block_loading_control')).width,10))
	{
		dgi('readystate').style.width = (w + 1) + "px";
		setTimeout(loading,10);
	}
	else
	{
	}
}

function fadeout(e)
{
	var o = parseInt(e.style.opacity,10);
	if (o < 100)
	{
		e.style.opacity = (o + 1);
		setTimeout(function(){fadeout(e);},100);
	}
}

function href(url)
{
	window.location = url;
}

function parentForm(e)
{
	if (e.parentNode)
	{
		if (e.parentNode.tagName)
		{
			if (e.parentNode.tagName.toUpperCase()=="FORM")
			{
				return e.parentNode;
			}
			else
			{
				return parentForm(e.parentNode);
			}
		}
		else
		{
			return null;
		}
	}
	else
	{
		return null;
	}
}//////////////////////////////////////////////////////////////
//
//	NAME		:	request(_STRING_ , _STRING_ , _STRING_ , _STRING_)
//
//	DESCRIPTION	:	OPEN THE REQUEST OBJECT CONNECTION; 
//					ASSIGN THE RESPONSE EVENT HANDLER
//					FUNCTION; 
//					SEND THE REQUEST
//
//	PARAMETERS	:	url ::	ABSOLUTE OR RELATIVE URL WITH
//							WITH QUERY STRING APPENDED
//					vars :: QUERY STRING WITHOUT LEADING '?'
//					id :: ELEMENT ID TO RECEIVE DATA;
//					      PASS null FOR NO RESPONSE
//
//	RETURN		:	NONE
//
//	NOTES		:	url MUST BE FROM THE ORIGINAL SERVER
//					OR A SECURITY WARNING WILL POP UP;
//
//	AUTHOR		:	JOHNATHAN HEBERT
//
//	DATE		:	2006-03-17
//
//////////////////////////////////////////////////////////////
function request(method, url, data)
{
	try
	{		
		// DEFINE THE REQUEST VARIABLE
		var req = createRequest();
		
		var postdata = null;
		
		if (req)
		{
			// DEFAULT VALUE OF postdata IS null
			postdata = null;
			
			// SET THE POST DATA BASED ON THE METHOD PASSED IN
			if (method.toUpperCase() == "POST")
			{
				postdata = data;
			}
			else if (method.toUpperCase() == "GET")
			{
				if (url.indexOf("?") == -1)
				{
					url += "?";
				}
				url += data;
			}

			// OPEN THE CONNECTION ASYNCHRONOUSLY
			req.open(method.toUpperCase(), url, true);

			// ASSIGN THE RESPONSE EVENT HANDLER FUNCTION
			req.onreadystatechange = function() 
			{
		        response(req);
		    };

			// SET REQUEST HEADER FOR POST REQUESTS
			if (method.toUpperCase() == "POST")
			{
				req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			}
			
			// SEND THE REQUEST
			req.send(postdata);
		}
		else
		{
			msg  = "ERROR!!!\n\n";
			msg += "REQUEST OBJECT COULD NOT BE CONSTRUCTED";
			throw new Error(msg);
		}
		
		// RETURN FALSE SO THAT PAGE WILL NOT BE REFRESHED
		return false;
	}
	catch (ex)
	{
		alert("EXCEPTION WAS THROWN IN REQUEST METHOD :\n\n" + ex.name + " :\n" + ex.message);
	}
}

//////////////////////////////////////////////////////////////
//
//	NAME		:	response(_OBJECT_ , _OBJECT_)
//
//	DESCRIPTION	:	EVENT HANDLER FOR THE REQUEST OBJECT THAT
//					WILL CHECK THE readyState PROPERTY AND 
//					status PROPERTY BEFORE PROCESSING DATA
//
//	PARAMETERS	:	req :: REQUEST OBJECT
//					e :: ELEMENT TO RECEIVE DATA
//
//	RETURN		:	NONE
//
//	NOTES		:	readyState EQUAL TO 4 SIGNIFIES A COMPLETE
//					RESPONSE FROM THE SERVER
//
//	AUTHOR		:	JOHNATHAN HEBERT
//
//	DATE		:	2006-03-17
//
//////////////////////////////////////////////////////////////
function response(req) 
{
	// WAIT FOR COMPLETE AND OK RESPONSE BEFORE HANDLING DATA
	if (req.readyState == 4)
	{
		// REMOVE THE EVENT HANDLER FOR IE BUG
		req.onreadystatechange = function () {};
		
		// CREATE THE RESPONSE DATA VARIABLE
		var response = "";
		
		// IMPORT EACH LINE OF HEADER INTO AN ARRAY
		var headerArray = req.getAllResponseHeaders().split(/\r?\n/);
		
		// INITIALIZE AN ASSOCIATIVE HEADER ARRAY
		var headers = new Array();
		
		// CREATE EACH HEADER ARRAY ELEMENT LIKE headers["headerName"] = "headerValue"		
		for (var i = 0; i < headerArray.length; i++)
		{
			hc = headerArray[i].split(/:\s?/);
			headers[hc[0].toUpperCase()] = hc[1];
		}
		
		// CHECK REQUEST STATUS AND DISPLAY APPROPRIATE DATA
		if (req.status == 200)
		{
			response = req.responseText;
		}
		else
		{
			response  = "ERROR CODE : " + req.status + "<br>" +
						"ERROR MESSAGE : " + req.statusText + "<hr><br><br>" +
						req.responseText;
		}
		
		process(response);
	}
	else
	{
		// DO SOMETHING WHILE REQUEST IS NOT YET COMPLETE
	}
}

//////////////////////////////////////////////////////////////
//
//	NAME		:	createXMLHttpRequest()
//
//	DESCRIPTION	:	CREATE REQUEST OBJECT IF POSSIBLE
//
//	PARAMETERS	:	NONE
//
//	RETURN		:	VALID REQUEST OBJECT OR null OBJECT
//
//	NOTES		:	EACH BROWSER HAS A DIFFERENT WAY OF
//					INSTANTIATING THE REQUEST OBJECT
//
//	AUTHOR		:	JOHNATHAN HEBERT
//
//	DATE		:	2006-03-17
//
//////////////////////////////////////////////////////////////
function createRequest()
{
	// DEFINE ARRAY OF ALL MICROSOFT XMLHTTPREQUEST OBJECTS
	var requestVersions = 	[
							"MSXML2.XMLHttp.5.0",
							"MSXML2.XMLHttp.4.0",
							"MSXML2.XMLHttp.3.0",
							"MSXML2.XMLHttp",
							"Microsoft.XMLHttp"
							];
	
    // ATTEMPT TO CREATE MOZILLA XMLHTTPREQUEST
    if (typeof(XMLHttpRequest) != "undefined")
    {
        return new XMLHttpRequest();
    }

	// ATTEMPT TO CREATE MICROSOFT XMLHTTPREQUEST REQUEST
	for (var i = 0; i < requestVersions.length; i++)
	{
		try
		{
			return new ActiveXObject(requestVersions[i]);
		}
		catch (ex)
		{
			// DO NOTHING
		}
	}
	
	// RETURN null OBJECT UPON FAILURE TO CREATE OBJECT
	return null;
}// vim: ts=4:sw=4:nu:fdc=4:nospell
/**
 * Ext.ux.form.LovCombo, List of Values Combo
 *
 * @author    Ing. Jozef Sakáloš
 * @copyright (c) 2008, by Ing. Jozef Sakáloš
 * @date      16. April 2008
 * @version   $Id: Ext.ux.form.LovCombo.js 285 2008-06-06 09:22:20Z jozo $
 *
 * @license Ext.ux.form.LovCombo.js is licensed under the terms of the Open Source
 * LGPL 3.0 license. Commercial use is permitted to the extent that the 
 * code/component(s) do NOT become part of another Open Source or Commercially
 * licensed development library or toolkit without explicit permission.
 * 
 * License details: http://www.gnu.org/licenses/lgpl.html
 */
 
/*global Ext */

// add RegExp.escape if it has not been already added
if('function' !== typeof RegExp.escape) {
	RegExp.escape = function(s) {
		if('string' !== typeof s) {
			return s;
		}
		// Note: if pasting from forum, precede ]/\ with backslash manually
		return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
	}; // eo function escape
}

// create namespace
Ext.ns('Ext.ux.form');
 
/**
 *
 * @class Ext.ux.form.LovCombo
 * @extends Ext.form.ComboBox
 */
Ext.ux.form.LovCombo = Ext.extend(Ext.form.ComboBox, {

	// {{{
    // configuration options
	/**
	 * @cfg {String} checkField name of field used to store checked state.
	 * It is automatically added to existing fields.
	 * Change it only if it collides with your normal field.
	 */
	 checkField:'checked'

	/**
	 * @cfg {String} separator separator to use between values and texts
	 */
    ,separator:','

	/**
	 * @cfg {String/Array} tpl Template for items. 
	 * Change it only if you know what you are doing.
	 */
	// }}}
    // {{{
    ,initComponent:function() {
        
		// template with checkbox
		if(!this.tpl) {
			this.tpl = 
				 '<tpl for=".">'
				+'<div class="x-combo-list-item">'
				+'<img src="' + Ext.BLANK_IMAGE_URL + '" '
				+'class="ux-lovcombo-icon ux-lovcombo-icon-'
				+'{[values.' + this.checkField + '?"checked":"unchecked"' + ']}">'
				+'<div class="ux-lovcombo-item-text">{' + (this.displayField || 'text' )+ '}</div>'
				+'</div>'
				+'</tpl>'
			;
		}
 
        // call parent
        Ext.ux.form.LovCombo.superclass.initComponent.apply(this, arguments);

		// install internal event handlers
		this.on({
			 scope:this
			,beforequery:this.onBeforeQuery
			,blur:this.onRealBlur
		});

		// remove selection from input field
		this.onLoad = this.onLoad.createSequence(function() {
			if(this.el) {
				var v = this.el.dom.value;
				this.el.dom.value = '';
				this.el.dom.value = v;
			}
		});
 
    } // e/o function initComponent
    // }}}
	// {{{
	/**
	 * Disables default tab key bahavior
	 * @private
	 */
	,initEvents:function() {
		Ext.ux.form.LovCombo.superclass.initEvents.apply(this, arguments);

		// disable default tab handling - does no good
		this.keyNav.tab = false;

	} // eo function initEvents
	// }}}
	// {{{
	/**
	 * clears value
	 */
	,clearValue:function() {
		this.value = '';
		this.setRawValue(this.value);
		this.store.clearFilter();
		this.store.each(function(r) {
			r.set(this.checkField, false);
		}, this);
		if(this.hiddenField) {
			this.hiddenField.value = '';
		}
		this.applyEmptyText();
	} // eo function clearValue
	// }}}
	// {{{
	/**
	 * @return {String} separator (plus space) separated list of selected displayFields
	 * @private
	 */
	,getCheckedDisplay:function() {
		var re = new RegExp(this.separator, "g");
		return this.getCheckedValue(this.displayField).replace(re, this.separator + ' ');
	} // eo function getCheckedDisplay
	// }}}
	// {{{
	/**
	 * @return {String} separator separated list of selected valueFields
	 * @private
	 */
	,getCheckedValue:function(field) {
		field = field || this.valueField;
		var c = [];

		// store may be filtered so get all records
		var snapshot = this.store.snapshot || this.store.data;

		snapshot.each(function(r) {
			if(r.get(this.checkField)) {
				c.push(r.get(field));
			}
		}, this);

		return c.join(this.separator);
	} // eo function getCheckedValue
	// }}}
	// {{{
	/**
	 * beforequery event handler - handles multiple selections
	 * @param {Object} qe query event
	 * @private
	 */
	,onBeforeQuery:function(qe) {
		qe.query = qe.query.replace(new RegExp(this.getCheckedDisplay() + '[ ' + this.separator + ']*'), '');
	} // eo function onBeforeQuery
	// }}}
	// {{{
	/**
	 * blur event handler - runs only when real blur event is fired
	 */
	,onRealBlur:function() {
		this.list.hide();
		var rv = this.getRawValue();
		var rva = rv.split(new RegExp(RegExp.escape(this.separator) + ' *'));
		var va = [];
		var snapshot = this.store.snapshot || this.store.data;

		// iterate through raw values and records and check/uncheck items
		Ext.each(rva, function(v) {
			snapshot.each(function(r) {
				if(v === r.get(this.displayField)) {
					va.push(r.get(this.valueField));
				}
			}, this);
		}, this);
		this.setValue(va.join(this.separator));
		this.store.clearFilter();
	} // eo function onRealBlur
	// }}}
	// {{{
	/**
	 * Combo's onSelect override
	 * @private
	 * @param {Ext.data.Record} record record that has been selected in the list
	 * @param {Number} index index of selected (clicked) record
	 */
	,onSelect:function(record, index) {
        if(this.fireEvent('beforeselect', this, record, index) !== false){

			// toggle checked field
			record.set(this.checkField, !record.get(this.checkField));

			// display full list
			if(this.store.isFiltered()) {
				this.doQuery(this.allQuery);
			}

			// set (update) value and fire event
			this.setValue(this.getCheckedValue());
            this.fireEvent('select', this, record, index);
        }
	} // eo function onSelect
	// }}}
	// {{{
	/**
	 * Sets the value of the LovCombo
	 * @param {Mixed} v value
	 */
	,setValue:function(v) {
		if(v) {
			v = '' + v;
			if(this.valueField) {
				this.store.clearFilter();
				this.store.each(function(r) {
					var checked = !(!v.match(
						 '(^|' + this.separator + ')' + RegExp.escape(r.get(this.valueField))
						+'(' + this.separator + '|$)'))
					;

					r.set(this.checkField, checked);
				}, this);
				this.value = this.getCheckedValue();
				this.setRawValue(this.getCheckedDisplay());
				if(this.hiddenField) {
					this.hiddenField.value = this.value;
				}
			}
			else {
				this.value = v;
				this.setRawValue(v);
				if(this.hiddenField) {
					this.hiddenField.value = v;
				}
			}
			if(this.el) {
				this.el.removeClass(this.emptyClass);
			}
		}
		else {
			this.clearValue();
		}
	} // eo function setValue
	// }}}
	// {{{
	/**
	 * Selects all items
	 */
	,selectAll:function() {
        this.store.each(function(record){
            // toggle checked field
            record.set(this.checkField, true);
        }, this);

        //display full list
        this.doQuery(this.allQuery);
        this.setValue(this.getCheckedValue());
    } // eo full selectAll
	// }}}
	// {{{
	/**
	 * Deselects all items. Synonym for clearValue
	 */
    ,deselectAll:function() {
		this.clearValue();
    } // eo full deselectAll 
	// }}}

}); // eo extend
 
// register xtype
Ext.reg('lovcombo', Ext.ux.form.LovCombo); 
 
// eof
Ext.form.ComboBox.prototype.anyMatch = false;

Ext.form.ComboBox.prototype.doQuery = function(q, forceAll, anyMatch){
    if(q === undefined || q === null){
        q = '';
    }
    var qe = {
        query: q,
        forceAll: forceAll,
        combo: this,
        cancel:false
    };
    if(this.fireEvent('beforequery', qe)===false || qe.cancel){
        return false;
    }
    q = qe.query;
    forceAll = qe.forceAll;
    if(forceAll === true || (q.length >= this.minChars)){
        if(this.lastQuery !== q){
            this.lastQuery = q;
            if(this.mode == 'local'){
                this.selectedIndex = -1;
                if(forceAll){
                    this.store.clearFilter();
                }else{
                    this.store.filter(this.displayField, q, anyMatch);
                }
                this.onLoad();
            }else{
                this.store.baseParams[this.queryParam] = q;
                this.store.load({
                    params: this.getParams(q)
                });
                this.expand();
            }
        }else{
            this.selectedIndex = -1;
            this.onLoad();
        }
    }
};
	
Ext.form.ComboBox.prototype.initQuery = function(){
    this.doQuery(this.getRawValue(),false,this.anyMatch);
};/**
 * flashembed 1.0.0. Adobe Flash embedding script
 * 
 * Copyright (c) 2009 Tero Piirainen
 * http://flowplayer.org/tools/flash-embed.html
 *
 * Dual licensed under MIT and GPL 2+ licenses
 * http://www.opensource.org/licenses
 *
 * Launch  : March 2008
 * Version : 1.0.0 - Tue Feb 03 2009 10:48:12 GMT-0000 (GMT+00:00)
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(5(){4 j=m 17==\'5\';5 1k(){3(l.19){8 14}4 d=M;3(d&&d.1K&&d.1n&&d.2J){2w(l.N);l.N=n;A(4 i=0;i<l.F.1l;i++){l.F[i].1i()}l.F=n;l.19=1f}}4 l=j?17:5(f){3(l.19){8 f()}3(l.N){l.F.Y(f)}w{l.F=[f];l.N=1D(1k,13)}};5 B(b,a){3(a){A(U H a){3(a.18(U)){b[U]=a[U]}}}8 b}5 y(b){2d(1p(b)){T\'W\':b=b.o(I 1V(\'(["\\\\\\\\])\',\'g\'),\'\\\\$1\');b=b.o(/^\\s?(\\d+)%/,"$1S");8\'"\'+b+\'"\';T\'1j\':8\'[\'+1h(b,5(a){8 y(a)}).1g(\',\')+\']\';T\'5\':8\'"5()"\';T\'t\':4 c=[];A(4 d H b){3(b.18(d)){c.Y(\'"\'+d+\'":\'+y(b[d]))}}8\'{\'+c.1g(\',\')+\'}\'}8 1L(b).o(/\\s/g," ").o(/\\\'/g,"\\"")}5 1p(a){3(a===n||a===Z){8 14}4 b=m a;8(b==\'t\'&&a.Y)?\'1j\':b}3(E.1r){E.1r("1E",5(){1C=5(){};1A=5(){}})}5 1h(c,a){4 b=[];A(4 i H c){3(c.18(i)){b[i]=a(c[i])}}8 b}5 v(p,c){4 a=M.2H;4 d=\'<t X="\'+p.X+\'" V="\'+p.V+\'"\';3(a&&!p.z){p.z="2u"+(""+2r.2o()).1t(9)}3(p.z){d+=\' z="\'+p.z+\'"\'}3(p.R||!a){d+=\' 2h="\'+p.G+\'" 2f="2e/x-2c-1w"\'}w{d+=\' 2b="28:26-24-21-1Z-1Y"\'}d+=\'>\';3(p.R||a){d+=\'<16 15="1U" 1d="\'+p.G+\'" />\'}4 e=B({},p);e.X=e.V=e.z=e.R=e.G=n;A(4 k H e){3(e[k]!==n){d+=\'<16 15="\'+k+\'" 1d="\'+e[k]+\'" />\'}}4 b="";3(c){A(4 f H c){3(c[f]!==n){b+=f+\'=\'+(m c[f]==\'t\'?y(c[f]):c[f])+\'&\'}}b=b.1t(0,b.1l-1);d+=\'<16 15="1T" 1d=\\\'\'+b+\'\\\' />\'}d+="</t>";8 d}5 J(f,c,g){4 h=q.P();B(K,{1R:5(){8 f},1Q:5(){8 1P},P:5(){8 h},1O:5(){8 g},1N:5(){8 f.1M},v:5(){8 v(c,g)}});4 b=c.u;4 a=c.12;4 d=!b||q.11(b);3(d){c.L=c.u=c.12=n;f.D=v(c,g)}w 3(b&&a&&q.11([6,1J])){B(c,{G:a});g={1I:1H.1x,1G:\'1F\',1W:M.1X};f.D=v(c,g)}w{3(f.D.o(/\\s/g,\'\')!==\'\'){}w{f.D="<1m>J u "+b+" 1B 20 1q 1z</1m>"+"<1o>"+(h[0]>0?"1y u 1q "+h:"25 2G 2D 1w 2C 2B")+"</1o>"+"<p>2A 2z u 2y <a 1x=\'2x://2t.2s.2q/2p/2n\'>2m</a></p>"}}3(!d&&c.L){4 e=c.L.1i(K);3(m e==\'W\'){f.D=e}}}E.q=5(d,c,e){3(m d==\'W\'){4 b=M.1n(d);3(b){d=b}w{l(5(){q(d,c,e)});8}}3(!d){8}4 a={X:\'1u%\',V:\'1u%\',2l:1f,2k:\'1s\',2j:\'2i\',u:n,L:n,12:n,R:14};3(m c==\'W\'){c={G:c}}B(a,c);8 I J(d,a,e)};B(E.q,{P:5(){4 d=[0,0];3(1a.1c&&m 1a.1c["1v J"]=="t"){4 f=1a.1c["1v J"].2g;3(m f!="Z"){f=f.o(/^.*\\s+(\\S+\\s+\\S+$)/,"$1");4 c=O(f.o(/^(.*)\\..*$/,"$1"),10);4 a=/r/.2v(f)?O(f.o(/^.*r(.*)$/,"$1"),10):0;d=[c,a]}}w 3(E.Q){1b{4 b=I Q("C.C.7")}1e(e){1b{b=I Q("C.C.6");d=[6,0];b.2a="1s"}1e(29){3(d[0]==6){8}}1b{b=I Q("C.C")}1e(27){}}3(m b=="t"){f=b.2E("$u");3(m f!="Z"){f=f.o(/^\\S+\\s+(.*)$/,"$1").2F(",");d=[O(f[0],10),O(f[2],10)]}}}8 d},11:5(c){4 a=q.P();4 b=(a[0]>c[0])||(a[0]==c[0]&&a[1]>=c[1]);8 b},23:l,y:y,v:v});3(j){17.22.q=5(b,a){8 K.2I(5(){q(K,b,a)})}}})();',62,170,'|||if|var|function|||return||||||||||||||typeof|null|replace||flashembed|||object|version|getHTML|else||asString|id|for|extend|ShockwaveFlash|innerHTML|window|ready|src|in|new|Flash|this|onFail|document|timer|parseInt|getVersion|ActiveXObject|w3c||case|key|height|string|width|push|undefined||isSupported|expressInstall||false|name|param|jQuery|hasOwnProperty|done|navigator|try|plugins|value|catch|true|join|map|call|array|isDomReady|length|h2|getElementById|h3|typeOf|is|attachEvent|always|substring|100|Shockwave|flash|href|Your|required|__flash_savedUnloadHandler|or|__flash_unloadHandler|setInterval|onbeforeunload|PlugIn|MMplayerType|location|MMredirectURL|65|getElementsByTagName|String|firstChild|getApi|getFlashvars|conf|getConf|getContainer|1pct|flashvars|movie|RegExp|MMdoctitle|title|444553540000|96B8|greater|11cf|prototype|domReady|AE6D|You|D27CDB6E|eee|clsid|ee|AllowScriptAccess|classid|shockwave|switch|application|type|description|data|high|quality|allowscriptaccess|allowfullscreen|here|getflashplayer|random|go|com|Math|adobe|www|_|test|clearInterval|http|from|latest|Download|installed|plugin|no|GetVariable|split|have|all|each|body'.split('|'),0,{}));/** 
 * flowplayer.js 3.0.0. The Flowplayer API
 * 
 * Copyright 2008 Flowplayer Oy
 * 
 * This file is part of Flowplayer.
 * 
 * Flowplayer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Flowplayer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Flowplayer.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Version: 3.0.0 - Tue Nov 25 2008 16:25:46 GMT-0000 (GMT+00:00)
 */
(function(){function log(args){if(typeof opera=='object'){opera.postError("$f.fireEvent: "+args.join(" | "));}else if(typeof console=='object'){console.log("$f.fireEvent",[].slice.call(args));}}function clone(obj){if(!obj||typeof obj!='object'){return obj;}var temp=new obj.constructor();for(var key in obj){if(obj.hasOwnProperty(key)){temp[key]=clone(obj[key]);}}return temp;}function each(obj,fn){if(!obj){return;}var name,i=0,length=obj.length;if(length===undefined){for(name in obj){if(fn.call(obj[name],name,obj[name])===false){break;}}}else{for(var value=obj[0];i<length&&fn.call(value,i,value)!==false;value=obj[++i]){}}return obj;}function el(id){return document.getElementById(id);}function extend(to,from,skipFuncs){if(to&&from){each(from,function(name,value){if(!skipFuncs||typeof value!='function'){to[name]=value;}});}}function select(query){var index=query.indexOf(".");if(index!=-1){var tag=query.substring(0,index)||"*";var klass=query.substring(index+1,query.length);var els=[];each(document.getElementsByTagName(tag),function(){if(this.className&&this.className.indexOf(klass)!=-1){els.push(this);}});return els;}}function stopEvent(e){e=e||window.event;if(e.preventDefault){e.stopPropagation();e.preventDefault();}else{e.returnValue=false;e.cancelBubble=true;}return false;}function bind(to,evt,fn){to[evt]=to[evt]||[];to[evt].push(fn);}function makeId(){return"_"+(""+Math.random()).substring(2,10);}var Clip=function(json,index,player){var self=this;var cuepoints={};var listeners={};this.index=index;if(typeof json=='string'){json={url:json};}extend(this,json,true);each(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),function(){var evt="on"+this;if(evt.indexOf("*")!=-1){evt=evt.substring(0,evt.length-1);var before="onBefore"+evt.substring(2);self[before]=function(fn){bind(listeners,before,fn);return self;};}self[evt]=function(fn){bind(listeners,evt,fn);return self;};if(index==-1){if(self[before]){player[before]=self[before];}if(self[evt]){player[evt]=self[evt];}}});extend(this,{onCuepoint:function(points,fn){if(arguments.length==1){cuepoints.embedded=[null,points];return self;}if(typeof points=='number'){points=[points];}var fnId=makeId();cuepoints[fnId]=[points,fn];if(player.isLoaded()){player._api().fp_addCuepoints(points,index,fnId);}return self;},update:function(json){extend(self,json);if(player.isLoaded()){player._api().fp_updateClip(json,index);}var conf=player.getConfig();var clip=(index==-1)?conf.clip:conf.playlist[index];extend(clip,json,true);},_fireEvent:function(evt,arg1,arg2,target){if(evt=='onLoad'){each(cuepoints,function(key,val){player._api().fp_addCuepoints(val[0],index,key);});return false;}if(index!=-1){target=self;}if(evt=='onCuepoint'){var fn=cuepoints[arg1];if(fn){return fn[1].call(player,target,arg2);}}if(evt=='onStart'||evt=='onUpdate'){extend(target,arg1);if(!target.duration){target.duration=arg1.metaData.duration;}else{target.fullDuration=arg1.metaData.duration;}}var ret=true;each(listeners[evt],function(){ret=this.call(player,target,arg1);});return ret;}});if(json.onCuepoint){self.onCuepoint.apply(self,json.onCuepoint);delete json.onCuepoint;}each(json,function(key,val){if(typeof val=='function'){bind(listeners,key,val);delete json[key];}});if(index==-1){player.onCuepoint=this.onCuepoint;}};var Plugin=function(name,json,player,fn){var listeners={};var self=this;var hasMethods=false;if(fn){extend(listeners,fn);}each(json,function(key,val){if(typeof val=='function'){listeners[key]=val;delete json[key];}});extend(this,{animate:function(props,speed,fn){if(!props){return self;}if(typeof speed=='function'){fn=speed;speed=500;}if(typeof props=='string'){var key=props;props={};props[key]=speed;speed=500;}if(fn){var fnId=makeId();listeners[fnId]=fn;}if(speed===undefined){speed=500;}json=player._api().fp_animate(name,props,speed,fnId);return self;},css:function(props,val){if(val!==undefined){var css={};css[props]=val;props=css;}json=player._api().fp_css(name,props);extend(self,json);return self;},show:function(){this.display='block';player._api().fp_showPlugin(name);return self;},hide:function(){this.display='none';player._api().fp_hidePlugin(name);return self;},toggle:function(){this.display=player._api().fp_togglePlugin(name);return self;},fadeTo:function(o,speed,fn){if(typeof speed=='function'){fn=speed;speed=500;}if(fn){var fnId=makeId();listeners[fnId]=fn;}this.display=player._api().fp_fadeTo(name,o,speed,fnId);this.opacity=o;return self;},fadeIn:function(speed,fn){return self.fadeTo(1,speed,fn);},fadeOut:function(speed,fn){return self.fadeTo(0,speed,fn);},getName:function(){return name;},_fireEvent:function(evt,arg){if(evt=='onUpdate'){var json=arg||player._api().fp_getPlugin(name);if(!json){return;}extend(self,json);delete self.methods;if(!hasMethods){each(json.methods,function(){var method=""+this;self[method]=function(){var a=[].slice.call(arguments);var ret=player._api().fp_invoke(name,method,a);return ret=='undefined'?self:ret;};});hasMethods=true;}}var fn=listeners[evt];if(fn){fn.call(self,arg);if(evt.substring(0,1)=="_"){delete listeners[evt];}}}});};function Player(wrapper,params,conf){var
self=this,api=null,html,commonClip,playlist=[],plugins={},listeners={},playerId,apiId,activeIndex,swfHeight,wrapperHeight;extend(self,{id:function(){return playerId;},isLoaded:function(){return(api!==null);},getParent:function(){return wrapper;},hide:function(all){if(all){wrapper.style.height="0px";}if(api){api.style.height="0px";}return self;},show:function(){wrapper.style.height=wrapperHeight+"px";if(api){api.style.height=swfHeight+"px";}return self;},isHidden:function(){return api&&parseInt(api.style.height,10)===0;},load:function(fn){if(!api&&self._fireEvent("onBeforeLoad")!==false){each(players,function(){this.unload();});html=wrapper.innerHTML;flashembed(wrapper,params,{config:conf});if(fn){fn.cached=true;bind(listeners,"onLoad",fn);}}return self;},unload:function(){if(api&&html.replace(/\s/g,'')!==''&&!api.fp_isFullscreen()&&self._fireEvent("onBeforeUnload")!==false){api.fp_close();wrapper.innerHTML=html;self._fireEvent("onUnload");api=null;}return self;},getClip:function(index){if(index===undefined){index=activeIndex;}return playlist[index];},getCommonClip:function(){return commonClip;},getPlaylist:function(){return playlist;},getPlugin:function(name){var plugin=plugins[name];if(!plugin&&self.isLoaded()){var json=self._api().fp_getPlugin(name);if(json){plugin=new Plugin(name,json,self);plugins[name]=plugin;}}return plugin;},getScreen:function(){return self.getPlugin("screen");},getControls:function(){return self.getPlugin("controls");},getConfig:function(copy){return copy?clone(conf):conf;},getFlashParams:function(){return params;},loadPlugin:function(name,url,props,fn){if(typeof props=='function'){fn=props;props={};}var fnId=fn?makeId():"_";self._api().fp_loadPlugin(name,url,props,fnId);var arg={};arg[fnId]=fn;var p=new Plugin(name,null,self,arg);plugins[name]=p;return p;},getState:function(){return api?api.fp_getState():-1;},play:function(clip){function play(){if(clip!==undefined){self._api().fp_play(clip);}else{self._api().fp_play();}}if(api){play();}else{self.load(function(){play();});}return self;},getVersion:function(){var js="flowplayer.js 3.0.0-rc5";if(api){var ver=api.fp_getVersion();ver.push(js);return ver;}return js;},_api:function(){if(!api){throw"Flowplayer "+self.id()+" not loaded. Try moving your call to player's onLoad event";}return api;},_dump:function(){console.log(listeners);}});each(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,Fullscreen*,FullscreenExit,Error").split(","),function(){var name="on"+this;if(name.indexOf("*")!=-1){name=name.substring(0,name.length-1);var name2="onBefore"+name.substring(2);self[name2]=function(fn){bind(listeners,name2,fn);return self;};}self[name]=function(fn){bind(listeners,name,fn);return self;};});each(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,reset").split(","),function(){var name=this;self[name]=function(arg){if(!api){return self;}var ret=(arg===undefined)?api["fp_"+name]():api["fp_"+name](arg);return ret=='undefined'?self:ret;};});self._fireEvent=function(evt,arg0,arg1,arg2){if(conf.debug){log(arguments);}if(evt=='onLoad'&&!api){api=api||el(apiId);swfHeight=api.clientHeight;each(playlist,function(){this._fireEvent("onLoad");});each(plugins,function(name,p){p._fireEvent("onUpdate");});commonClip._fireEvent("onLoad");}if(evt=='onContextMenu'){each(conf.contextMenu[arg0],function(key,fn){fn.call(self);});return;}if(evt=='onPluginEvent'){var name=arg0.name||arg0;var p=plugins[name];if(p){if(arg0.name){p._fireEvent("onUpdate",arg0);}p._fireEvent(arg1);}return;}if(evt=='onPlaylistReplace'){playlist=[];var index=0;each(arg0,function(){playlist.push(new Clip(this,index++));});}var ret=true;if(arg0===0||(arg0&&arg0>=0)){activeIndex=arg0;var clip=playlist[arg0];if(clip){ret=clip._fireEvent(evt,arg1,arg2);}if(!clip||ret!==false){ret=commonClip._fireEvent(evt,arg1,arg2,clip);}}var i=0;each(listeners[evt],function(){ret=this.call(self,arg0);if(this.cached){listeners[evt].splice(i,1);}if(ret===false){return false;}i++;});return ret;};function init(){if($f(wrapper)){return null;}wrapperHeight=parseInt(wrapper.style.height,10)||wrapper.clientHeight;players.push(self);if(typeof params=='string'){params={src:params};}playerId=wrapper.id||"fp"+makeId();apiId=params.id||playerId+"_api";params.id=apiId;conf.playerId=playerId;if(typeof conf=='string'){conf={clip:{url:conf}};}conf.clip=conf.clip||{};commonClip=new Clip(conf.clip,-1,self);if(wrapper.getAttribute("href")){conf.playlist=[{url:wrapper.getAttribute("href",2)}];}conf.playlist=conf.playlist||[conf.clip];var index=0;each(conf.playlist,function(){var clip=this;if(typeof clip=='object'&&clip.length){clip=""+clip;}if(!clip.url&&typeof clip=='string'){clip={url:clip};}extend(clip,conf.clip,true);conf.playlist[index]=clip;clip=new Clip(clip,index,self);playlist.push(clip);index++;});each(conf,function(key,val){if(typeof val=='function'){bind(listeners,key,val);delete conf[key];}});each(conf.plugins,function(name,val){if(val){plugins[name]=new Plugin(name,val,self);}});if(!conf.plugins||conf.plugins.controls===undefined){plugins.controls=new Plugin("controls",null,self);}params.bgcolor=params.bgcolor||"#000000";params.version=params.version||[9,0];params.expressInstall='http://www.flowplayer.org/swf/expressinstall.swf';function doClick(e){if(self._fireEvent("onBeforeClick")!==false){self.load();}return stopEvent(e);}html=wrapper.innerHTML;if(html.replace(/\s/g,'')!==''){if(wrapper.addEventListener){wrapper.addEventListener("click",doClick,false);}else if(wrapper.attachEvent){wrapper.attachEvent("onclick",doClick);}}else{if(wrapper.addEventListener){wrapper.addEventListener("click",stopEvent,false);}self.load();}}if(typeof wrapper=='string'){flashembed.domReady(function(){var node=el(wrapper);if(!node){throw"Flowplayer cannot access element: "+wrapper;}else{wrapper=node;init();}});}else{init();}}var players=[];function Iterator(arr){this.length=arr.length;this.each=function(fn){each(arr,fn);};this.size=function(){return arr.length;};}window.flowplayer=window.$f=function(){var instance=null;var arg=arguments[0];if(!arguments.length){each(players,function(){if(this.isLoaded()){instance=this;return false;}});return instance||players[0];}if(arguments.length==1){if(typeof arg=='number'){return players[arg];}else{if(arg=='*'){return new Iterator(players);}each(players,function(){if(this.id()==arg.id||this.id()==arg||this.getParent()==arg){instance=this;return false;}});return instance;}}if(arguments.length>1){var swf=arguments[1];var conf=(arguments.length==3)?arguments[2]:{};if(typeof arg=='string'){if(arg.indexOf(".")!=-1){var instances=[];each(select(arg),function(){instances.push(new Player(this,clone(swf),clone(conf)));});return new Iterator(instances);}else{var node=el(arg);return new Player(node!==null?node:arg,swf,conf);}}else if(arg){return new Player(arg,swf,conf);}}return null;};extend(window.$f,{fireEvent:function(id,evt,a0,a1,a2){var p=$f(id);return p?p._fireEvent(evt,a0,a1,a2):null;},addPlugin:function(name,fn){Player.prototype[name]=fn;return $f;},each:each,extend:extend});if(typeof jQuery=='function'){jQuery.prototype.flowplayer=function(params,conf){if(!arguments.length||typeof arguments[0]=='number'){var arr=[];this.each(function(){var p=$f(this);if(p){arr.push(p);}});return arguments.length?arr[arguments[0]]:new Iterator(arr);}return this.each(function(){$f(this,clone(params),conf?clone(conf):{});});};}})();(function(){var jQ=typeof jQuery=='function';function isDomReady(){if(domReady.done){return false;}var d=document;if(d&&d.getElementsByTagName&&d.getElementById&&d.body){clearInterval(domReady.timer);domReady.timer=null;for(var i=0;i<domReady.ready.length;i++){domReady.ready[i].call();}domReady.ready=null;domReady.done=true;}}var domReady=jQ?jQuery:function(f){if(domReady.done){return f();}if(domReady.timer){domReady.ready.push(f);}else{domReady.ready=[f];domReady.timer=setInterval(isDomReady,13);}};function extend(to,from){if(from){for(key in from){if(from.hasOwnProperty(key)){to[key]=from[key];}}}return to;}function concatVars(vars){var out="";for(var key in vars){if(vars[key]){out+=[key]+'='+asString(vars[key])+'&';}}return out.substring(0,out.length-1);}function asString(obj){switch(typeOf(obj)){case'string':obj=obj.replace(new RegExp('(["\\\\])','g'),'\\$1');obj=obj.replace(/^\s?(\d+)%/,"$1pct");return'"'+obj+'"';case'array':return'['+map(obj,function(el){return asString(el);}).join(',')+']';case'function':return'"function()"';case'object':var str=[];for(var prop in obj){if(obj.hasOwnProperty(prop)){str.push('"'+prop+'":'+asString(obj[prop]));}}return'{'+str.join(',')+'}';}return String(obj).replace(/\s/g," ").replace(/\'/g,"\"");}function typeOf(obj){if(obj===null||obj===undefined){return false;}var type=typeof obj;return(type=='object'&&obj.push)?'array':type;}if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};});}function map(arr,func){var newArr=[];for(var i in arr){if(arr.hasOwnProperty(i)){newArr[i]=func(arr[i]);}}return newArr;}function getEmbedCode(p,c){var html='<embed type="application/x-shockwave-flash" ';if(p.id){extend(p,{name:p.id});}for(var key in p){if(p[key]!==null){html+=key+'="'+p[key]+'"\n\t';}}if(c){html+='flashvars=\''+concatVars(c)+'\'';}html+='/>';return html;}function getObjectCode(p,c,embeddable){var html='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';html+='width="'+p.width+'" height="'+p.height+'"';if(!p.id&&document.all){p.id="_"+(""+Math.random()).substring(5);}if(p.id){html+=' id="'+p.id+'"';}html+='>';if(document.all){p.src+=((p.src.indexOf("?")!=-1?"&":"?")+Math.random());}html+='\n\t<param name="movie" value="'+p.src+'" />';var e=extend({},p);e.id=e.width=e.height=e.src=null;for(var k in e){if(e[k]!==null){html+='\n\t<param name="'+k+'" value="'+e[k]+'" />';}}if(c){html+='\n\t<param name="flashvars" value=\''+concatVars(c)+'\' />';}if(embeddable){html+=getEmbedCode(p,c);}html+="</object>";return html;}function getFullHTML(p,c){return getObjectCode(p,c,true);}function getHTML(p,c){var isNav=navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length;return(isNav)?getEmbedCode(p,c):getObjectCode(p,c);}window.flashembed=function(root,userParams,flashvars){var params={src:'#',width:'100%',height:'100%',version:null,onFail:null,expressInstall:null,debug:false,allowfullscreen:true,allowscriptaccess:'always',quality:'high',type:'application/x-shockwave-flash',pluginspage:'http://www.adobe.com/go/getflashplayer'};if(typeof userParams=='string'){userParams={src:userParams};}extend(params,userParams);var version=flashembed.getVersion();var required=params.version;var express=params.expressInstall;var debug=params.debug;if(typeof root=='string'){var el=document.getElementById(root);if(el){root=el;}else{domReady(function(){flashembed(root,userParams,flashvars);});return;}}if(!root){return;}if(!required||flashembed.isSupported(required)){params.onFail=params.version=params.expressInstall=params.debug=null;root.innerHTML=getHTML(params,flashvars);return root.firstChild;}else if(params.onFail){var ret=params.onFail.call(params,flashembed.getVersion(),flashvars);if(ret===true){root.innerHTML=ret;}}else if(required&&express&&flashembed.isSupported([6,65])){extend(params,{src:express});flashvars={MMredirectURL:location.href,MMplayerType:'PlugIn',MMdoctitle:document.title};root.innerHTML=getHTML(params,flashvars);}else{if(root.innerHTML.replace(/\s/g,'')!==''){}else{root.innerHTML="<h2>Flash version "+required+" or greater is required</h2>"+"<h3>"+(version[0]>0?"Your version is "+version:"You have no flash plugin installed")+"</h3>"+"<p>Download latest version from <a href='"+params.pluginspage+"'>here</a></p>";}}return root;};extend(window.flashembed,{getVersion:function(){var version=[0,0];if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){var _d=navigator.plugins["Shockwave Flash"].description;if(typeof _d!="undefined"){_d=_d.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var _m=parseInt(_d.replace(/^(.*)\..*$/,"$1"),10);var _r=/r/.test(_d)?parseInt(_d.replace(/^.*r(.*)$/,"$1"),10):0;version=[_m,_r];}}else if(window.ActiveXObject){try{var _a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");version=[6,0];_a.AllowScriptAccess="always";}catch(ee){if(version[0]==6){return;}}try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(eee){}}if(typeof _a=="object"){_d=_a.GetVariable("$version");if(typeof _d!="undefined"){_d=_d.replace(/^\S+\s+(.*)$/,"$1").split(",");version=[parseInt(_d[0],10),parseInt(_d[2],10)];}}}return version;},isSupported:function(version){var now=flashembed.getVersion();var ret=(now[0]>version[0])||(now[0]==version[0]&&now[1]>=version[1]);return ret;},domReady:domReady,asString:asString,getHTML:getHTML,getFullHTML:getFullHTML});if(jQ){jQuery.prototype.flashembed=function(params,flashvars){return this.each(function(){flashembed(this,params,flashvars);});};}})();;Ext.BLANK_IMAGE_URL = '/images/spacer.gif';