/**
 * SWFObject v1.5.1: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept={};}if(typeof deconcept.util=="undefined"){deconcept.util={};}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil={};}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params={};this.variables={};this.attributes=[];if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10]||"";},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15]||"";},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=[];var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+(this.getAttribute("style")||"")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+(this.getAttribute("style")||"")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

// <?php !! This fools phpdocumentor into parsing this file
/**
* @version $Id: joomla.javascript.js 5689 2006-11-09 00:55:42Z Saka $
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* Joomla! is Free Software
*/

// general utility for browsing a named array or object
function xshow(o) {
	s = '';
	for(e in o) {s += e+'='+o[e]+'\n';}
	alert( s );
}

/**
* Writes a dynamically generated list
* @param string The parameters to insert into the <select> tag
* @param array A javascript array of list options in the form [key,value,text]
* @param string The key to display for the initial state of the list
* @param string The original key that was selected
* @param string The original item value that was selected
*/
function writeDynaList( selectParams, source, key, orig_key, orig_val ) {
	var html = '\n	<select ' + selectParams + '>';
	var i = 0;
	for (x in source) {
		if (source[x][0] == key) {
			var selected = '';
			if ((orig_key == key && orig_val == source[x][1]) || (i == 0 && orig_key != key)) {
				selected = 'selected="selected"';
			}
			html += '\n		<option value="'+source[x][1]+'" '+selected+'>'+source[x][2]+'</option>';
		}
		i++;
	}
	html += '\n	</select>';

	document.writeln( html );
}

/**
* Changes a dynamically generated list
* @param string The name of the list to change
* @param array A javascript array of list options in the form [key,value,text]
* @param string The key to display
* @param string The original key that was selected
* @param string The original item value that was selected
*/
function changeDynaList( listname, source, key, orig_key, orig_val ) {
	var list = eval( 'document.adminForm.' + listname );

	// empty the list
	for (i in list.options.length) {
		list.options[i] = null;
	}
	i = 0;
	for (x in source) {
		if (source[x][0] == key) {
			opt = new Option();
			opt.value = source[x][1];
			opt.text = source[x][2];

			if ((orig_key == key && orig_val == opt.value) || i == 0) {
				opt.selected = true;
			}
			list.options[i++] = opt;
		}
	}
	list.length = i;
}

/**
* Adds a select item(s) from one list to another
*/
function addSelectedToList( frmName, srcListName, tgtListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );
	var tgtList = eval( 'form.' + tgtListName );

	var srcLen = srcList.length;
	var tgtLen = tgtList.length;
	var tgt = "x";

	//build array of target items
	for (var i=tgtLen-1; i > -1; i--) {
		tgt += "," + tgtList.options[i].value + ","
	}

	//Pull selected resources and add them to list
	//for (var i=srcLen-1; i > -1; i--) {
	for (var i=0; i < srcLen; i++) {
		if (srcList.options[i].selected && tgt.indexOf( "," + srcList.options[i].value + "," ) == -1) {
			opt = new Option( srcList.options[i].text, srcList.options[i].value );
			tgtList.options[tgtList.length] = opt;
		}
	}
}

function delSelectedFromList( frmName, srcListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	var srcLen = srcList.length;

	for (var i=srcLen-1; i > -1; i--) {
		if (srcList.options[i].selected) {
			srcList.options[i] = null;
		}
	}
}

function moveInList( frmName, srcListName, index, to) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );
	var total = srcList.options.length-1;

	if (index == -1) {
		return false;
	}
	if (to == +1 && index == total) {
		return false;
	}
	if (to == -1 && index == 0) {
		return false;
	}

	var items = new Array;
	var values = new Array;

	for (i=total; i >= 0; i--) {
		items[i] = srcList.options[i].text;
		values[i] = srcList.options[i].value;
	}
	for (i = total; i >= 0; i--) {
		if (index == i) {
			srcList.options[i + to] = new Option(items[i],values[i], 0, 1);
			srcList.options[i] = new Option(items[i+to], values[i+to]);
			i--;
		} else {
			srcList.options[i] = new Option(items[i], values[i]);
	   }
	}
	srcList.focus();
}

function getSelectedOption( frmName, srcListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	i = srcList.selectedIndex;
	if (i != null && i > -1) {
		return srcList.options[i];
	} else {
		return null;
	}
}

function setSelectedValue( frmName, srcListName, value ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	var srcLen = srcList.length;

	for (var i=0; i < srcLen; i++) {
		srcList.options[i].selected = false;
		if (srcList.options[i].value == value) {
			srcList.options[i].selected = true;
		}
	}
}

function getSelectedRadio( frmName, srcGroupName ) {
	var form = eval( 'document.' + frmName );
	var srcGroup = eval( 'form.' + srcGroupName );

	if (srcGroup[0]) {
		for (var i=0, n=srcGroup.length; i < n; i++) {
			if (srcGroup[i].checked) {
				return srcGroup[i].value;
			}
		}
	} else {
		if (srcGroup.checked) {
			return srcGroup.value;
		} // if the one button is checked, return zero
	}
   // if we get to this point, no radio button is selected
   return null;
}

function getSelectedValue( frmName, srcListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	i = srcList.selectedIndex;
	if (i != null && i > -1) {
		return srcList.options[i].value;
	} else {
		return null;
	}
}

function getSelectedText( frmName, srcListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	i = srcList.selectedIndex;
	if (i != null && i > -1) {
		return srcList.options[i].text;
	} else {
		return null;
	}
}

function chgSelectedValue( frmName, srcListName, value ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	i = srcList.selectedIndex;
	if (i != null && i > -1) {
		srcList.options[i].value = value;
		return true;
	} else {
		return false;
	}
}

// Form specific functions for editting content images

