var previousCount, shouldReLoad;
window.onload = function() {
	setTimeout('timeTick()', 1000);
	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);
	
	if ((version >= 5.5) && (document.body.filters)) 
	{
	   for(var i=0; i<document.images.length - 1; i++)
	   {
		  var img = document.images[i];
		  var imgName = img.src.toUpperCase();
		  if (imgName.indexOf('.PNG') > 0)
		  {
			 var imgID = (img.id) ? "id='" + img.id + "' " : "";
			 var imgClass = (img.className) ? "class='" + img.className + "' " : "";
			 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
			 var imgStyle = "display:inline-block;" + img.style.cssText;
			 if (img.align == "left") imgStyle = "float:left;" + imgStyle;
			 if (img.align == "right") imgStyle = "float:right;" + imgStyle;
			 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
			 var strNewHTML = "<span " + imgID + imgClass + imgTitle
			 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
			 img.outerHTML = strNewHTML;
			 i = i-1;
		  }
	   }
	}
}

/* SWFObject v2.1 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();


previousCount = 0;

var xmlhttp=false;
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  xmlhttp = new XMLHttpRequest();
}

function checkCount(newscount){
	if (newscount != "error")
	{
		if ((newscount > previousCount) && (previousCount > 0)){
		shownewspopup();
		}
		if (newscount >= previousCount)
		previousCount = newscount;
	}
}

function ref(object)
{
	if (document.getElementById)
	{
		return document.getElementById(object);
	}
	else if (document.all)
	{
		return eval('document.all.' + object);
	}
	else
	{
		return false;
	}
}

function expand(object)
{
	object = ref(object);
	
	if( !object.style )
	{
		return false;
	}
	else
	{
		object.style.display = '';
	}

	if (window.event)
	{
		window.event.cancelBubble = true;
	}
}

function hidenewspopup()
{
	object = ref("newspopupholder");
	
	if( !object.style )
	{
		return false;
	}
	else
	{
		object.style.display = 'none';
	}

	if (window.event)
	{
		window.event.cancelBubble = true;
	}
}

function contract(object)
{
	object = ref(object);
	if( !object.style )
	{
		return false;
	}
	else
	{
		object.style.display = 'none';
	}
	if (window.event)
	{
		window.event.cancelBubble = true;
	}
}

function toggle(object, path)
{
	image = ref(object + '_img');
	object = ref(object);
	if( !object.style )
	{
		return false;
	}
	
	if( object.style.display == 'none' )
	{
		object.style.display = '';
		image.src = path + 'contract.gif';
	}
	else
	{
		object.style.display = 'none';
		image.src = path + 'expand.gif';
	}
}

function login_toggle(object)
{
	object = ref(object);
	if( !object.style )
	{
		return false;
	}
	
	if( object.style.display == 'none' )
	{
		object.style.display = '';
	}
	else
	{
		object.style.display = 'none';
	}
}

function expand1(listID)
{
        if (listID.style.display=="none")
        {
                listID.style.display="";
        }
        else
        {
                listID.style.display="none";
        }
        window.event.cancelBubble=true;
}

function contract1(listID)
{
        if (listID.style.display=="show")
        {
                listID.style.display="";
        }
        else
        {
                listID.style.display="none";
        }
        window.event.cancelBubble=true;
}

function toggle_imenik()
{
	object_fizicka = ref('imenik_fizicka');
	object_pravna = ref('imenik_pravna');
	
	if( !object_fizicka.style || !object_pravna.style )
	{
		return false;
	}
	
	if( object_fizicka.style.display == 'none' )
	{
		object_fizicka.style.display = '';
	}
	else
	{
		object_fizicka.style.display = 'none';
	}
	
	
	if( object_pravna.style.display == 'none' )
	{
		object_pravna.style.display = '';
	}
	else
	{
		object_pravna.style.display = 'none';
	}
}

function toggle_search()
{
	object_search_type = ref('search_type');
	object_album = ref('search_album');
	object_forums = ref('search_forums');
	
	if( !object_forums.style || !object_album.style )
	{
		return false;
	}
	
	if( object_forums.style.display == 'none' )
	{
		object_forums.style.display = '';
		object_search_type.value='forums';
	}
	else
	{
		object_forums.style.display = 'none';
		object_search_type.value='album';
	}
	
	
	if( object_album.style.display == 'none' )
	{
		object_album.style.display = '';
		object_search_type.value='album';
	}
	else
	{
		object_album.style.display = 'none';
		object_search_type.value='forums';
	}
}

function oglas_edit(id, cat)
{
	document.getElementById('Tel').value = document.getElementById('tel_' + id).innerHTML;
	document.getElementById('Oglas').value = document.getElementById('oglas_' + id).innerHTML;
	document.getElementById('Kategorija').value = cat;
	document.getElementById('Oglas_edit').value = 1;
	document.getElementById('Oglas_edit_id').value = id;
}

function loadCount() {
	try
	{
		url = "countnews.php?pageID=" + pageID + "&RandomKey=" + Math.random() * Date.parse(new Date());
		xmlhttp.open("GET", url, true);
 		xmlhttp.onreadystatechange=function()
 		{
 			try
 			{
	  			if ((xmlhttp.readyState==4) && (xmlhttp.responseText > 0))
	  			{
	   			checkCount(xmlhttp.responseText);
	  			}
	  			else
	  			{
	  			return "error";
	  			}
	  		}
	  		catch(e)
	  		{
				if (previousCount == 'undefined')
				{
					var previousCount;
					previousCount = 0;
				}
			}
 		}
 	xmlhttp.send(null)
	}
	catch(e)
	{
		previousCount = 0;
		shouldReLoad = 1;
	}
}

function timeTick(){
	loadCount();
	setTimeout('timeTick()', 20000);
}

function shownewspopup()
{
try
	{
		xmlhttp.open("GET", "countnews.php?text=1", true);
 		xmlhttp.onreadystatechange=function()
 		{
 			try
 			{
	  			if ((xmlhttp.responseText.length > 0))
	  			{
					//insert div
					document.getElementById("newspopupholder").innerHTML = xmlhttp.responseText;
	  			}
	  			else
	  			{
	  				return "error";
	  			}
	  		}
	  		catch(e)
	  		{
	  				return "error";
			}
 		}
 	xmlhttp.send(null)
	}
	catch(e)
	{
		 shownewspopup();
	}
}

function key(e) {
	e = (e)?e:window.event;
	return ((e.which)? e.which : e.keyCode);
}    

var biracki_spisak_timer = 0;

function biracki_spisak()
{
	stop_checking = false;
	document.getElementById("biracki_spisak").innerHTML = '<img src="images/loading_s.gif" alt="" style="margin-top: 5px;" />';
	document.getElementById("biracki_spisak").style.height = '28px';
	document.getElementById("biracki_spisak_query").style.display = 'none';
	document.getElementById("biracki_spisak").style.display = '';
	clearTimeout(biracki_spisak_timer);
	biracki_spisak_timer = setTimeout('biracki_spisak();', 10000);
try
	{
		xmlhttp.open("GET", "ajax.php?mode=biracki_spisak&jmbg=" + document.getElementById("jmbg").value, true);
 		xmlhttp.onreadystatechange=function()
 		{
 			try
 			{
	  			if (xmlhttp.responseText.length > 0)
	  			{
	  				if(xmlhttp.responseText == '0')
	  				{
		  				document.getElementById("biracki_spisak").innerHTML = '<span style="color: #be1616;">Niste upisani u birački spisak u Somboru!</span><br />To ne isključuje mogućnost da ste upisani u birački spisak neke druge opštine. Ukoliko smatrate da treba da budete upisani u birački spisak opštine Sombor, obratite se nadležnoj službi na adresi Trg Cara Uroša 1 (Županija), u kancelariji 213 ili na telefon 025/468-148';
		  				document.getElementById("biracki_spisak").style.height = 'auto';
		  				document.getElementById("biracki_spisak").style.display = '';
		  				clearTimeout(biracki_spisak_timer);
		  				biracki_spisak_timer = setTimeout('document.getElementById("biracki_spisak").style.display = "none"; document.getElementById("biracki_spisak_query").style.display = "";', 25000);
	  				}
		  			else if(xmlhttp.responseText == '-1')
		  			{
		  				document.getElementById("biracki_spisak").innerHTML = '<span style="color: #be1616;">Greška.</span><br />Pokušajte ponovo kasnije.';
		  				document.getElementById("biracki_spisak").style.height = 'auto';
		  				document.getElementById("biracki_spisak").style.display = '';
		  				clearTimeout(biracki_spisak_timer);
		  				biracki_spisak_timer = setTimeout('document.getElementById("biracki_spisak").style.display = "none"; document.getElementById("biracki_spisak_query").style.display = "";', 5000);
		  			}
	  				else
	  				{
		  				document.getElementById("biracki_spisak").innerHTML = '<span style="color: #19c507;">Ako je Vaše ime ' + xmlhttp.responseText + ', upisani ste u birački spisak</span>';
		  				document.getElementById("biracki_spisak").style.height = 'auto';
		  				document.getElementById("biracki_spisak").style.display = '';
		  				clearTimeout(biracki_spisak_timer);
		  				biracki_spisak_timer = setTimeout('document.getElementById("biracki_spisak").style.display = "none"; document.getElementById("biracki_spisak_query").style.display = "";', 10000);
		  			}
	  			}
	  		}
	  		catch(e)
	  		{
	  				return "error";
			}
 		}
 	xmlhttp.send(null)
	}
	catch(e)
	{
			biracki_spisak();
	}
}

function hide(obj)
{
    document.getElementById(obj).style.display="none";
}

function setToggleCookie(name, value, path, domain, secure) 
{
    var expires = new Date();
    var base = new Date(0);
    var skew = base.getTime();
    if ( skew > 0 )
        expires.setTime(expires.getTime()-skew);
    expires.setTime(expires.getTime() + 365 * 24 * 60 * 60 * 1000);
    var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
    document.cookie = curCookie;
}

function getToggleCookie(name) 
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) 
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } 
    else
        begin += 2;
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
        end = dc.length;
    return unescape(dc.substring(begin + prefix.length, end));
}

function toggleForums(object)
{ 
	var visi = 0;
    var iconId = 't' + object;
    
    if(document.getElementById(object).style.display == 'none')
    {
    	icon = '<img src="images/arrow.gif" />';
    	document.getElementById(object).style.display='';
    }
	else
	{
    	icon = '<img src="images/arrow_down.gif" />';
		document.getElementById(object).style.display='none';
	}
	setToggleCookie(object,visi);
	document.getElementById(iconId).innerHTML=icon;
}

function loadAll(count)
{
    for ( i = 1; i <= count; i++ )
    {
        var cId = 'cat' + i;
        var exp = getToggleCookie(cId);
        if ( exp == 1 )
    	   showForums(cId);
		else hideAll(cId);
    }
}


function expandAll(count)
{
    for ( i = 1; i <= count; i++ )
    {
    	showForums('cat' + i);
    }
}

function showForums(object)
{
    var icon = '<img src="images/arrow.gif" />';
    var iconId = 't' + object;
    document.getElementById(object).style.display='';
	document.getElementById(iconId).innerHTML=icon;
}

function collapseAll(count)
{
    for ( i = 1; i <= count; i++ )
    {
    	hideAll('cat' + i);
    }
}

function hideAll(object)
{
    var icon = '<img src="images/arrow_down.gif" />';
    var iconId = 't' + object;
    document.getElementById(object).style.display='none';
	document.getElementById(iconId).innerHTML=icon;
}

//prototype

//  Lightview 2.3 - 18-06-2008
//  Copyright (c) 2008 Nick Stakenburg (http://www.nickstakenburg.com)
//
//  Licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License
//  http://creativecommons.org/licenses/by-nc-nd/3.0/

//  More information on this project:
//  http://www.nickstakenburg.com/projects/lightview/

var Lightview = {
  Version: '2.3',

  // Configuration
  options: {
    backgroundColor: '#ffffff',                            // Background color of the view
    border: 12,                                            // Size of the border
    buttons: {
      opacity: {                                           // Opacity of inner buttons
        disabled: 0.4,
        normal: 0.75,
        hover: 1
      },
      side: { display: true },                             // show side buttons
      innerPreviousNext: { display: true },                // show the inner previous and next button
      slideshow: { display: true }                         // show slideshow button
    },
    cyclic: true,                                         // Makes galleries cyclic, no end/begin.
    images: 'images/lightview/',                        // The directory of the images, relative to this file or an absolute url
    imgNumberTemplate: '#{position} / #{total}',    // Want a different language? change it here
    keyboard: { enabled: true },                           // Enabled the keyboard buttons
    overlay: {                                             // Overlay
      background: '#000',                                  // Background color, Mac Firefox & Safari use overlay.png
      close: true,                                         // Overlay click closes the view
      opacity: 0.85,
      display: true
    },
    preloadHover: true,                                    // Preload images on mouseover
    preloadSurroundingImages: true,                                    // Preload images on mouseover
    radius: 12,                                            // Corner radius of the border
    removeTitles: true,                                    // Set to false if you want to keep title attributes intact
    resizeDuration: 0.7,                                   // When effects are used, the duration of resizing in seconds
    slideshowDelay: 5,                                     // Seconds to wait before showing the next slide in slideshow
    titleSplit: '::',                                      // The characters you want to split title with
    transition: function(pos) {                            // Or your own transition
      return ((pos/=0.5) < 1 ? 0.5 * Math.pow(pos, 4) :
        -0.5 * ((pos-=2) * Math.pow(pos,3) - 2));
    },
    viewport: true,                                        // Stay within the viewport, true is recommended
    zIndex: 5000,                                          // zIndex of #lightview, #overlay is this -1

    // Optional
    closeDimensions: {                                     // If you've changed the close button you can change these
      large: { width: 85, height: 22 },                    // not required but it speeds things up.
      small: { width: 32, height: 22 },
      innertop: { width: 22, height: 22 },
      topclose: { width: 22, height: 18 }                  // when topclose option is used
    },
    defaultOptions : {                                     // Default open dimensions for each type
      image:  { topclose: true },
      ajax:   { width: 400, height: 300, topclose: true },
      iframe: { width: 400, height: 300, scrolling: true, topclose: true },
      inline: { width: 400, height: 300, topclose: true },
      flash:  { width: 400, height: 300, topclose: true },
      quicktime: { width: 480, height: 220, autoplay: true, controls: true, topclose: true },
      audio: { width: 480, height: 20, autoplay: true, controls: true, topclose: true }
    },
    sideDimensions: { width: 16, height: 22 }              // see closeDimensions
  },

  classids: {
    quicktime: 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
    flash: 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',
    audio: 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
  },
  codebases: {
    quicktime: 'http://www.apple.com/qtactivex/qtplugin.cab#version=7,3,0,0',
    flash: 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0',
    audio: 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0'
  },
  errors: {
    requiresPlugin: "<div class='message'>The content your are attempting to view requires the <span class='type'>#{type}</span> plugin.</div><div class='pluginspage'><p>Please download and install the required plugin from:</p><a href='#{pluginspage}' target='_blank'>#{pluginspage}</a></div>"
  },
  mimetypes: {
    quicktime: 'video/quicktime',
    flash: 'application/x-shockwave-flash',
    audio: 'application/x-shockwave-flash'
  },
  pluginspages: {
    quicktime: 'http://www.apple.com/quicktime/download',
    flash: 'http://www.adobe.com/go/getflashplayer',
    audio: 'http://www.adobe.com/go/getflashplayer'
  },
  // used with auto detection
  typeExtensions: {
    flash: 'swf',
    image: 'bmp gif jpeg jpg png',
    iframe: 'asp aspx cgi cfm htm html jsp php pl php3 php4 php5 phtml rb rhtml shtml txt',
    audio: 'mp3 wav',
    quicktime: 'avi mov mpg mpeg movie'
  }
};

Lightview.IEVersion=(function(B){var A=new RegExp("MSIE ([\\d.]+)").exec(B);
return A?parseFloat(A[1]):-1})(navigator.userAgent);
Object.extend(Prototype.Browser,{IE6:Prototype.Browser.IE&&(Lightview.IEVersion>=6&&Lightview.IEVersion<7),WebKit419:(Prototype.Browser.WebKit&&!document.evaluate)});
Object.extend(Lightview,{REQUIRED_Prototype:"1.6.0.2",REQUIRED_Scriptaculous:"1.8.1",queue:{position:"end",scope:"lightview"},isMac:!!navigator.userAgent.match(/mac/i),pngOverlay:!!navigator.userAgent.match(/mac/i)&&(Prototype.Browser.WebKit||Prototype.Browser.Gecko),require:function(A){if((typeof window[A]=="undefined")||(this.convertVersionString(window[A].Version)<this.convertVersionString(this["REQUIRED_"+A]))){throw("Lightview requires "+A+" >= "+this["REQUIRED_"+A]);
}},convertVersionString:function(A){var B=A.replace(/_.*|\./g,"");
B=parseInt(B+"0".times(4-B.length));
return A.indexOf("_")>-1?B-1:B},load:function(){this.require("Prototype");
if(!!window.Effect&&!window.Scriptaculous){this.require("Scriptaculous")}if(this.options.images.include("://")){this.images=this.options.images}else{var A=/lightview(?:-[\w\d.]+)?\.js(.*)/;
this.images=(($$("head script[src]").find(function(B){return B.src.match(A)})||{}).src||"").replace(A,"")+this.options.images}if(Prototype.Browser.IE&&!document.namespaces.v){document.namespaces.add("v","urn:schemas-microsoft-com:vml");
document.observe("dom:loaded",function(){document.createStyleSheet().addRule("v\\:*","behavior: url(#default#VML);")})}},start:function(){this.radius=this.options.radius;
this.border=(this.radius>this.options.border)?this.radius:this.options.border;
this.closeDimensions=this.options.closeDimensions;
this.sideDimensions=this.options.sideDimensions;
this.build();
this.updateViews();
this.addObservers();
this._lightviewLoadedEvent()}});
Object.extend(Lightview,{_lightviewLoadedEvents:15,_lightviewLoadedEvent:function(){var A=arguments.callee;
A.counter++;
if(A.counter==this._lightviewLoadedEvents){$(document.body).fire("lightview:loaded")}}});
Lightview._lightviewLoadedEvent.counter=0;
Object.extend(Lightview,{build:function(){this.lightview=new Element("div",{id:"lightview"});
var B,I,D=this.pixelClone(this.sideDimensions);
if(Prototype.Browser.WebKit419){this.lightview.hide=function(){this.setStyle("left:-9500px;top:-9500px;visibility:hidden;");
return this};
this.lightview.show=function(){this.setStyle("visibility:visible");
return this};
this.lightview.visible = function() {
    return (this.getStyle("visibility") == "visible" && parseFloat(this.getStyle("top").replace("px", "")) > -9500)
}
}
$(document.body).insert(this.overlay = new Element("div", {
    id: "overlay"
}).setStyle({
    zIndex: this.options.zIndex - 1,
    position: (!(Prototype.Browser.Gecko || Prototype.Browser.IE6)) ? "fixed": "absolute",
    background: this.pngOverlay ? "url(" + this.images + "overlay.png) top left repeat": this.options.overlay.background
}).setOpacity((Prototype.Browser.Gecko) ? 1 : this.options.overlay.opacity).hide()).insert(this.lightview.setStyle({
    zIndex: this.options.zIndex,
    top: "-9500px",
    left: "-9500px"
}).setOpacity(0).insert(this.container = new Element("div", {
    className: "lv_Container"
}).insert(this.sideButtons = new Element("ul", {
    className: "lv_Sides"
}).insert(this.prevSide = new Element("li", {
    className: "lv_PrevSide"
}).setStyle(I = Object.extend({
    marginLeft: -1 * this.sideDimensions.width + "px"
},
D)).insert(this.prevButtonImage = new Element("div", {
    className: "lv_Wrapper"
}).setStyle(Object.extend({
    marginLeft: this.sideDimensions.width + "px"
},
D)).insert(new Element("div", {
    className: "lv_Button"
})))).insert(this.nextSide = new Element("li", {
    className: "lv_NextSide"
}).setStyle(Object.extend({
    marginRight: -1 * this.sideDimensions.width + "px"
},
D)).insert(this.nextButtonImage = new Element("div", {
    className: "lv_Wrapper"
}).setStyle(I).insert(new Element("div", {
    className: "lv_Button"
}))))).insert(this.topButtons = new Element("div", {
    className: "lv_topButtons"
}).insert(this.topcloseButtonImage = new Element("div", {
    className: "lv_Wrapper lv_topcloseButtonImage"
}).insert(this.topcloseButton = new Element("div", {
    className: "lv_Button"
})))).insert(new Element("ul", {
    className: "lv_Frames"
}).insert(new Element("li", {
    className: "lv_Frame lv_FrameTop"
}).insert(B = new Element("div", {
    className: "lv_Liquid"
}).setStyle({
    height: this.border + "px"
}).insert(new Element("ul", {
    className: "lv_Half lv_HalfLeft"
}).insert(new Element("li", {
    className: "lv_CornerWrapper"
}).insert(new Element("div", {
    className: "lv_Corner"
})).insert(new Element("div", {
    className: "lv_Fill"
}).setStyle({
    left: this.border + "px"
})))).insert(new Element("div", {
    className: "lv_Filler"
})).insert(new Element("ul", {
    className: "lv_Half lv_HalfRight"
}).insert(new Element("li", {
    className: "lv_CornerWrapper"
}).setStyle("margin-top: " + ( - 1 * this.border) + "px").insert(new Element("div", {
    className: "lv_Corner"
})).insert(new Element("div", {
    className: "lv_Fill"
}).setStyle("left: " + ( - 1 * this.border) + "px")))))).insert(this.resizeCenter = new Element("li", {
    className: "lv_Center"
}).setStyle("height: " + (150 - this.border) + "px").insert(new Element("div", {
    className: "lv_WrapUp"
}).insert(new Element("div", {
    className: "lv_WrapDown"
}).setStyle("margin-top: " + this.border + "px").insert(this.center = new Element("div", {
    className: "lv_WrapCenter"
}).setOpacity(0).setStyle("padding: 0 " + this.border + "px").insert(this.media = new Element("div", {
    className: "lv_Media lv_Fill"
})).insert(this.menubar = new Element("div", {
    className: "lv_MenuBar"
}).insert(this.closeButton = new Element("div", {
    className: "lv_Button lv_Close"
}).setStyle(this.pixelClone(this.options.closeDimensions.large)).setStyle({
    background: this.options.backgroundColor
}).setOpacity(this.options.buttons.opacity.normal)).insert(this.downloadButton = new Element("a", {
    className: "lv_Button lv_Download"
}).setStyle(this.pixelClone(this.options.closeDimensions.large)).setStyle({
    background: this.options.backgroundColor
}).setOpacity(this.options.buttons.opacity.normal)).insert(this.data = new Element("ul", {
    className: "lv_Data"
}).insert(this.dataText = new Element("li", {
    className: "lv_DataText"
}).insert(this.title = new Element("div", {
    className: "lv_Title"
})).insert(this.caption = new Element("div", {
    className: "lv_Caption"
}))).insert(this.imgNumber = new Element("li", {
    className: "lv_ImgNumber"
}).insert(new Element("div"))).insert(this.innerPrevNext = new Element("li", {
    className: "lv_innerPrevNext"
}).insert(this.innerPrevButton = new Element("div", {
    className: "lv_Button"
}).setOpacity(this.options.buttons.opacity.normal).setStyle({
    backgroundColor: this.options.backgroundColor
}).setPngBackground(this.images + "inner_prev.png", {
    backgroundColor: this.options.backgroundColor
})).insert(this.innerNextButton = new Element("div", {
    className: "lv_Button"
}).setOpacity(this.options.buttons.opacity.normal).setStyle({
    backgroundColor: this.options.backgroundColor
}).setPngBackground(this.images + "inner_next.png", {
    backgroundColor: this.options.backgroundColor
}))).insert(this.slideshow = new Element("li", {
    className: "lv_Slideshow"
}).insert(this.slideshowButton = new Element("div", {
    className: "lv_Button"
}).setOpacity(this.options.buttons.opacity.normal).setStyle({
    backgroundColor: this.options.backgroundColor
}).setPngBackground(this.images + "inner_slideshow_play.png", {
    backgroundColor: this.options.backgroundColor
}))))).insert(this.external = new Element("div", {
    className: "lv_External"
}))))).insert(this.loading = new Element("div", {
    className: "lv_Loading"
}).insert(this.loadingButton = new Element("div", {
    className: "lv_Button"
}).setStyle("background: url(" + this.images + "loading.gif) top left no-repeat")))).insert(new Element("li", {
    className: "lv_Frame lv_FrameBottom"
}).insert(B.cloneNode(true))).insert(this.prevnext = new Element("li", {
    className: "lv_PrevNext"
}).hide().setStyle("margin-top: " + this.border + "px; background: url(" + this.images + "blank.gif) top left repeat"))))).insert(new Element("div", {
    id: "lightviewError"
}).hide());
var H=new Image();
H.onload=function(){H.onload=Prototype.emptyFunction;
this.sideDimensions={width:H.width,height:H.height};
var K=this.pixelClone(this.sideDimensions),C;
this.downloadButton.setPngBackground(this.images+"download.png",{backgroundColor:this.options.backgroundColor});
this.downloadButton.setStyle({display: "block", float: "right", width: 34 + "px", height: 22 + "px"});
this.downloadButton.title = ("Download");
this.sideButtons.setStyle({marginTop:0-(H.height/2).round()+"px",height:H.height+"px"});
this.prevSide.setStyle(C=Object.extend({marginLeft:-1*this.sideDimensions.width+"px"},K));
this.prevButtonImage.setStyle(Object.extend({marginLeft:K.width},K));
this.nextSide.setStyle(Object.extend({marginRight:-1*this.sideDimensions.width+"px"},K));
this.nextButtonImage.setStyle(C);
this._lightviewLoadedEvent()}.bind(this);
H.src=this.images+"prev.png";
$w("center title caption imgNumber").each(function(C){this[C].setStyle({backgroundColor:this.options.backgroundColor})}.bind(this));
var G=this.container.select(".lv_Corner");
$w("tl tr bl br").each(function(K,C){if(this.radius>0){this.createCorner(G[C],K)}else{G[C].insert(new Element("div",{className:"lv_Fill"}))}G[C].setStyle({width:this.border+"px",height:this.border+"px"}).addClassName("lv_Corner"+K.capitalize());
this._lightviewLoadedEvent()}.bind(this));
this.lightview.select(".lv_Filler",".lv_Fill",".lv_WrapDown").invoke("setStyle",{backgroundColor:this.options.backgroundColor});
var E={};
$w("prev next topclose").each(function(K){this[K+"ButtonImage"].side=K;
var C=this.images+K+".png";
if(K=="topclose"){E[K]=new Image();
E[K].onload=function(){E[K].onload=Prototype.emptyFunction;
this.closeDimensions[K]={width:E[K].width,height:E[K].height};
var L=this.isMac?"left":"right",M=Object.extend({"float":L,marginTop:this.closeDimensions[K].height+"px"},this.pixelClone(this.closeDimensions[K]));
M["padding"+L.capitalize()]=this.border+"px";
this[K+"ButtonImage"].setStyle(M);
this.topButtons.setStyle({height:E[K].height+"px",top:-1*this.closeDimensions[K].height+"px"});
this[K+"ButtonImage"].down().setPngBackground(C).setStyle(this.pixelClone(this.closeDimensions[K]));
this._lightviewLoadedEvent()}.bind(this);
E[K].src=this.images+K+".png"}else{this[K+"ButtonImage"].setPngBackground(C)}}.bind(this));
var A={};
$w("large small innertop").each(function(C){A[C]=new Image();
A[C].onload=function(){A[C].onload=Prototype.emptyFunction;
this.closeDimensions[C]={width:A[C].width,height:A[C].height};
this._lightviewLoadedEvent()}.bind(this);
A[C].src=this.images+"close_"+C+".png"}.bind(this));
var J=new Image();
J.onload=function(){J.onload=Prototype.emptyFunction;
this.loading.setStyle({width:J.width+"px",height:J.height+"px",marginTop:-0.5*J.height+0.5*this.border+"px",marginLeft:-0.5*J.width+"px"});
this._lightviewLoadedEvent()}.bind(this);
J.src=this.images+"loading.gif";
var F=new Image();
F.onload=function(C){F.onload=Prototype.emptyFunction;
var K={width:F.width+"px",height:F.height+"px"};
this.slideshow.setStyle(K);
this.slideshowButton.setStyle(K);
this._lightviewLoadedEvent()}.bind(this);
F.src=this.images+"inner_slideshow_stop.png";
$w("prev next").each(function(L){var K=L.capitalize(),C=new Image();
C.onload=function(){C.onload=Prototype.emptyFunction;
this["inner"+K+"Button"].setStyle({width:C.width+"px",height:C.height+"px"});
this._lightviewLoadedEvent()}.bind(this);
C.src=this.images+"inner_"+L+".png";
this["inner"+K+"Button"].prevnext=L}.bind(this));
this._lightviewLoadedEvent()},prepare:function(){Effect.Queues.get("lightview").each(function(A){A.cancel()});
this.scaledInnerDimensions=null;
this.restoreInlineContent();
this.views=null},restoreInlineContent:function(){if(!this.inlineContent||!this.inlineMarker){return}this.inlineMarker.insert({after:this.inlineContent.setStyle({display:this.inlineContent._inlineDisplayRestore})});
this.inlineMarker.remove();
this.inlineMarker=null},show:function(B){this.element=null;
if(Object.isElement(B)||Object.isString(B)){this.element=$(B);
if(!this.element){return}this.element.blur();
this.view=this.element._view}else{if(B.href){this.element=$(document.body);
this.view=new Lightview.View(B)}else{if(Object.isNumber(B)){this.element=this.getSet(this.view.rel).elements[B];
this.view=this.element._view}}}if(!this.view.href){return}this.prepare();
this.disableKeyboardNavigation();
this.hideOverlapping();
this.hideContent();
this.restoreCenter();
this.appear();
if(this.view.href!="#lightviewError"&&Object.keys(Lightview.Plugin).join(" ").indexOf(this.view.type)>=0){if(!Lightview.Plugin[this.view.type]){$("lightviewError").update(new Template(this.errors.requiresPlugin).evaluate({type:this.view.type.capitalize(),pluginspage:this.pluginspages[this.view.type]}));
var C=$("lightviewError").getDimensions();
this.show({href:"#lightviewError",title:this.view.type.capitalize()+" plugin required",options:C});
return false}}if(this.view.isGallery()){this.views=this.view.isGallery()?this.getViews(this.view.rel):[this.view]}var A=Object.extend({menubar:true,topclose:false,wmode:"transparent",innerPreviousNext:this.view.isGallery()&&this.options.buttons.innerPreviousNext.display,slideshow:this.view.isGallery()&&this.options.buttons.slideshow.display},this.options.defaultOptions[this.view.type]||{});
this.view.options=Object.extend(A,this.view.options);
if(!(this.view.title||this.view.caption||(this.views&&this.views.length>1))&&this.view.options.topclose){this.view.options.menubar=false}if(this.view.isImage()){if(this.view.isGallery()){this.position=this.views.indexOf(this.view);
this.preloadSurroundingImages()}this.innerDimensions=this.view.preloadedDimensions;
if(this.innerDimensions){this.afterEffect()}else{this.startLoading();
var D=new Image();
D.onload=function(){D.onload=Prototype.emptyFunction;
this.stopLoading();
this.innerDimensions={width:D.width,height:D.height};
this.afterEffect()}.bind(this);
D.src=this.view.href}}else{this.innerDimensions=this.view.options.fullscreen?document.viewport.getDimensions():{width:this.view.options.width,height:this.view.options.height};
this.afterEffect()}},insertContent:function(){var D=this.detectExtension(this.view.href),A=this.scaledInnerDimensions||this.innerDimensions;
if(this.view.isImage()){var B=this.pixelClone(A);
this.downloadButton.href = this.view.href.replace(/images\/foto\//, "images/foto/download/");
this.downloadButton.target = '_blank';
this.media.setStyle(B).update(new Element("img",{id:"lightviewContent",src:this.view.href,alt:"",galleryimg:"no"}).setStyle(B))}else{if(this.view.isExternal()){if(this.scaledInnerDimensions&&this.view.options.fullscreen){A.height-=this.menuBarDimensions.height}switch(this.view.type){

case"ajax":var F=Object.clone(this.view.options.ajax)||{};
var E=function(){this.stopLoading();
if(this.view.options.autosize){this.external.setStyle({width:"auto",height:"auto"});
this.innerDimensions=this.getHiddenDimensions(this.external)}new Effect.Event({queue:this.queue,afterFinish:this.resizeWithinViewport.bind(this)})}.bind(this);
if(F.onComplete){F.onComplete=F.onComplete.wrap(function(N,M){E();
N(M)})}else{F.onComplete=E}this.startLoading();
new Ajax.Updater(this.external,this.view.href,F);
break;

case"iframe":this.external.update(this.iframe=new Element("iframe",{frameBorder:0,hspace:0,src:this.view.href,id:"lightviewContent",name:"lightviewContent_"+(Math.random()*99999).round(),scrolling:(this.view.options&&this.view.options.scrolling)?"auto":"no"}).setStyle(Object.extend({border:0,margin:0,padding:0},this.pixelClone(A))));
break;

case"inline":var C=this.view.href,H=$(C.substr(C.indexOf("#")+1));
if(!H||!H.tagName){return}var L=new Element(this.view.options.wrapperTag||"div"),G=H.getStyle("visibility"),J=H.getStyle("display");
H.wrap(L);
H.setStyle({visibility:"hidden"}).show();
var I=this.getHiddenDimensions(L);
H.setStyle({visibility:G,display:J});
L.insert({before:H}).remove();
H.insert({before:this.inlineMarker=new Element(H.tagName)});
H._inlineDisplayRestore=H.getStyle("display");
this.inlineContent=H.show();
this.external.update(this.inlineContent);
this.external.select("select, object, embed").each(function(M){this.overlappingRestore.each(function(N){if(N.element==M){M.setStyle({visibility:N.visibility})}})}.bind(this));
if(this.view.options.autosize){this.innerDimensions=I;
new Effect.Event({queue:this.queue,afterFinish:this.resizeWithinViewport.bind(this)})}break
}}else{var K={tag:"object",id:"lightviewContent",width:A.width,height:A.height};
switch(this.view.type){

case"quicktime":Object.extend(K,{pluginspage:this.pluginspages[this.view.type],children:[{tag:"param",name:"autoplay",value:this.view.options.autoplay},{tag:"param",name:"scale",value:"tofit"},{tag:"param",name:"controller",value:this.view.options.controls},{tag:"param",name:"enablejavascript",value:true},{tag:"param",name:"src",value:this.view.href},{tag:"param",name:"loop",value:this.view.options.loop||false}]});
Object.extend(K,Prototype.Browser.IE?{codebase:this.codebases[this.view.type],classid:this.classids[this.view.type]}:{data:this.view.href,type:this.mimetypes[this.view.type]});
break;

case"flash":Object.extend(K,{data:this.view.href,type:this.mimetypes[this.view.type],quality:"high",wmode:this.view.options.wmode,pluginspage:this.pluginspages[this.view.type],children:[{tag:"param",name:"movie",value:this.view.href},{tag:"param",name:"allowFullScreen",value:"true"}]});
if(this.view.options.flashvars){K.children.push({tag:"param",name:"FlashVars",value:this.view.options.flashvars})}
break;


case"audio":Object.extend(K,{data:'flash/streamer.swf', type:this.mimetypes[this.view.type],quality:"high",wmode:this.view.options.wmode,pluginspage:this.pluginspages[this.view.type],children:[{tag:"param",name:"file",value:this.view.href},{tag:"param",name:"allowfullscreen",value:"false"}, {tag:"param",name:"flashvars", value:"file=" + this.view.href + "&amp;bufferlength=5&amp;volume=70&amp;id=streamer_lightview&amp;fullscreen=false&amp;autostart=" + this.view.options.autoplay }]});
if(this.view.options.flashvars){K.children.push({tag:"param",name:"FlashVars",value:this.view.options.flashvars})}
this.downloadButton.href = this.view.href;
this.downloadButton.target = '_blank';
break;
}

this.media.setStyle(this.pixelClone(A)).show();
this.media.update(this.createHTML(K));
if(this.view.isQuicktime()&&$("lightviewContent")){(function(){try{if("SetControllerVisible"in $("lightviewContent")){$("lightviewContent").SetControllerVisible(this.view.options.controls)}}catch(M){}}.bind(this)).delay(0.4)}}}},getHiddenDimensions:function(B){B=$(B);
var A=B.ancestors(),C=[],E=[];
A.push(B);
A.each(function(F){if(F!=B&&F.visible()){return}C.push(F);
E.push({display:F.getStyle("display"),position:F.getStyle("position"),visibility:F.getStyle("visibility")});
F.setStyle({display:"block",position:"absolute",visibility:"visible"})});
var D={width:B.clientWidth,height:B.clientHeight};
C.each(function(G,F){G.setStyle(E[F])});
return D},clearContent:function(){var A=$("lightviewContent");
if(A){switch(A.tagName.toLowerCase()){case"object":if(Prototype.Browser.WebKit&&this.view.isQuicktime()){try{A.Stop()}catch(B){}A.innerHTML=""}if(A.parentNode){A.remove()}else{A=Prototype.emptyFunction}break;

case"iframe":A.remove();
if(Prototype.Browser.Gecko){delete window.frames.lightviewContent}break;
default:A.remove();
break}}},adjustDimensionsToView:function(){var A=this.scaledInnerDimensions||this.innerDimensions;
if(this.view.options.controls){switch(this.view.type){case"quicktime":A.height+=16;
break}}this[(this.scaledInnerDimensions?"scaledI":"i")+"nnerDimensions"]=A},afterEffect:function(){new Effect.Event({queue:this.queue,afterFinish:function(){this.afterShow()}.bind(this)})},afterShow:function(){this.fillMenuBar();
if(!this.view.isAjax()){this.stopLoading()}if(!((this.view.options.autosize&&this.view.isInline())||this.view.isAjax())){this.resizeWithinViewport()}if(!this.view.isIframe()){new Effect.Event({queue:this.queue,afterFinish:this.insertContent.bind(this)})}},finishShow:function(){new Effect.Event({queue:this.queue,afterFinish:this.showContent.bind(this)});
if(this.view.isIframe()){new Effect.Event({delay:0.2,queue:this.queue,afterFinish:this.insertContent.bind(this)})}if(this.sliding){new Effect.Event({queue:this.queue,afterFinish:this.nextSlide.bind(this)})}},previous:function(){this.show(this.getSurroundingIndexes().previous)},next:function(){this.show(this.getSurroundingIndexes().next)},resizeWithinViewport:function(){this.adjustDimensionsToView();
var B=this.getInnerDimensions(),D=this.getBounds();
if(this.options.viewport&&(B.width>D.width||B.height>D.height)){if(!this.view.options.fullscreen){var E=Object.clone(this.getOuterDimensions()),A=D,C=Object.clone(E);
if(C.width>A.width){C.height*=A.width/C.width;
C.width=A.width;
if(C.height>A.height){C.width*=A.height/C.height;
C.height=A.height}}else{if(C.height>A.height){C.width*=A.height/C.height;
C.height=A.height;
if(C.width>A.width){C.height*=A.width/C.width;
C.width=A.width}}}var F=(C.width%1>0?C.height/E.height:C.height%1>0?C.width/E.width:1);
this.scaledInnerDimensions={width:(this.innerDimensions.width*F).round(),height:(this.innerDimensions.height*F).round()};
this.fillMenuBar();
B={width:this.scaledInnerDimensions.width,height:this.scaledInnerDimensions.height+this.menuBarDimensions.height}}else{this.scaledInnerDimensions=D;
this.fillMenuBar();
B=D}}else{this.fillMenuBar();
this.scaledInnerDimensions=null}this.resize(B)},resize:function(B){var F=this.lightview.getDimensions(),I=2*this.border,D=B.width+I,M=B.height+I;
this.hidePrevNext();
var L=function(){this.restoreCenter();
this.resizing=null;
this.finishShow()};
if(F.width==D&&F.height==M){L.bind(this)();
return}var C={width:D+"px",height:M+"px"};
if(!Prototype.Browser.IE6){Object.extend(C,{marginLeft:0-D/2+"px",marginTop:0-M/2+"px"})}var G=D-F.width,K=M-F.height,J=parseInt(this.lightview.getStyle("marginLeft").replace("px","")),E=parseInt(this.lightview.getStyle("marginTop").replace("px",""));
if(!Prototype.Browser.IE6){var A=(0-D/2)-J,H=(0-M/2)-E}this.resizing=new Effect.Tween(this.lightview,0,1,{duration:this.options.resizeDuration,queue:this.queue,transition:this.options.transition,afterFinish:L.bind(this)},function(Q){var N=(F.width+Q*G).toFixed(0),P=(F.height+Q*K).toFixed(0);
if(Prototype.Browser.IE6){this.lightview.setStyle({width:(F.width+Q*G).toFixed(0)+"px",height:(F.height+Q*K).toFixed(0)+"px"});
this.resizeCenter.setStyle({height:P-1*this.border+"px"})}else{if(Prototype.Browser.IE){this.lightview.setStyle({position:"fixed",width:N+"px",height:P+"px",marginLeft:((0-N)/2).round()+"px",marginTop:((0-P)/2).round()+"px"});
this.resizeCenter.setStyle({height:P-1*this.border+"px"})}else{var O=this.getViewportDimensions(),R=document.viewport.getScrollOffsets();
this.lightview.setStyle({position:"absolute",marginLeft:0,marginTop:0,width:N+"px",height:P+"px",left:(R[0]+(O.width/2)-(N/2)).floor()+"px",top:(R[1]+(O.height/2)-(P/2)).floor()+"px"});
this.resizeCenter.setStyle({height:P-1*this.border+"px"})}}}.bind(this))},showContent:function(){new Effect.Event({queue:this.queue,afterFinish:Element.show.bind(this,this[this.view.isMedia()?"media":"external"])});
new Effect.Event({queue:this.queue,afterFinish:this.hidePrevNext.bind(this)});
new Effect.Parallel([new Effect.Opacity(this.center,{sync:true,from:0,to:1}),new Effect.Appear(this.sideButtons,{sync:true})],{queue:this.queue,duration:0.3,afterFinish:function(){if(this.element){this.element.fire("lightview:opened")}}.bind(this)});
if(this.view.isGallery()){new Effect.Event({queue:this.queue,afterFinish:this.showPrevNext.bind(this)})}},hideContent:function(){if(!this.lightview.visible()){return}new Effect.Parallel([new Effect.Opacity(this.sideButtons,{sync:true,from:1,to:0}),new Effect.Opacity(this.center,{sync:true,from:1,to:0})],{queue:this.queue,duration:0.3});
new Effect.Event({queue:this.queue,afterFinish:function(){this.clearContent();
this.media.update("").hide();
this.external.update("").hide();
this.topcloseButtonImage.setStyle({marginTop:this.closeDimensions.topclose.height+"px"})}.bind(this)})},hideData:function(){this.dataText.hide();
this.title.hide();
this.caption.hide();
this.imgNumber.hide();
this.innerPrevNext.hide();
this.slideshow.hide()},fillMenuBar:function(){this.hideData();
if(!this.view.options.menubar){this.menuBarDimensions={width:0,height:0};
this.closeButtonWidth=0;
this.menubar.hide();
return false}else{this.menubar.show()}this.menubar[(this.view.isExternal()?"add":"remove")+"ClassName"]("lv_MenuTop");
if(this.view.title||this.view.caption){this.dataText.show()}if(this.view.title){this.title.update(this.view.title).show()}if(this.view.caption){this.caption.update(this.view.caption).show()}if(this.views&&this.views.length>1){this.imgNumber.show().down().update(new Template(this.options.imgNumberTemplate).evaluate({position:this.position+1,total:this.views.length}));
if(this.view.options.slideshow){this.slideshowButton.show();
this.slideshow.show()}}if(this.view.options.innerPreviousNext&&this.views.length>1){var A={prev:(this.options.cyclic||this.position!=0),next:(this.options.cyclic||(this.view.isGallery()&&this.getSurroundingIndexes().next!=0))};
$w("prev next").each(function(B){this["inner"+B.capitalize()+"Button"].setStyle({cursor:(A[B]?"pointer":"auto")}).setOpacity(A[B]?this.options.buttons.opacity.normal:this.options.buttons.opacity.disabled)}.bind(this));
this.innerPrevNext.show()}this.setCloseButtons();
this.setMenuBarDimensions()},setCloseButtons:function(){var E=this.closeDimensions.small.width,D=this.closeDimensions.large.width,G=this.closeDimensions.innertop.width,A=this.scaledInnerDimensions?this.scaledInnerDimensions.width:this.innerDimensions.width,F=180,C=0,B=this.options.borderColor;
if(this.view.options.topclose){B=null}else{if(!this.view.isMedia()){B="innertop";
C=G}else{if(A>=F+E&&A<F+D){B="small";
C=E}else{if(A>=F+D){B="small";
C=E}}}}if(C>0){this.closeButton.setStyle({width:C+"px"}).show()}else{this.closeButton.hide()}if(B){this.closeButton.setPngBackground(this.images+"close_"+B+".png",{backgroundColor:this.options.backgroundColor})}this.closeButtonWidth=C},startLoading:function(){this.loadingEffect=new Effect.Appear(this.loading,{duration:0.3,from:0,to:1,queue:this.queue})},stopLoading:function(){if(this.loadingEffect){Effect.Queues.get("lightview").remove(this.loadingEffect)}new Effect.Fade(this.loading,{duration:0.2,queue:this.queue})},setPrevNext:function(){if(!this.view.isImage()){return}var D=(this.options.cyclic||this.position!=0),B=(this.options.cyclic||(this.view.isGallery()&&this.getSurroundingIndexes().next!=0));
this.prevButtonImage[D?"show":"hide"]();
this.nextButtonImage[B?"show":"hide"]();
var C=this.scaledInnerDimensions||this.innerDimensions;
this.prevnext.setStyle({height:C.height+"px"});
var A=((C.width/2-1)+this.border).floor();
if(D){this.prevnext.insert(this.prevButton=new Element("div",{className:"lv_Button lv_PrevButton"}).setStyle({width:A+"px"}));
this.prevButton.side="prev"}if(B){this.prevnext.insert(this.nextButton=new Element("div",{className:"lv_Button lv_NextButton"}).setStyle({width:A+"px"}));
this.nextButton.side="next"}if(D||B){this.prevnext.show()}},showPrevNext:function(){if(!this.options.buttons.side.display||!this.view.isImage()){return}this.setPrevNext();
this.prevnext.show()},hidePrevNext:function(){this.prevnext.update("").hide();
this.prevButtonImage.hide().setStyle({marginLeft:this.sideDimensions.width+"px"});
this.nextButtonImage.hide().setStyle({marginLeft:-1*this.sideDimensions.width+"px"})},appear:function(){if(this.lightview.getStyle("opacity")!=0){return}var A=function(){if(!Prototype.Browser.WebKit419){this.lightview.show()}this.lightview.setOpacity(1)}.bind(this);
if(this.options.overlay.display){new Effect.Appear(this.overlay,{duration:0.3,from:0,to:this.pngOverlay?1:this.options.overlay.opacity,queue:this.queue,beforeStart:this.maxOverlay.bind(this),afterFinish:A})}else{A()}},hide:function(){if(Prototype.Browser.IE&&this.iframe&&this.view.isIframe()){this.iframe.remove()}if(Prototype.Browser.WebKit419&&this.view.isQuicktime()){var A=$$("object#lightviewContent")[0];
if(A){try{A.Stop()}catch(B){}}}if(this.lightview.getStyle("opacity")==0){return}this.stopSlideshow();
this.prevnext.hide();
if(!Prototype.Browser.IE||!this.view.isIframe()){this.center.hide()}if(Effect.Queues.get("lightview_hide").effects.length>0){return}Effect.Queues.get("lightview").each(function(C){C.cancel()});
new Effect.Event({queue:this.queue,afterFinish:this.restoreInlineContent.bind(this)});
new Effect.Opacity(this.lightview,{duration:0.2,from:1,to:0,queue:{position:"end",scope:"lightview_hide"}});
new Effect.Fade(this.overlay,{duration:0.2,queue:{position:"end",scope:"lightview_hide"},afterFinish:this.afterHide.bind(this)})},afterHide:function(){this.lightview.hide();
this.center.setOpacity(0).show();
this.prevnext.update("").hide();
this.clearContent();
this.media.update("").hide();
this.external.update("").hide();
this.disableKeyboardNavigation();
this.showOverlapping();
if(this.element){this.element.fire("lightview:hidden")}this.element=null;
this.views=null;
this.view=null;
this.scaledInnerDimensions=null},setMenuBarDimensions:function(){var B={},A=this[(this.scaledInnerDimensions?"scaledI":"i")+"nnerDimensions"].width;
this.menubar.setStyle({width:A+"px"});
this.data.setStyle({width:A-this.closeButtonWidth-1+"px"});
B=this.getHiddenDimensions(this.menubar);
this.menubar.setStyle({width:"100%"});
this.menuBarDimensions=this.view.options.menubar?B:{width:B.width,height:0}},restoreCenter:function(){var B=this.lightview.getDimensions();
if(Prototype.Browser.IE6){this.lightview.setStyle({top:"50%",left:"50%"})}else{if(Prototype.Browser.WebKit419||Prototype.Browser.Gecko){var A=this.getViewportDimensions(),C=document.viewport.getScrollOffsets();
this.lightview.setStyle({marginLeft:0,marginTop:0,left:(C[0]+(A.width/2)-(B.width/2)).floor()+"px",top:(C[1]+(A.height/2)-(B.height/2)).floor()+"px"})}else{this.lightview.setStyle({position:"fixed",left:"50%",top:"50%",marginLeft:(0-B.width/2).round()+"px",marginTop:(0-B.height/2).round()+"px"})}}},startSlideshow:function(){this.stopSlideshow();
this.sliding=true;
this.next.bind(this).delay(0.25);
this.slideshowButton.setPngBackground(this.images+"inner_slideshow_stop.png",{backgroundColor:this.options.backgroundColor}).hide()},stopSlideshow:function(){if(this.sliding){this.sliding=false}if(this.slideTimer){clearTimeout(this.slideTimer)}this.slideshowButton.setPngBackground(this.images+"inner_slideshow_play.png",{backgroundColor:this.options.backgroundColor})},toggleSlideshow:function(){this[(this.sliding?"stop":"start")+"Slideshow"]()},nextSlide:function(){if(this.sliding){this.slideTimer=this.next.bind(this).delay(this.options.slideshowDelay)}},updateViews:function(){this.sets=[];
var A=$$("a[class~=lightview]");
A.each(function(B){B.stopObserving();
new Lightview.View(B);
B.observe("click",this.show.curry(B).wrap(function(E,D){D.stop();
E(D)}).bindAsEventListener(this));
if(B._view.isImage()){if(this.options.preloadHover){B.observe("mouseover",this.preloadImageHover.bind(this,B._view))}var C=A.partition(function(D){return D.rel==B.rel});
if(C[0].length){this.sets.push({rel:B._view.rel,elements:C[0]});
A=C[1]}}}.bind(this))},getSet:function(A){return this.sets.find(function(B){return B.rel==A})},getViews:function(A){return this.getSet(A).elements.pluck("_view")},addObservers:function(){$(document.body).observe("click",this.delegateClose.bindAsEventListener(this));
$w("mouseover mouseout").each(function(C){this.prevnext.observe(C,function(D){var E=D.findElement("div");
if(!E){return}if(this.prevButton&&this.prevButton==E||this.nextButton&&this.nextButton==E){this.toggleSideButton(D)}}.bindAsEventListener(this))}.bind(this));
this.prevnext.observe("click",function(D){var E=D.findElement("div");
if(!E){return}var C=(this.prevButton&&this.prevButton==E)?"previous":(this.nextButton&&this.nextButton==E)?"next":null;
if(C){this[C].wrap(function(G,F){this.stopSlideshow();
G(F)}).bind(this)()}}.bindAsEventListener(this));
$w("prev next").each(function(F){var E=F.capitalize(),C=function(H,G){this.stopSlideshow();
H(G)},D=function(I,H){var G=H.element().prevnext;
if((G=="prev"&&(this.options.cyclic||this.position!=0))||(G=="next"&&(this.options.cyclic||(this.view.isGallery()&&this.getSurroundingIndexes().next!=0)))){I(H)}};
this[F+"ButtonImage"].observe("mouseover",this.toggleSideButton.bindAsEventListener(this)).observe("mouseout",this.toggleSideButton.bindAsEventListener(this)).observe("click",this[F=="next"?F:"previous"].wrap(C).bindAsEventListener(this));
this["inner"+E+"Button"].observe("click",this[F=="next"?F:"previous"].wrap(D).bindAsEventListener(this)).observe("mouseover",Element.setOpacity.curry(this["inner"+E+"Button"],this.options.buttons.opacity.hover).wrap(D).bindAsEventListener(this)).observe("mouseout",Element.setOpacity.curry(this["inner"+E+"Button"],this.options.buttons.opacity.normal).wrap(D).bindAsEventListener(this))}.bind(this));
var B=[this.closeButton,this.slideshowButton, this.downloadButton];
if(!Prototype.Browser.WebKit419){B.each(function(C){C.observe("mouseover",Element.setOpacity.bind(this,C,this.options.buttons.opacity.hover)).observe("mouseout",Element.setOpacity.bind(this,C,this.options.buttons.opacity.normal))}.bind(this))}else{B.invoke("setOpacity",1)}this.slideshowButton.observe("click",this.toggleSlideshow.bindAsEventListener(this));
if(Prototype.Browser.WebKit419||Prototype.Browser.Gecko){var A=function(D,C){if(this.lightview.getStyle("top").charAt(0)=="-"){return}D(C)};
Event.observe(window,"scroll",this.restoreCenter.wrap(A).bindAsEventListener(this));
Event.observe(window,"resize",this.restoreCenter.wrap(A).bindAsEventListener(this))}if(Prototype.Browser.Gecko){Event.observe(window,"resize",this.maxOverlay.bindAsEventListener(this))}this.lightview.observe("mouseover",this.toggleTopClose.bindAsEventListener(this)).observe("mouseout",this.toggleTopClose.bindAsEventListener(this));
this.topcloseButton.observe("mouseover",this.toggleTopClose.bindAsEventListener(this)).observe("mouseout",this.toggleTopClose.bindAsEventListener(this))},toggleTopClose:function(C){var B=C.type;
if(!this.view){B="mouseout"}else{if(!(this.view&&this.view.options&&this.view.options.topclose&&(this.center.getOpacity()==1))){return}}if(this.topCloseEffect){Effect.Queues.get("lightview_topCloseEffect").remove(this.topCloseEffect)}var A={marginTop:((B=="mouseover")?0:this.closeDimensions.topclose.height)+"px"};
this.topCloseEffect=new Effect.Morph(this.topcloseButtonImage,{style:A,duration:0.2,queue:{scope:"lightview_topCloseEffect",limit:1},delay:(B=="mouseout"?0.3:0)})},getScrollDimensions:function(){var A={};
$w("width height").each(function(E){var C=E.capitalize();
var B=document.documentElement;
A[E]=Prototype.Browser.IE?[B["offset"+C],B["scroll"+C]].max():Prototype.Browser.WebKit?document.body["scroll"+C]:B["scroll"+C]});
return A},maxOverlay:function(){if(!Prototype.Browser.Gecko){return}this.overlay.setStyle(this.pixelClone(document.viewport.getDimensions()));
this.overlay.setStyle(this.pixelClone(this.getScrollDimensions()))},delegateClose:function(A){if(!this.delegateCloseElements){this.delegateCloseElements=[this.closeButton,this.topButtons,this.loadingButton,this.topcloseButton];
if(this.options.overlay.close){this.delegateCloseElements.push(this.overlay)}}if(A.target&&(this.delegateCloseElements.include(A.target))){this.hide()}},toggleSideButton:function(E){var C=E.target,B=C.side,A=this.sideDimensions.width,F=(E.type=="mouseover")?0:B=="prev"?A:-1*A,D={marginLeft:F+"px"};
if(!this.sideEffect){this.sideEffect={}}if(this.sideEffect[B]){Effect.Queues.get("lightview_side"+B).remove(this.sideEffect[B])}this.sideEffect[B]=new Effect.Morph(this[B+"ButtonImage"],{style:D,duration:0.2,queue:{scope:"lightview_side"+B,limit:1},delay:(E.type=="mouseout"?0.1:0)})},getSurroundingIndexes:function(){if(!this.views){return}var D=this.position,C=this.views.length;
var B=(D<=0)?C-1:D-1,A=(D>=C-1)?0:D+1;
return{previous:B,next:A}},createCorner:function(G,H){var F=arguments[2]||this.options,B=F.radius,E=F.border,D=new Element("canvas",{className:"cornerCanvas"+H.capitalize(),width:E+"px",height:E+"px"}),A={top:(H.charAt(0)=="t"),left:(H.charAt(1)=="l")};
if(D&&D.getContext&&D.getContext("2d")){G.insert(D);
var C=D.getContext("2d");
C.fillStyle=F.backgroundColor;
C.arc((A.left?B:E-B),(A.top?B:E-B),B,0,Math.PI*2,true);
C.fill();
C.fillRect((A.left?B:0),0,E-B,E);
C.fillRect(0,(A.top?B:0),E,E-B)}else{G.insert(new Element("div").setStyle({width:E+"px",height:E+"px",margin:0,padding:0,display:"block",position:"relative",overflow:"hidden"}).insert(new Element("v:roundrect",{fillcolor:F.backgroundColor,strokeWeight:"1px",strokeColor:F.backgroundColor,arcSize:(B/E*0.5).toFixed(2)}).setStyle({width:2*E-1+"px",height:2*E-1+"px",position:"absolute",left:(A.left?0:(-1*E))+"px",top:(A.top?0:(-1*E))+"px"})))}},hideOverlapping:function(){if(this.preventingOverlap){return}var A=$$("select","embed","object");
this.overlappingRestore=A.map(function(B){return{element:B,visibility:B.getStyle("visibility")}});
A.invoke("setStyle","visibility:hidden");
this.preventingOverlap=true},showOverlapping:function(){this.overlappingRestore.each(function(B,A){B.element.setStyle("visibility: "+B.visibility)});
delete this.overlappingRestore;
this.preventingOverlap=false},pixelClone:function(A){var B={};
Object.keys(A).each(function(C){B[C]=A[C]+"px"});
return B},getInnerDimensions:function(){return{width:this.innerDimensions.width,height:this.innerDimensions.height+this.menuBarDimensions.height}},getOuterDimensions:function(){var B=this.getInnerDimensions(),A=2*this.border;
return{width:B.width+A,height:B.height+A}},getBounds:function(){var C=20,A=2*this.sideDimensions.height+C,B=this.getViewportDimensions();
return{width:B.width-A,height:B.height-A}},getViewportDimensions:function(){var A=document.viewport.getDimensions();
if(this.controller&&this.controller.visible()){A.height-=this.controllerOffset}return A}});
Object.extend(Lightview,{enableKeyboardNavigation:function(){if(!this.options.keyboard.enabled){return}this.keyboardEvent=this.keyboardDown.bindAsEventListener(this);
document.observe("keydown",this.keyboardEvent)},disableKeyboardNavigation:function(){if(!this.options.keyboard.enabled){return}if(this.keyboardEvent){document.stopObserving("keydown",this.keyboardEvent)}},keyboardDown:function(C){var B=String.fromCharCode(C.keyCode).toLowerCase(),E=C.keyCode,F=this.view.isGallery()&&!this.resizing,A=this.view.options.slideshow,D;
if(this.view.isMedia()){C.stop();
D=(E==Event.KEY_ESC||["x","c"].member(B))?"hide":(E==37&&F&&(this.options.cyclic||this.position!=0))?"previous":(E==39&&F&&(this.options.cyclic||this.getSurroundingIndexes().next!=0))?"next":(B=="p"&&A&&this.view.isGallery())?"startSlideshow":(B=="s"&&A&&this.view.isGallery())?"stopSlideshow":null;
if(B!="s"){this.stopSlideshow()}}else{D=(E==Event.KEY_ESC)?"hide":null}if(D){this[D]()}if(F){if(E==Event.KEY_HOME&&this.views.first()!=this.view){this.show(this.views.first())}if(E==Event.KEY_END&&this.views.last()!=this.view){this.show(this.views.last())}}}});
Lightview.afterShow=Lightview.afterShow.wrap(function(B,A){this.enableKeyboardNavigation();
B(A)});
Object.extend(Lightview,{preloadSurroundingImages:function(){if(this.views.length==0){return}var A=this.getSurroundingIndexes();
this.preloadFromSet([A.next,A.previous])},preloadFromSet:function(C){var A=(this.views&&this.views.member(C)||Object.isArray(C))?this.views:C.rel?this.getViews(C.rel):null;
if(!A){return}var B=$A(Object.isNumber(C)?[C]:C.type?[A.indexOf(C)]:C).uniq();
B.each(function(F){var D=A[F],E=D.href;
if(D.preloadedDimensions||D.isPreloading||!E){return}var G=new Image();
G.onload=function(){G.onload=Prototype.emptyFunction;
D.isPreloading=null;
this.setPreloadedDimensions(D,G)}.bind(this);
G.src=E}.bind(this))},setPreloadedDimensions:function(A,B){A.preloadedDimensions={width:B.width,height:B.height}},preloadImageHover:function(A){if(A.preloadedDimensions||A.isPreloading){return}this.preloadFromSet(A)}});
Element.addMethods({setPngBackground:function(C,B){C=$(C);
var A=Object.extend({align:"top left",repeat:"no-repeat",sizingMethod:"scale",backgroundColor:""},arguments[2]||{});
C.setStyle(Prototype.Browser.IE6?{filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+B+"'', sizingMethod='"+A.sizingMethod+"')"}:{background:A.backgroundColor+" url("+B+") "+A.align+" "+A.repeat});
return C}});
Object.extend(Lightview,{detectType:function(A){var B;
$w("flash image iframe quicktime audio").each(function(C){if(new RegExp("\\.("+this.typeExtensions[C].replace(/\s+/g,"|")+")(\\?.*)?","i").test(A)){B=C}}.bind(this));
if(B){return B}if(A.startsWith("#")){return"inline"}if(document.domain&&document.domain!=(A).replace(/(^.*\/\/)|(:.*)|(\/.*)/g,"")){return"iframe"}return"image"},detectExtension:function(A){var B=A.gsub(/\?.*/,"").match(/\.([^.]{3,4})$/);
return B?B[1]:null},createHTML:function(B){var C="<"+B.tag;
for(var A in B){if(!["children","html","tag"].member(A)){C+=" "+A+'="'+B[A]+'"'}}if(new RegExp("^(?:area|base|basefont|br|col|frame|hr|img|input|link|isindex|meta|param|range|spacer|wbr)$","i").test(B.tag)){C+="/>"}else{C+=">";
if(B.children){B.children.each(function(D){C+=this.createHTML(D)}.bind(this))}if(B.html){C+=B.html}C+="</"+B.tag+">"}return C}});
(function(){document.observe("dom:loaded",function(){var B=(navigator.plugins&&navigator.plugins.length),A=function(D){var C=false;
if(B){C=($A(navigator.plugins).pluck("name").join(",").indexOf(D)>=0)}else{try{C=new ActiveXObject(D)}catch(E){}}return!!C};
window.Lightview.Plugin=(B)?{flash:A("Shockwave Flash"),quicktime:A("QuickTime")}:{flash:A("ShockwaveFlash.ShockwaveFlash"),quicktime:A("QuickTime.QuickTime")}})})();
Lightview.View=Class.create({initialize:function(b){var c=Object.isElement(b);
if(c&&!b._view){b._view=this;
if(b.title){b._view._title=b.title;
if(Lightview.options.removeTitles){b.title=""}}}this.href=c?b.getAttribute("href"):b.href;
if(this.href.indexOf("#")>=0){this.href=this.href.substr(this.href.indexOf("#"))}if(b.rel&&b.rel.startsWith("gallery")){this.type="gallery";
this.rel=b.rel}else{if(b.rel){this.type=b.rel;
this.rel=b.rel}else{this.type=Lightview.detectType(this.href);
this.rel=this.type}}$w("ajax flash gallery iframe image inline quicktime external media audio").each(function(a){var T=a.capitalize(),t=a.toLowerCase();
if("image gallery media external".indexOf(a)<0){this["is"+T]=function(){return this.type==t}.bind(this)}}.bind(this));
if(c&&b._view._title){var d=b._view._title.split(Lightview.options.titleSplit).invoke("strip");
if(d[0]){this.title=d[0]}if(d[1]){this.caption=d[1]}var e=d[2];
this.options=(e&&Object.isString(e))?eval("({"+e+"})"):{}}else{this.title=b.title;
this.caption=b.caption;
this.options=b.options||{}}if(this.options.ajaxOptions){this.options.ajax=Object.clone(this.options.ajaxOptions);
delete this.options.ajaxOptions}},isGallery:function(){return this.type.startsWith("gallery")},isImage:function(){return(this.isGallery()||this.type=="image")},isExternal:function(){return"iframe inline ajax".indexOf(this.type)>=0},isMedia:function(){return!this.isExternal()}});
Lightview.load();
document.observe("dom:loaded",Lightview.start.bind(Lightview));