function showImageProps(base_path) {
	form = document.adminForm;
	value = getSelectedValue( 'adminForm', 'imagelist' );
	parts = value.split( '|' );
	form._source.value = parts[0];
	setSelectedValue( 'adminForm', '_align', parts[1] || '' );
	form._alt.value = parts[2] || '';
	form._border.value = parts[3] || '0';
	form._caption.value = parts[4] || '';
	setSelectedValue( 'adminForm', '_caption_position', parts[5] || '' );
	setSelectedValue( 'adminForm', '_caption_align', parts[6] || '' );
	form._width.value = parts[7] || '';

	//previewImage( 'imagelist', 'view_imagelist', base_path );
	srcImage = eval( "document." + 'view_imagelist' );
	srcImage.src = base_path + parts[0];
}

function applyImageProps() {
	form = document.adminForm;
	if (!getSelectedValue( 'adminForm', 'imagelist' )) {
		alert( "Select and image from the list" );
		return;
	}
	value = form._source.value + '|'
	+ getSelectedValue( 'adminForm', '_align' ) + '|'
	+ form._alt.value + '|'
	+ parseInt( form._border.value ) + '|'
	+ form._caption.value + '|'
	+ getSelectedValue( 'adminForm', '_caption_position' ) + '|'
	+ getSelectedValue( 'adminForm', '_caption_align' ) + '|'
	+ form._width.value;
	chgSelectedValue( 'adminForm', 'imagelist', value );
}

function previewImage( list, image, base_path ) {
	form = document.adminForm;
	srcList = eval( "form." + list );
	srcImage = eval( "document." + image );
	var srcOption = srcList.options[(srcList.selectedIndex < 0) ? 0 : srcList.selectedIndex];
	var fileName = srcOption.text;
	var fileName2 = srcOption.value;
	if (fileName.length == 0 || fileName2.length == 0) {
		srcImage.src = 'images/blank.gif';
	} else {
		srcImage.src = base_path + fileName2;
	}
}

/**
* Toggles the check state of a group of boxes
*
* Checkboxes must have an id attribute in the form cb0, cb1...
* @param The number of box to 'check'
* @param An alternative field name
*/
function checkAll( n, fldName ) {
  if (!fldName) {
     fldName = 'cb';
  }
	var f = document.adminForm;
	var c = f.toggle.checked;
	var n2 = 0;
	for (i=0; i < n; i++) {
		cb = eval( 'f.' + fldName + '' + i );
		if (cb) {
			cb.checked = c;
			n2++;
		}
	}
	if (c) {
		document.adminForm.boxchecked.value = n2;
	} else {
		document.adminForm.boxchecked.value = 0;
	}
}

function listItemTask( id, task ) {
    var f = document.adminForm;
    cb = eval( 'f.' + id );
    if (cb) {
        for (i = 0; true; i++) {
            cbx = eval('f.cb'+i);
            if (!cbx) break;
            cbx.checked = false;
        } // for
        cb.checked = true;
        f.boxchecked.value = 1;
        submitbutton(task);
    }
    return false;
}

function hideMainMenu()
{
	document.adminForm.hidemainmenu.value=1;
}

function isChecked(isitchecked){
	if (isitchecked == true){
		document.adminForm.boxchecked.value++;
	}
	else {
		document.adminForm.boxchecked.value--;
	}
}

/**
* Default function.  Usually would be overriden by the component
*/
function submitbutton(pressbutton) {
	submitform(pressbutton);
}

/**
* Submit the admin form
*/
function submitform(pressbutton){
	document.adminForm.task.value=pressbutton;
	try {
		document.adminForm.onsubmit();
		}
	catch(e){}
	document.adminForm.submit();
}

/**
* Submit the control panel admin form
*/
function submitcpform(sectionid, id){
	document.adminForm.sectionid.value=sectionid;
	document.adminForm.id.value=id;
	submitbutton("edit");
}

/**
* Getting radio button that is selected.
*/
function getSelected(allbuttons){
	for (i=0;i<allbuttons.length;i++) {
		if (allbuttons[i].checked) {
			return allbuttons[i].value
		}
	}
}

// JS Calendar
var calendar = null; // remember the calendar object so that we reuse
// it and avoid creating another

// This function gets called when an end-user clicks on some date
function selected(cal, date) {
	cal.sel.value = date; // just update the value of the input field
}

// And this gets called when the end-user clicks on the _selected_ date,
// or clicks the "Close" (X) button.  It just hides the calendar without
// destroying it.
function closeHandler(cal) {
	cal.hide();			// hide the calendar

	// don't check mousedown on document anymore (used to be able to hide the
	// calendar when someone clicks outside it, see the showCalendar function).
	Calendar.removeEvent(document, "mousedown", checkCalendar);
}

// This gets called when the user presses a mouse button anywhere in the
// document, if the calendar is shown.  If the click was outside the open
// calendar this function closes it.
function checkCalendar(ev) {
	var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
	for (; el != null; el = el.parentNode)
	// FIXME: allow end-user to click some link without closing the
	// calendar.  Good to see real-time stylesheet change :)
	if (el == calendar.element || el.tagName == "A") break;
	if (el == null) {
		// calls closeHandler which should hide the calendar.
		calendar.callCloseHandler(); Calendar.stopEvent(ev);
	}
}

// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.
function showCalendar(id) {
	var el = document.getElementById(id);
	if (calendar != null) {
		// we already have one created, so just update it.
		calendar.hide();		// hide the existing calendar
		calendar.parseDate(el.value); // set it to a new date
	} else {
		// first-time call, create the calendar
		var cal = new Calendar(true, null, selected, closeHandler);
		calendar = cal;		// remember the calendar in the global
		cal.setRange(1900, 2070);	// min/max year allowed
		calendar.create();		// create a popup calendar
		calendar.parseDate(el.value); // set it to a new date
	}
	calendar.sel = el;		// inform it about the input field in use
	calendar.showAtElement(el);	// show the calendar next to the input field

	// catch mousedown on the document
	Calendar.addEvent(document, "mousedown", checkCalendar);
	return false;
}

/**
* Pops up a new window in the middle of the screen
*/
function popupWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

// LTrim(string) : Returns a copy of a string without leading spaces.
function ltrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      s = s.substring(j, i);
   }
   return s;
}

//RTrim(string) : Returns a copy of a string without trailing spaces.
function rtrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;       // Get length of string
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }
   return s;
}

// Trim(string) : Returns a copy of a string without leading or trailing spaces
function trim(str) {
   return rtrim(ltrim(str));
}

function mosDHTML(){
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")<-1
	this.ie5=(this.ver.indexOf("MSIE 5")<-1 && this.dom && !this.opera5)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")<-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")<-1
	this.ns6=(this.dom && parseInt(this.ver) <= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5);

	this.activeTab = '';
	this.onTabStyle = 'ontab';
	this.offTabStyle = 'offtab';

	this.setElemStyle = function(elem,style) {
		document.getElementById(elem).className = style;
	}
	this.showElem = function(id) {
		if (elem = document.getElementById(id)) {
			elem.style.visibility = 'visible';
			elem.style.display = 'block';
		}
	}
	this.hideElem = function(id) {
		if (elem = document.getElementById(id)) {
			elem.style.visibility = 'hidden';
			elem.style.display = 'none';
		}
	}
	this.cycleTab = function(name) {
		if (this.activeTab) {
			this.setElemStyle( this.activeTab, this.offTabStyle );
			page = this.activeTab.replace( 'tab', 'page' );
			this.hideElem(page);
		}
		this.setElemStyle( name, this.onTabStyle );
		this.activeTab = name;
		page = this.activeTab.replace( 'tab', 'page' );
		this.showElem(page);
	}
	return this;
}
var dhtml = new mosDHTML();

function MM_findObj(n, d) { //v4.01
	var p,i,x;
	if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n);
	return x;
}
function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x;
	if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr;
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document;
	if(d.images){
	if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
	for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function saveorder( n ) {
	checkAll_button( n );
}

//needed by saveorder function
function checkAll_button( n ) {
	for ( var j = 0; j <= n; j++ ) {
		box = eval( "document.adminForm.cb" + j );
		if ( box ) {
			if ( box.checked == false ) {
				box.checked = true;
			}
		} else {
			alert("You cannot change the order of items, as an item in the list is `Checked Out`");
			return;
		}
	}
	submitform('saveorder');
}
/**
* @param object A form element
* @param string The name of the element to find
*/
function getElementByName( f, name ) {
	if (f.elements) {
		for (i=0, n=f.elements.length; i < n; i++) {
			if (f.elements[i].name == name) {
				return f.elements[i];
			}
		}
	}
	return null;
}

/* packed with http://dean.edwards.name/packer/   */
/* DO NOT REMOVE THIS NOTICE PROJECT:  mygosuMenu  (Modded By Guy Thomas for Mambo) VERSION: 1.1.6 COPYRIGHT: (c) 2003,2004 Cezary Tomczak  LINK:  http://gosu.pl/dhtml/mygosumenu.html */

eval(function(p,a,c,k,e,d){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--)d[e(c)]=k[c]||e(c);k=[function(e){return d[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;}('f 2x(7){3.10="1A";3.1Y=0;3.1i={"1J":0,"22":33};3.N={"19":{"O":0,"x":0},"1K":{"O":0,"x":0}};3.1U=1V;3.1c={"j":36,"1N":-1};3.w={"15":2I(h.3e.Y),"1o":(/2j 5/.z(2d.2b)),"1q":(/2j 6/.z(2d.2b))};9(!3.w.15){3.w.1o=1D;3.w.1q=1D}3.2B=f(){9(!h.o(3.7)){g}9(3.10!="1A"&&3.10!="2J"){g 2S("2x.2B() 2N. 2R Z 10: \'"+3.10+"\'")}9(3.w.15&&3.w.1o){2C()}9(!3.w.15){2u()}2H();2L();1w(h.o(3.7).y,3.H,3.7)};f 2u(){4 1R=h.o(8.7).J("a");m(4 a=0;a<1R.c;a++){4 p=1R[a];1M=13(h.2P.2O(p,\'\').2Q("K"));p.e.K=(1M-(p.L-1M))+"u"}};f 2L(){4 1u=h.o(8.7).J("r");4 n=D 1z();4 1v=D 1z();m(4 i=0;i<1u.c;i++){9(1u[i].l=="S"){n.A(1u[i])}}m(4 i=0;i<n.c;i++){1v.A(2e(n[i]))}m(4 i=0;i<n.c;i++){n[i].e.K=(1v[i])+"u"}m(4 i=0;i<n.c;i++){2k(n[i],1v[i])}};f 2C(){4 1k=h.o(8.7).J("a");m(4 i=0;i<1k.c;i++){9(/2m/.z(1k[i].l)){1k[i].1y=\'<r 2E="2E">\'+1k[i].1y+\'</r>\'}}};f 2H(){9(8.10!="1A"){g}9(8.1Y==0){g}4 23=h.o(8.7).J("23").16(0);4 M=23.y;4 2M=0;4 1Q=0;m(i=0;i<M.c;i++){9(M[i].1n==1){4 p=M[i].J("a").16(0);9(p.l=="2c"){1Q++}}}4 1l=8.1Y/1Q;9(!8.w.15){m(i=0;i<M.c;i++){9(M[i].1n==1){4 p=M[i].J("a").16(0);p.e.K=1l+"u";4 28=1l-(p.L-1l);4 1e=28;1j}}}E{4 1e=1l}m(i=0;i<M.c;i++){9(M[i].1n==1){4 p=M[i].J("a").16(0);9(p.l=="2c"){p.e.K=1e+"u"}}}4 1t=h.o(8.7).J("r");m(k=0;k<1t.c;k++){9(1t[k].l=="S"){4 1a=1t[k].J("r").16(0);9(/^1a/.z(1a.l)){4 2f=1a.J("a").16(0);9(1a.L<1e){1a.e.K=(1e)+"u";2f.e.K=(1e)+"u"}}}}};f 1O(17){4 V=D 1z();m(4 i=0;i<17.y.c;i++){m(4 1r=0;1r<17.y[i].y[0].y.c;1r++){4 1X=17.y[i].y[0].y[1r];9(/^1a/.z(1X.l)){V.A(1X.y[0])}}}g(V)};f 2e(17){4 p=17.J("a").16(0);4 1I=p.2a.2a;9(8.w.15){g(1I.L)}E{4 V=1O(17);m(4 a=0;a<V.c;a++){V[a].e.1d="3b-3c"}4 2g=1I.L;m(4 a=0;a<V.c;a++){V[a].e.1d="21"}}g 2g;};f 2k(2l,1s){1L=1O(2l);m(4 a=0;a<1L.c;a++){4 p=1L[a];9(p.1n==1&&/2m/.z(p.l)){p.e.K=(1s)+"u";9(!8.w.15){9(p.L>13(p.e.K)){4 29=1s-(p.L-1s);p.e.K=(29)+"u"}}}}};f 1w(q,H,7){m(4 i=0;i<q.c;i++){9(1!=q[i].1n){37}38(1V){26/(\\39\\b)|(^3g)/.z(q[i].l):q[i].7=7+"-"+H.c;H.A(D 1z());q[i].27=2r;q[i].2n=2o;1j;26/\\2s\\b/.z(q[i].l):q[i].7=7+"-"+(H.c-1)+"-S";q[i].27=2p;q[i].2n=2q;4 B=h.o(7+"-"+(H.c-1));4 Q=h.o(q[i].7);4 t=D R(B.7);9(1==t.2i){9("1A"==8.10){Q.e.O=B.20+B.2v+8.N.19.O+"u";9(8.w.1o){Q.e.x=8.N.19.x+"u"}E{Q.e.x=B.1P+8.N.19.x+"u"}}E 9("2J"==8.10){Q.e.O=B.20+8.N.19.O+"u";9(8.w.1o){Q.e.x=B.L+8.N.19.x+"u"}E{Q.e.x=B.1P+B.L+8.N.19.x+"u"}}}E{Q.e.O=B.20+8.N.1K.O+"u";Q.e.x=B.1P+B.L+8.N.1K.x+"u"}8.n.A(q[i].7);8.14.A(0);8.11.A(0);9(8.1U&&8.w.1q){q[i].1y=q[i].1y+\'<I 7="\'+q[i].7+\'-I" 2X="2Y:1D;" 2Z="2W" 2T="0" e="N: 2U; O: 2K; x: 2K; 1d: 2F; 2V:34(35=0);"></I>\'}1j}9(q[i].y){9(/\\2s\\b/.z(q[i].l)){1w(q[i].y,H[H.c-1],7+"-"+(H.c-1))}E{1w(q[i].y,H,7)}}}};f 2r(){8.1g++;4 G=3.7+"-S";9(8.j.c){4 t=D R(1p(8.j));t=h.o(t.1m().7);9(/((U\\d)|(T))-X/.z(t.l)){t.l=t.l.1C(/((U\\d)|(T))-X/,"$1")}}9(18(8.n,G)){1G();8.11[F(8.n,G)]++;4 v=8.14[F(8.n,G)];4 12=1x(f(a,b){g f(){8.2A(a,b)}}(G,v),8.1i.1J);8.W.A(12)}E{9(8.j.c){1G();4 12=1x(f(a,b){g f(){8.2z(a,b)}}(3.7,8.1g),8.1i.1J);8.W.A(12)}}};f 2o(){8.1g++;4 G=3.7+"-S";9(18(8.n,G)){8.14[F(8.n,G)]++;9(18(8.j,G)){4 v=8.11[F(8.n,G)];4 12=1x(f(a,b){g f(){8.1f(a,b)}}(G,v),8.1i.22);8.W.A(12)}}};f 2p(){8.11[F(8.n,3.7)]++;4 t=D R(3.7);4 C=h.o(t.1m().7);9(!/((U\\d)|(T))-X/.z(C.l)){C.l=C.l.1C(/((U\\d)|(T))/,"$1-X")}};f 2q(){8.14[F(8.n,3.7)]++;4 v=8.11[F(8.n,3.7)];4 12=1x(f(a,b){g f(){8.1f(a,b)}}(3.7,v),8.1i.22);8.W.A(12)};3.2A=f(7,v){9(1Z v!="1H"){9(v!=3.14[F(3.n,7)]){g}}3.14[F(3.n,7)]++;9(3.j.c){9(7==1p(3.j)){g}4 t=D R(7);4 1b=t.1W();m(4 i=3.j.c-1;i>=0;i--){9(18(1b,3.j[i])){1j}E{3.1f(3.j[i])}}}4 t=D R(7);4 C=h.o(t.1m().7);9(!/((U\\d)|(T))-X/.z(C.l)){C.l=C.l.1C(/((U\\d)|(T))/,"$1-X")}9(h.2G){h.o(7).e.1d="21"}h.o(7).e.2t="j";h.o(7).e.1c=3.1c.j;9(3.1U&&3.w.1q){4 r=h.o(7);9(r.Y.30==31){r.e.1T=0;r.e.2w=0;r.e.1S=0;r.e.2y=0}4 I=h.o(7+"-I");I.e.K=r.L+13(r.Y.1T)+13(r.Y.2w);I.e.32=r.2v+13(r.Y.1S)+13(r.Y.2y);I.e.O=-13(r.Y.1S);I.e.x=-13(r.Y.1T);I.e.1c=-1;I.e.1d="21"}3.j.A(7)};3.2z=f(7,v){9(1Z v!="1H"){9(v!=3.1g){g}}3.1g++;9(3.j.c){4 t=D R(7+"-S");4 1b=t.1W();m(4 i=3.j.c-1;i>=0;i--){9(18(1b,3.j[i])){1j}E{3.1f(3.j[i])}}}};3.1f=f(7,v){9(1Z v!="1H"){9(v!=3.11[F(3.n,7)]){g}9(7==1p(3.j)){m(4 i=3.j.c-1;i>=0;i--){3.1f(3.j[i])}g}}4 t=D R(7);4 C=h.o(t.1m().7);9(/((U\\d)|(T))-X/.z(C.l)){C.l=C.l.1C(/((U\\d)|(T))-X/,"$1")}h.o(7).e.1c=3.1c.1N;h.o(7).e.2t="1N";9(h.2G){h.o(7).e.1d="2F"}9(18(3.j,7)){9(7==1p(3.j)){3.j.1E()}E{}}E{}3.11[F(3.n,7)]++};f R(7){3.Z=8;3.7=7;3.2h=f(){4 s=3.7.1h(3.Z.7.c);g 24(s,"-")};3.1m=f(){4 s=3.7.1h(3.Z.7.c);4 a=s.1B("-");a.1E();g D R(3.Z.7+a.3d("-"))};3.3f=f(){4 s=3.7.1h(3.Z.7.c);4 a=s.1B("-");g a.c>2};3.3i=f(){g 2I(h.o(3.7+"-S"))};3.1W=f(){4 s=3.7.1h(3.Z.7.c);s=s.1h(0,s.c-"-S".c);4 a=s.1B("-");a.3h();a.1E();4 s=3.Z.7;4 1b=[];m(4 i=0;i<a.c;i++){s+=("-"+a[i]);1b.A(s+"-S")}g 1b};3.2i=3.2h()};f 1G(){m(4 i=8.W.c-1;i>=0;i--){3a(8.W[i]);8.W.1E()}};4 8=3;3.7=7;3.H=[];3.n=[];3.14=[];3.11=[];3.1g=0;3.W=[];3.j=[];};f F(P,1F){m(4 i=0;i<P.c;i++){9(P[i]===1F){g i}}g-1;};f 18(P,1F){m(4 i=0;i<P.c;i++){9(P[i]===1F){g 1V}}g 1D};f 24(25,2D){g 25.1B(2D).c-1};f 1p(P){g P[P.c-1]};',62,205,'|||this|var|||id|self|if|||length||style|function|return|document||visible||className|for|sections|getElementById|anc|nodes|div||el|px|cnt|browser|left|childNodes|test|push|box1|parent|new|else|itemInArray|id_section|tree|iframe|getElementsByTagName|width|offsetWidth|rootItems|position|top|inArray|box2|Element|section|Item|Item_|sectAnchors|timers|active|currentStyle|menu|type|sectionsHideCnt|timerId|parseInt|sectionsShowCnt|ie|item|chkSect|stringInArray|level1|menuCont|parents|zIndex|display|setMenuWidth|hideSection|itemShowCnt|substr|delay|break|elements|menuWidth|getParent|nodeType|ie5|lastItemOfArray|ie6|cn|maxWidth|kids|arr|widths|parse|setTimeout|innerHTML|Array|horizontal|split|replace|false|pop|srchItem|clearTimers|undefined|menuBox|show|levelX|ancs|menuItemWidth|hidden|getAnchorsFromSection|offsetLeft|numRoots|allAnchors|borderTopWidth|borderLeftWidth|fixIeSelectBoxBug|true|getParentSections|menContTest|fitWidth|typeof|offsetTop|block|hide|tr|countSubStr|srcStr|case|onmouseover|mozWidth|noPadWidth|parentNode|appVersion|parentItem|navigator|getMaxWidth|subAnc|checkWidth|getLevel|level|MSIE|setMaxWidth|sect|subItem|onmouseout|itemOut|sectionOver|sectionOut|itemOver|bsection|visibility|fixMozWidth|offsetHeight|borderRightWidth|DropDownMenuX|borderBottomWidth|showItem|showSection|init|fixWrap|subStr|nowrap|none|all|fitHorizontalToTabWidth|Boolean|vertical|0px|fixSections|topWidth|failed|getComputedStyle|defaultView|getPropertyValue|Unknown|alert|frameborder|absolute|filter|no|src|javascript|scrolling|border|null|height|400|alpha|opacity|500|continue|switch|bparentItem|clearTimeout|table|cell|join|body|hasParent|subItem_|shift|hasChilds'.split('|'),0,{}))
/* packed with http://dean.edwards.name/packer/   */
/* DO NOT REMOVE THIS NOTICE PROJECT:  mygosuMenu  VERSION: 1.1.6 COPYRIGHT: (c) 2003,2004 Cezary Tomczak  LINK:  http://gosu.pl/dhtml/mygosumenu.html */
eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--)d[c.toString(a)]=k[c]||c.toString(a);k=[function(e){return d[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}('8(!6.5.p){6.5.p=e(){c l;8(3.4){l=3[3.4-1];3.4-=1}d l}}8(!6.5.j){6.5.j=e(){7(c i=0;i<a.4;++i){3[3.4]=a[i]}d 3.4}}8(!6.5.o){6.5.o=e(){c k;8(3.4){k=3[0];7(c i=0;i<3.4-1;++i){3[i]=3[i+1]}3.4-=1}d k}}8(!6.5.n){6.5.n=e(){8(a.4){c i,f=a.4;7(i=3.4+f-1;i>=f;--i){3[i]=3[i-f]}7(i=0;i<f;++i){3[i]=a[i]}}d 3.4}}8(!6.5.m){6.5.m=e(b,h){c 9=[],g=[],i;7(i=2;i<a.4;++i){9.j(a[i])}7(i=b;(i<b+h)&&(i<3.4);++i){g.j(3[i])}7(i=b+h;i<3.4;++i){3[i-h]=3[i]}3.4-=g.4;7(i=3.4+9.4-1;i>=b+9.4;--i){3[i]=3[i-9.4]}7(i=0;i<9.4;++i){3[b+i]=9[i]}d g}}',26,26,'|||this|length|prototype|Array|for|if|elements|arguments|index|var|return|function|len|removed|howMany||push|first|last|splice|unshift|shift|pop'.split('|'),0,{}))

//Javascript for SmilieInsert and Form Check
function validatecomment(){
  if (document.commentform.cmttext.value==''){
    alert(ponygallery_enter_comment);
  }
  else if (document.commentform.cmtname.value=='' || document.commentform.cmtname.value=='Ваше имя'){
    alert('Укажите ваше имя');
  }
  else if(pg_use_code==1) {
    if (document.commentform.pg_code.value==''){
      alert(ponygallery_enter_code);
    } else {
      document.commentform.action = 'index.php';
      document.commentform.submit();
    }
  } else {
    document.commentform.action = 'index.php';
    document.commentform.submit();
  }
}


function pg_smilie(thesmile) {
  document.commentform.cmttext.value += thesmile+' ';
  document.commentform.cmttext.focus();
}


function validatesend2friend(){
  if ((document.send2friend.send2friendname.value=='') || (document.send2friend.send2friendemail.value=='')){
    alert(ponygallery_enter_name_email);
  } else {
    document.send2friend.action = 'index.php';
    document.send2friend.submit();
  }
}


function checkMe() {
  var form = document.adminForm;
  form.imgtitle.style.backgroundColor = '';
  form.catid.style.backgroundColor = '';
  var doublefiles = false;
  // do field validation
  if (form.imgtitle.value == ''|| form.imgtitle.value == null) {
    alert(ponygallery_pic_must_have_title);
    form.imgtitle.style.backgroundColor = pg_ffwrong;
    form.imgtitle.focus();
    return false;
  } else if (form.catid.value == "0") {
    alert(ponygallery_select_category);
    form.catid.style.backgroundColor = pg_ffwrong;
    form.catid.focus();
    return false;
    //Prüft ob überhaupt Dateien angeben wurden.
  } else {
    var zaehl = 0;
    var arenofiles = true;
    var fullfields = new Array();
    var screenshotfieldname = new Array();
    var screenshotfieldvalue = new Array();
    for(i=0;i<pg_inputcounter;i++) {
      screenshotfieldname[i] = 'arrscreenshot['+i+']';
      screenshotfieldvalue[i] = document.getElementsByName(screenshotfieldname[i])[0].value;
      document.getElementsByName(screenshotfieldname[i])[0].style.backgroundColor='';
      if(screenshotfieldvalue[i] != "") {
        arenofiles = false;
        fullfields[zaehl] = i;
        zaehl++;
      }
    }
  }
  if(arenofiles) {
    alert(ponygallery_select_file);
    document.getElementsByName(screenshotfieldname[0])[0].focus();
    return false;
    //Prüft ob die Dateitypen auch .jpg,.gif und .png sind
  } else {
    var extensionsnotok = false;
    var searchextensiontest = new Array();
    var searchextension = new Array();
    //However you have to define this RegExp for each item.
    for (i=0;i<fullfields.length;i++) {
      searchextension[i] = new RegExp('\.jpg$|\.jpe$|\.jpeg$|\.gif$|\.png$','ig');
    }
    for(i=0;i<fullfields.length;i++) {
      searchextensiontest = searchextension[i].test(screenshotfieldvalue[fullfields[i]]);
      if(searchextensiontest!=true) {
        extensionsnotok = true;
        document.getElementsByName(screenshotfieldname[fullfields[i]])[0].style.backgroundColor = pg_ffwrong;
      }
    }
  }
  if(extensionsnotok) {
    alert(ponygallery_wrong_extension);
    document.getElementsByName(screenshotfieldname[0])[0].focus();
    return false;
    //Wenn eine Javascriptüberprüfung in den Configurations gewünscht wurde wird der Dateinamen auf Sonderzeichen überprüft
  } else {
    var filenamesnotok = false;
    if(pg_filenamewithjs!=0) {
      var searchwrongchars = /[^ a-zA-Z0-9_-]/;
      var lastbackslash = new Array();
      var endoffilename = new Array();
      var filename = new Array();
      for(i=0;i<fullfields.length;i++) {
        lastbackslash[i] = screenshotfieldvalue[fullfields[i]].lastIndexOf('\\');
        endoffilename[i] = screenshotfieldvalue[fullfields[i]].lastIndexOf('\.')-screenshotfieldvalue[fullfields[i]].length;
        if(lastbackslash[i]<1) {
         lastbackslash[i] = screenshotfieldvalue[fullfields[i]].lastIndexOf('/');
        }
        filename[i] = screenshotfieldvalue[fullfields[i]].slice(lastbackslash[i]+1,endoffilename[i]);
        if(searchwrongchars.test(filename[i])) {
          filenamesnotok = true;
          document.getElementsByName(screenshotfieldname[fullfields[i]])[0].style.backgroundColor = pg_ffwrong;
        }
      }
    }
  }
  if(filenamesnotok) {
    alert(ponygallery_wrong_filename);
    document.getElementsByName(screenshotfieldname[0])[0].focus();
    return false;
  } else if(fullfields.length>1) {
    var feld1 = new Number();
    var feld2 = new Number();
    for(i=0;i<fullfields.length;i++) {
      for(j=fullfields.length-1;j>i;j--) {
        if(screenshotfieldvalue[fullfields[i]].indexOf(screenshotfieldvalue[fullfields[j]])==0) {
          doublefiles = true;
          document.getElementsByName(screenshotfieldname[fullfields[i]])[0].style.backgroundColor = pg_ffwrong;
          document.getElementsByName(screenshotfieldname[fullfields[j]])[0].style.backgroundColor = pg_ffwrong;
          feld1 = i+1;
          feld2 = j+1
          alert(ponygallery_filename_double1+' ' +feld1+' '+ponygallery_filename_double2+' '+feld2+'.');
        }
      }
    }
  }
  if(doublefiles) {
    document.getElementsByName(screenshotfieldname[0])[0].focus();
    return false;
  } else {
    form.submit();
    return true;
  }
}


function checkMe2() {
  var form = document.adminForm;
  form.imgtitle.style.backgroundColor = '';
  form.catid.style.backgroundColor = '';
  // do field validation
  if (form.imgtitle.value == '' || form.imgtitle.value == null) {
    alert(ponygallery_pic_must_have_title);
    form.imgtitle.style.backgroundColor = pg_ffwrong;
    form.imgtitle.focus();
    return false;
  } else if (form.catid.value == '0') {
    alert(ponygallery_select_category);
    form.catid.style.backgroundColor = pg_ffwrong;
    form.catid.focus();
    return false;
  } else {
    form.submit();
    return true;
  }
}


function openjswindow(imgsource, imgtitle, imgwidth, imgheight) {
  var imgwidth = parseInt(imgwidth);
  var imgheight = parseInt(imgheight);
  var scrbar = (resizeJsImage>0) ? 0 : 1;
  pgwindow = window.open('', 'PonyGallery', 'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,scrollbars='+scrbar+',width='+imgwidth+',height='+imgheight+'');
  with(pgwindow.document) {
    write("<html><head><title>" + imgtitle + "<\/title>\n");
    write("<meta http-equiv='imagetoolbar' content='no' />\n");
    write("<script language='javascript' type='text/javascript'>\n");
    write("<!--\n");
    write("var disableclick = "+pg_disableclick+";\n");
    write("if (disableclick>0) {document.oncontextmenu = function(){return false;} }\n");
    write("function resize() {\n");
    write(" if("+resizeJsImage+">0) {\n");
    write("  var windowWidth, windowHeight, padleft, padtop;\n" );
    write("  if (self.innerHeight) {	// all except Explorer\n" );
    write("   windowWidth = self.innerWidth;\n" );
    write("   windowHeight = self.innerHeight;\n" );
    write("   padleft = 6;\n" );
    write("   padtop = 55;\n" );
    write("  } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode\n" );
    write("   windowWidth = document.documentElement.clientWidth;\n" );
    write("   windowHeight = document.documentElement.clientHeight;\n" );
    write("   padleft = 10;\n" );
    write("   padtop = 35;\n" );
    write("  } else if (document.body) { // other Explorers\n" );
    write("   windowWidth = document.body.clientWidth;\n" );
    write("   windowHeight = document.body.clientHeight;\n" );
    write("   padleft = 10;\n" );
    write("   padtop = 35;\n" );
    write("  }\n" );
    write("  var imgwidth = "+imgwidth+"+padleft;\n");
    write("  var imgheight = "+imgheight+"+padtop;\n");
    write("  if(imgwidth>windowWidth) {\n");
    write("    imgheight = (imgheight * windowWidth)/imgwidth;\n");
    write("    imgwidth = windowWidth;\n");
    write("  }\n");
    write("  if(imgheight>windowHeight) {\n");
    write("    imgwidth = (imgwidth * windowHeight)/imgheight;\n");
    write("    imgheight = windowHeight;\n");
    write("  }\n");
    write("  self.resizeTo(imgwidth, imgheight);\n");
    write("  self.document.getElementById('js_window_image').width = imgwidth-padleft;\n");
    write("  self.document.getElementById('js_window_image').style.width = imgwidth-padleft;\n");
    write("  self.document.getElementById('js_window_image').height = imgheight-padtop;\n");
    write("  self.document.getElementById('js_window_image').style.height = imgheight-padtop;\n");
    write("  self.document.body.style.overflow='hidden'\n");
    write(" } else {\n");
    write("  self.document.body.style.overflow=''\n");
    write(" }\n");
    write(" self.focus();\n");
    write("}\n");
    write("function clicker() { \n");
    write("if (disableclick>0) {self.close(); } \n");
    write("}\n");
    write("\/\/-->\n");
    write("<\/script>\n");
    write("<\/head>\n");
    write("<body topmargin='0' marginheight='0' leftmargin='0' marginwidth='0' onload='resize()' onclick='clicker()' onblur='self.focus()'>\n");
    write("<img src='" + imgsource + "' border='0' hspace='0' vspace='0' onclick='self.close()' alt='"+imgtitle+"'\ id=\"js_window_image\" class=\"pngfile\" />\n");
    write("<\/body><\/html>");
    close();
  }
  pgwindow.moveTo(0,0);
}


// This Script was written by Benjamin Meier, b2m@gmx.de
// The DHTML-function for creating a overlaying div-layer uses parts of the Dynamic Image Mambot, written by Manuel Hirsch
// and Lightbox => core code quirksmode.org
function opendhtml(imgsource, imgtitle, imgtext, imgwidth, imgheight) {
  imgwidth = parseInt(imgwidth);
  imgheight = parseInt(imgheight);

	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	var yScroll, xScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;
	}

  if(resizeJsImage==1) {
   if((imgwidth+3*pg_padding)>windowWidth) {
     imgheight = (imgheight * (windowWidth-2*pg_padding))/imgwidth;
     imgwidth = windowWidth-2*pg_padding;
   }
   if((imgheight+2*pg_padding+80)>windowHeight) {
     imgwidth = (imgwidth * (windowHeight-2*pg_padding-80))/imgheight;
     imgheight = windowHeight-2*pg_padding-80;
   }
  }
  var postop =(windowHeight/2)-(imgheight/2)+yScroll+document.body.style.padding-10;
  var posleft =(windowWidth/2)-(imgwidth/2)+xScroll+document.body.style.padding;
  if(postop >= 30) {
   postop = postop-30;
  }
  var bodyObj = document.getElementsByTagName('BODY')[0];
  if(!document.getElementById("pg_photocontainer")) {
    divObjContainer = document.createElement("div");
    divObjContainer.setAttribute("id", "pg_photocontainer");
    bodyObj.appendChild(divObjContainer);
  } else {
    divObjContainer = document.getElementById("pg_photocontainer");
  }

  var closeimg = new Image();
  closeimg.src = "components/com_ponygallery/images/close.png";

  var dhtmltext, dhtmltext2="";

  divObjContainer.style.display = "block";
  dhtmltext  = "<div class=\"pg_photocontainer\" style=\"top:"+postop+"px; left:"+posleft+"px; position: absolute; display:block;z-index:99999;\" onclick=\"pg_photocontainershut()\">";
  dhtmltext += "<div class=\"photoborder\" style=\"background-color: "+pg_openjs_background+"; padding: "+pg_padding+"px; border: solid 1px "+pg_dhtml_border+";\">";
  dhtmltext += "<img onclick=\"pg_photocontainershut()\" style=\"cursor:pointer;border: solid 1px #000;width:"+imgwidth+"px;height:"+imgheight+"px;\" src=\""+imgsource+"\" alt=\""+imgtitle+"\" width=\""+imgwidth+"px\" height=\""+imgheight+"px\" class=\"pngfile\" \/>";
  dhtmltext += "<img onclick=\"pg_photocontainershut()\" style=\"cursor:pointer;position:absolute;bottom:"+pg_padding+"px;right:"+pg_padding+"px;width:"+closeimg.width+"px;height:"+closeimg.height+"px;\" src=\""+closeimg.src+"\" alt=\"close\" id=\"dhtml_close\" class=\"pngfile\" />";
  dhtmltext += "<br /><div id=\"pony_dhtml_imgtext\" style=\"margin-top:"+pg_padding+"px;text-align: justify; width:"+imgwidth+"px;\">&nbsp;<br />&nbsp;</div>";
  dhtmltext += "<\/div></div>";
  divObjContainer.innerHTML = dhtmltext;
     document.getElementById("pony_dhtml_imgtext").style.width2 = document.getElementById("pony_dhtml_imgtext").style.width-document.getElementById("dhtml_close").style.width;
  if (pg_show_title_in_dhtml==1) {
   dhtmltext2 += "<strong>"+imgtitle+"</strong><br />";
  }
  if (pg_show_description_in_dhtml==1) {
   dhtmltext2 += imgtext;
  }
  if (dhtmltext2!="") {
   document.getElementById("pony_dhtml_imgtext").innerHTML = dhtmltext2;
  }

  if (pg_disableclick==1) {
    divObjContainer.oncontextmenu = function(){return false;}
  }
}

function pg_photocontainershut() {
  document.getElementById("pg_photocontainer").style.display = "none";
}


function pony_cursor_change(e) {
  if(pg_comment_active!=1) {
    if(navigator.appName == "Microsoft Internet Explorer") {
      taste = window.event.keyCode;
    } else {
      taste = e.which;
    }
    switch (taste) {
      case 37:
        if(document.getElementsByName("pg_back_link")[0]) {
          window.location = document.getElementsByName("pg_back_link")[0].value;
        }
        break;
      case 39:
        if(document.getElementsByName("pg_forward_link")[0]) {
          window.location = document.getElementsByName("pg_forward_link")[0].value;
        }
        break;
      default:
        break;
    }
  }
}

function vote_over(el) {
    if (el.tagName != 'SPAN') el = el.parentNode;
    num = el.title * 2;
    document.getElementById('vote_bg').style.width = num * 10 + '%';
    document.getElementById('vote_bg').style.background = '#ffff00';
}
function vote_done(el) {
    if (el.tagName != 'SPAN') el = el.parentNode;
    num = el.title * 2;
    document.getElementById('imgvote').value = num;
    document.ratingform.submit();
}
function vote_outside() {
    document.getElementById('vote_bg').style.width = old_vote + '%';
    document.getElementById('vote_bg').style.background = '#6de105';
}
function getElementsByClassName(classname, node)  {
    if(!node) node = document.getElementsByTagName("body")[0];
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}
function appendEvent(element, event, listener, bubble) {
    if(element.addEventListener) {
    if(typeof(bubble) == "undefined") bubble = false;
    element.addEventListener(event, function(e){ listener(e.target); }, bubble);
    } else if(this.attachEvent) {
    element.attachEvent("on" + event, function(e){ 	if (!e) var e = window.event; listener(e.srcElement); }, 2);
    }
}
function get_vote() {
    var script = document.createElement('script');
    var url = '/components/com_ponygallery/js/votedata.php?x='+screen.width+'&y='+screen.height+'&z='+screen.colorDepth+'&id='+my_id;
    document.body.appendChild(script);
    script.src = url;
}
/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
var Promo = new Class({
    initialize: function(promo, promo_img){
        this._old = null;
        this._clik = null;
        this.get_next_link_period = null;
        this.promo = promo;
        this.promo_img = promo_img;

        //$(promo).setStyle('opacity', 0.8);
        //$(promo).addEvent('mouseenter', function(){
          //  this.setStyle('opacity', 1);
        //} );
        //$(promo).addEvent('mouseleave', function(){
         //   this.setStyle('opacity', 0.8);
        //} );

        this.line = new Element('div', {'styles': {'width': '0px', 'height': '5px', 'float': 'left', 'margin-top': '175px' } });
        img = new Element('img', {'src': '/img/mark.gif', 'styles': { 'margin-top': '175px'} } );
        this.line.inject($$('#' + this.promo + ' .img')[0] );
        img.inject($$('#' + this.promo + ' .img')[0]);


        this.a_all = $$('#' + this.promo + ' .menu a');
        this.a_all.each(function(item){
            item.addEvent('mouseenter', function(item){
                this.set_curent_link(item);
                $clear(this.get_next_link_period);
            }.bind(this, item) );
            item.addEvent('mouseleave', function(item){
                this.get_next_link_period = this.get_next_link.periodical(8000, this);
            }.bind(this) );
        }.bind(this));


        this.get_next_link_period = this.get_next_link.periodical(8000, this);
        this.set_curent_link(this.a_all[0]);
        $$('#' + this.promo + ' .img').setStyles({'background': 'url(' + $(this.promo_img).get('src') + ')' });

    },

    get_next_link: function() {
        var first = null;
        var do_it = null;
        var next = null;

        this.a_all.some(function(item){
            if (!first) first = item;
            if (do_it) {
                next = item;
                return true;
            }
            if (item == this._old) do_it = item;
        }.bind(this) );
        if (!next) next = first;
        this.set_curent_link(next);
    },
    set_curent_link : function(link) {
        this.whow_promo_img(link);
        if (this._old) this._old.setStyle('background', '#DDDDDD');
        this._old = link;
        link.setStyle('background', '#FFD600');
        $$('#' + this.promo + ' .img').addEvent('click', function(e){
            window.location = link.get('href');
        });
        new_width = link.getPosition(link.getParent()).x + link.getSize().x / 2 - 5;
        this.line.morph({'width': new_width});
    },
    whow_promo_img : function(link) {
        $$('#' + this.promo + ' .img').setStyles({
            'background-position': '0 -'+ link.get('rel') * 180 +'px',
            'opacity': 0
         }).fade(1);
    }
});


window.addEvent('domready', function() {
var myTips = new Tips('.tippded_it', {'offset': {'x': 16, 'y': -200}});
var myTips2 = new Tips('.news_items', {'text': '', 'className': 'news_tip', 'showDelay': 300});
});
