var IsIE = !!(window.attachEvent && !window.opera);
var IsOpera = !!window.opera;
var IsMozilla = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1;
function __(href,w,h){var width=arguments.length<2?820:w;var height=arguments.length<3?590:h;window.open(href+(href.indexOf('?')<0?'?':'&')+'window=' + Math.floor(Math.random() * 0xFFFFFFFF) ,Math.floor(Math.random() * 0xFFFFFFFF).toString(),'width='+width+',height='+height+',resizable=yes,scrollbars=yes');}

// ContextMenu
var __CM = [];
function __CCM() { var iid = arguments[0]; __CM[iid] = { id: iid, actions: [], timer: null, div: null }; __FCM(iid); }
function __FCM() { var iid = arguments[0]; var a = []; for (var i = 1; i < arguments.length; i += 4) a.push({ IconSrc: arguments[i], Href: arguments[i + 1], Target: arguments[i + 2], Caption: arguments[i + 3] }); __CM[iid].actions = a; }
function __PCM(id) { var angor = $('__CMA' + id); var div = new Element('div'); div.addClassName('ContextMenu'); div.style.position = 'absolute'; div.style.top = (angor.cumulativeOffset().top + angor.getHeight()) + 'px'; div.style.left = angor.cumulativeOffset().left + 'px'; return div; }
function __SCM(id) {
    var menu = __CM[id];
    if (menu == null) return;
    if (menu.timer != null) { clearTimeout(menu.timer); menu.timer = null; }
    if (menu.div != null) return;
    var div = __PCM(id);
    var s = '';
    var a = menu.actions;
    for (var i = 0; i < a.length; i++)
        s += '<a onmouseover="__SCM(\'' + id + '\');\" onmouseout=\"__HCM(\'' + id + '\');\" href="' + a[i].Href + '" target="' + a[i].Target + '"><img src="' + a[i].IconSrc + '" align="absmiddle" /><img src="img src="res/ac3/img/spacer.gif" width="10" height="1" align="absmiddle" />' + a[i].Caption + '</a>';
    div.update(s);
    $(document.body).insert(div);
    menu.div = div;
}
function __ACM(id, url) {
    var menu = __CM[id];
    if (menu == null) { __CCM(id); menu = __CM[id]; }
    if (menu.timer != null) { clearTimeout(menu.timer); menu.timer = null; }
    if (menu.div != null) return;
    var div = __PCM(id);
    div.update('<a class="ajax" onmouseover="__ACM(\'' + id + '\',\'' + url + '\');\" onmouseout=\"__HCM(\'' + id + '\');\" href="javascript:;"><center><br/><br/><img src="res/ac3/img/Ajax.gif" /><br/><br/><br/></center></a>');
    $(document.body).insert(div);
    menu.div = div;
    new Ajax.Request(url, { method: 'GET', onSuccess: function(transport) {
        eval(transport.responseText);
        var menu = __CM[id];
        if (menu == null) return;
        if (menu.div == null) return;
        var s = '';
        var a = menu.actions;
        for (var i = 0; i < a.length; i++)
            s += '<a onmouseover="__ACM(\'' + id + '\',\'' + url + '\');\" onmouseout=\"__HCM(\'' + id + '\');\" href="' + a[i].Href + '" target="' + a[i].Target + '"><img src="' + a[i].IconSrc + '" align="absmiddle" /><img src="img src="res/ac3/img/spacer.gif" width="10" height="1" align="absmiddle" />' + a[i].Caption + '</a>';
        menu.div.update(s);
    }
    });
}

function __HCM(id) { var menu = __CM[id]; if (menu == null) return; menu.timer = setTimeout("__DHCM('" + id + "');", 100); }
function __DHCM(id) { var menu = __CM[id]; if (menu == null) return; if (menu.div != null) { menu.div.remove(); menu.div = null; } menu.timer = null; }


function __InsertScripts(s) {
   var myRegExp = new RegExp('<\s*script.*?>(.*?)<\s*/script\s*>','g');
   var scripts = s.match(myRegExp);
   if (scripts) for (var i=0; i<scripts.length; i++) {
       var scripttag = window.document.createElement('script');
       var scriptcontent = scripts[i].substring(scripts[i].indexOf('>')+1,scripts[i].lastIndexOf('<'));
       try {scripttag.appendChild(window.document.createTextNode(scriptcontent));}
       catch(e) {scripttag.text = scriptcontent;} //IE
       window.document.getElementsByTagName('head')[0].appendChild(scripttag);
   }
}

// Balloons
function CallBalloon(url){CallBalloon(url,false);}
function CallBalloon(url,calculatesize){new Ajax.Request(url,{method:'GET',evalJS:true,onSuccess:function(transport){ShowBalloon(transport.responseText,'',calculatesize);}});}
function ShowBalloon(content,description){ShowBalloon(content,description,false);}
function ShowBalloon(content,description,calculatesize){
    new Insertion.Bottom($(document.body),'<div id="BalloonContainer" style="position:absolute;top:0px;left:0px;width:'+document.body.scrollWidth+'px;height:'+document.body.scrollHeight+'px;background:#1A1A1A;" ><div>');
    new Insertion.Bottom($(document.body),'<div id="curBalloonContainer" style="position:absolute;top:0px;left:0px;display:none;"><div>');
    if(calculatesize)new Insertion.Bottom($(document.body),'<div id="curBalloonDimensions" style="position:absolute;top:0px;left:0px;display:none;"><div>');
    if(calculatesize)$('curBalloonContainer').update(''+content+'');
    $('BalloonContainer').setOpacity(0.8);
    $('BalloonContainer').style.zIndex=200;
    $('BalloonContainer').onclick=function(){RemoveBalloon();}
    var initLeft=parseInt(((document.body.clientWidth-200)/2))+'px';
    var initTop=parseInt(((document.body.clientHeight-200)/2))+'px';
    new Insertion.Bottom($(document.body),'<table id="BalloonLayer" width="300px" height="170px" cellspacing="0" cellpadding="0" border="0" style="position:absolute;top:'+initTop+';left:'+initLeft+';z-index:201;">'
     + '<tr><td width="11" height="11"><img src="res/ac3/img/Balloon_tl.gif" /></td><td width="100%" style="background:#ffffff;"></td><td width="11" height="11"><img src="res/ac3/img/Balloon_tr.gif" /></td></tr>'
     + '<tr style="background:#ffffff;" height="100%"><td></td><td class="Balloon" id="BalloonRealContainer"><div style="text-align:center;"><img id="barberpole" src="res/ac3/img/BarberPole.gif" /></div></td><td></td></tr>'
     + '<tr style="background:#ffffff;" height="30"><td></td><td><table cellspacing="0" cellpadding="0" border="0"><tr><td id="BalloonDescription" width="100%">'
     + '</td><td valign="top" style="cursor:pointer;"><img src="res/ac3/img/Balloon_close.gif"  onclick="RemoveBalloon();"></td></tr></table></td><td></td></tr>'
     + '<tr><td width="11" height="11"><img src="res/ac3/img/Balloon_bl.gif" /></td><td width="100%" style="background:#ffffff;"></td><td width="11" height="11"><img src="res/ac3/img/Balloon_br.gif" /></td></tr>'
     + '</table>');
    if(calculatesize){
        new Insertion.Bottom($('curBalloonDimensions'),$('curBalloonContainer').getWidth());
        new Insertion.Bottom($('curBalloonDimensions'),$('curBalloonContainer').getHeight());
    }
    BalloonPositionTimer=setInterval(CenterBalloon,100);
	if(calculatesize){new PeriodicalExecuter(function(pe){$('BalloonRealContainer').update('');ResizeBalloon(parseInt($('curBalloonContainer').getWidth())+22,parseInt($('curBalloonContainer').getHeight())+62,30,content,''+description+'');pe.stop();},0.3);}
	else {
	    $('BalloonRealContainer').update(content);
	    $('BalloonDescription').update(description);
        //add javascript
	    var myRegExp = new RegExp("<\s*script.*?>(.*?)<\s*/script\s*>","g");
        var scripts = content.match(myRegExp);
        if (scripts) for (var i=0; i<scripts.length; i++) {
            var scripttag = window.document.createElement("script");
            var scriptcontent = scripts[i].substring(scripts[i].indexOf('>')+1,scripts[i].lastIndexOf('<'));
            try {scripttag.appendChild(window.document.createTextNode(scriptcontent));}      
            catch(e) {scripttag.text = scriptcontent;}      
            window.document.getElementsByTagName('head')[0].appendChild(scripttag);
        }
	}
	CenterBalloon();
}
function RemoveBalloon(){
	$('BalloonRealContainer').update('');
	if($('curBalloonContainer')!=null)$('curBalloonContainer').update('');
	if($('curBalloonDimensions')!=null)$('curBalloonDimensions').remove();
	$('BalloonRealContainer').remove();
	$('BalloonContainer').remove();
	if($('curBalloonContainer')!=null)$('curBalloonContainer').remove();
	$('BalloonLayer').remove();
	clearInterval(BalloonPositionTimer);
}
function CenterBalloon(){
	try{
		$('BalloonLayer').style.left=parseInt(((document.body.clientWidth-$('BalloonLayer').getWidth())/2))+'px';
		$('BalloonLayer').style.top=parseInt(((document.body.clientHeight-$('BalloonLayer').getHeight())/2)+document.body.scrollTop)+'px';
	}catch(err){}
}
function ResizeBalloon(toWidth,toHeight,frames,content,description){

	if(toWidth>parseInt(document.body.clientWidth)){toWidth=document.body.clientWidth};
	if(toHeight>parseInt(document.body.clientHeight)){toHeight=document.body.clientHeight};
	var curwidth=parseInt($('BalloonLayer').getWidth());
	var curheight=parseInt($('BalloonLayer').getHeight());
	var defWidth = ((Math.abs(parseInt(toWidth))-Math.abs(parseInt(curwidth))));
	var defHeight = ((Math.abs(parseInt(toHeight))-Math.abs(parseInt(curheight))));
	var dw = defWidth / frames;
	var dh = defHeight / frames;
	for (i = 0; i < frames-1; i++)setTimeout("DoResizeBalloon("+(curwidth+i*dw)+","+(curheight+i*dh)+");", (i+1)*10); 
	new PeriodicalExecuter(function(pe) {DoResizeBalloon(toWidth,toHeight);pe.stop();},frames*0.01);
	new PeriodicalExecuter(function(pe) {
	    $('BalloonRealContainer').update(content);
	    $('BalloonDescription').update(description);
        //add javascript
	    var myRegExp = new RegExp("<\s*script.*?>(.*?)<\s*/script\s*>","g");
        var scripts = content.match(myRegExp);
        if (scripts) for (var i=0; i<scripts.length; i++) {
            var scripttag = window.document.createElement("script");
            var scriptcontent = scripts[i].substring(scripts[i].indexOf('>')+1,scripts[i].lastIndexOf('<'));
            try {scripttag.appendChild(window.document.createTextNode(scriptcontent));}      
            catch(e) {scripttag.text = scriptcontent;}      
            window.document.getElementsByTagName('head')[0].appendChild(scripttag);
        }
	    pe.stop();
	},frames*0.01+0.3);
}
function DoResizeBalloon(toWidth,toHeight){$('BalloonLayer').style.width=toWidth+'px';$('BalloonLayer').style.height=toHeight+'px';CenterBalloon();}
function ChangeBalloonContent(content,description){
    $('curBalloonContainer').update(''+content+'');
    $('BalloonDescription').update('');
    $('BalloonRealContainer').update('<div style="text-align:center;"><img id="barberpole" src="res/ac3/img/BarberPole.gif" /></div>');
    new Insertion.Bottom($('curBalloonDimensions'),$('curBalloonContainer').getWidth());
    new Insertion.Bottom($('curBalloonDimensions'),$('curBalloonContainer').getHeight());
    BalloonPositionTimer=setInterval(CenterBalloon,100);
	new PeriodicalExecuter(function(pe){$('BalloonRealContainer').update('');ResizeBalloon(parseInt($('curBalloonContainer').getWidth())+22,parseInt($('curBalloonContainer').getHeight())+62,30,''+content+'',''+description+'');pe.stop();},0.3);
	CenterBalloon();
}

//Ajax wait control
function ShowAjaxUpdateControl(){new Insertion.Bottom($(document.body),'<div id="AjaxUpdateDiv" style="position:absolute;top:'+parseInt(((document.body.clientHeight-200)/2))+'px;left:'+parseInt(((document.body.clientWidth-200)/2))+'px;width:200px;height:100px;"><div style="position:relative;"><img src="res/ac3/img/AjaxUpdateBalloon.gif"><img src="res/ac3/img/AjaxUpdateCircle.gif" style="position:absolute;left:85px;top:15px;"></div><div>');$('AjaxUpdateDiv').setOpacity(0.9);$('AjaxUpdateDiv').style.zIndex=210;$('AjaxUpdateDiv').style.left=parseInt(((document.body.clientWidth-$('AjaxUpdateDiv').getWidth())/2))+'px';$('AjaxUpdateDiv').style.top=parseInt(((document.body.clientHeight-$('AjaxUpdateDiv').getHeight())/2)+document.body.scrollTop)+'px';}
function HideAjaxUpdateControl(){$('AjaxUpdateDiv').remove();}

//Tooltip control call from BalloonTooltipControl :Look active/controls/generic
function showTooltip(obj,txt){


if(Object.isElement($('balloon_tooltip_'+obj.id))!=true){var tooltip='';
new Insertion.Bottom($(document.body),'<div id="tooltip_tempcontainer_'+obj.id+'" style="position:absolute;top:0px;left:0px;display:none;"></div>');
$('tooltip_tempcontainer_'+obj.id).update(txt);var tempWidth=$('tooltip_tempcontainer_'+obj.id).getWidth();
if(parseInt(document.body.clientWidth/2)>parseInt(obj.cumulativeOffset().left+obj.getWidth())){		
tooltip='<table id="balloon_tooltip_'+obj.id+'"   border="0" cellspacing="0" cellpadding="0" style="position:absolute;top:'+(obj.cumulativeOffset().top-25)+'px;left:'+(obj.cumulativeOffset().left+obj.getWidth())+'px;">'+
'<tr><td >&nbsp;</td><td align="right" valign="top"><img src="res/ac3/img/tooltip_top_left.gif"></td>'+
'<td  height="16" style="background-color:#FFFFFF;border-top:1px solid #979797;"><img src="res/ac3/img/spacer.gif"></td>'+
'<td><img src="res/ac3/img/tooltip_top_right.gif"></td></tr>'+
'<tr><td valign="top"><table border="0" cellspacing="0" cellpadding="0" height="100%"><tr><td align="right"><img src="res/ac3/img/tooltip_arrow_left.gif" ></td></tr>'+
'<tr><td align="right" id="tooltip_left_side_'+obj.id+'" style="border-right:1px solid #979797;" height="100%"><img src="res/ac3/img/spacer.gif" height="100%"></td></tr></table>'+
'</td><td width="16" style="background-color:#FFFFFF;"><img src="res/ac3/img/spacer.gif" width="16"></td>'+
'<td id="tooltip_container_'+obj.id+'" style="background-color:#FFFFFF;" valign="top" >'+
'</td><td width="16" height="100%" style="background-color:#FFFFFF;border-right:1px solid #979797;"><img src="res/ac3/img/spacer.gif"></td></tr>'+
'<tr><td>&nbsp;</td><td align="right"><img src="res/ac3/img/tooltip_bottom_left.gif"></td>'+
'<td  height="16" style="background-color:#FFFFFF;border-bottom:1px solid #979797;"><img src="res/ac3/img/spacer.gif"></td>'+
'<td><img src="res/ac3/img/tooltip_bottom_right.gif"></td></tr></table>';
}else{
tooltip='<table id="balloon_tooltip_'+obj.id+'"   border="0" cellspacing="0" cellpadding="0" style="position:absolute;top:'+(obj.cumulativeOffset().top-25)+'px;left:'+(obj.cumulativeOffset().left-tempWidth-62)+'px;">'+
'<tr><td align="right" valign="top"><img src="res/ac3/img/tooltip_top_left.gif"></td>'+
'<td  height="16" style="background-color:#FFFFFF;border-top:1px solid #979797;"><img src="res/ac3/img/spacer.gif"></td>'+
'<td><img src="res/ac3/img/tooltip_top_right.gif"></td><td >&nbsp;</td></tr>'+
'<tr><td width="16" style="background-color:#FFFFFF;border-left:1px solid #979797;"><img src="res/ac3/img/spacer.gif" width="16"></td>'+
'<td id="tooltip_container_'+obj.id+'" style="background-color:#FFFFFF;" valign="top"></td><td width="16" height="100%" style="background-color:#FFFFFF;">'+
'<img src="res/ac3/img/spacer.gif"></td><td valign="top"><table border="0" cellspacing="0" cellpadding="0" height="100%"><tr><td align="left"><img src="res/ac3/img/tooltip_arrow_right.gif" ></td></tr><tr><td align="left" id="tooltip_left_side_'+obj.id+'" style="border-left:1px solid #979797;" height="100%"><img src="res/ac3/img/spacer.gif" height="100%"></td></tr></table></td></tr>'+
'<tr><td align="right"><img src="res/ac3/img/tooltip_bottom_left.gif"></td>'+
'<td  height="16" style="background-color:#FFFFFF;border-bottom:1px solid #979797;"><img src="res/ac3/img/spacer.gif"></td>'+
'<td><img src="res/ac3/img/tooltip_bottom_right.gif"></td><td>&nbsp;</td></tr></table>';
}
new Insertion.Bottom($(document.body),tooltip);
$('balloon_tooltip_'+obj.id).setOpacity(0.95);
$('balloon_tooltip_'+obj.id).style.zIndex=300;
$('tooltip_container_'+obj.id).update(txt);
//new Insertion.Bottom($('tooltip_container_'+obj.id),txt);
$('tooltip_left_side_'+obj.id).style.height=$('tooltip_container_'+obj.id).getHeight()-18;}
$('tooltip_tempcontainer_'+obj.id).remove();
}function hideTooltip(obj){$('balloon_tooltip_'+obj.id).remove();}



//IMAGE GALERY
//usage: <div id="test"></div>
//var box;
//var images=[];
//document.observe("dom:loaded", function() { 
//images[0]={src:'skn/scirocco/scirocco1_B.jpg',description:'Scirocco',name:'Scirocco 1.6 140ps'};
//images[1]={src:'skn/obt_v2_05.jpg',description:'obt asdasd asd asd sad sad sa dsadg ajhsd jhgj sahd<br/>sadsad sada ssad',name:'Obt logo'};
//images[2]={src:'skn/scirocco/scirocco3.jpg',description:'image3',name:'Im3'};
//images[3]={src:'skn/map_greece.gif',description:'Map of Greece',name:'Map'};
//images[4]={src:'skn/scirocco/scirocco2_B.jpg',description:'image2',name:'Im2'};
//images[5]={src:'skn/scirocco/scirocco3_B.jpg',description:'image4',name:'Im4'};
//images[6]={src:'skn/scirocco/scirocco4_B.jpg',description:'image5',name:'Im5'};
//images[7]={src:'skn/scirocco/scirocco5.jpg',description:'image6',name:'Im6'};
//images[8]={src:'skn/scirocco/scirocco5_B.jpg',description:'image7',name:'Im7'};
//box = new protoLightBox("test",images,0,{opacity:0.9});
//box.show();

 var protoLightBox = Class.create({
  initialize: function(name,images,index,options) {
	this.name = name;
	this.images=images;
	this.index=index;
	if(this.index==null)this.index=0;
		this.options = Object.extend({
		opacity : 0.6
	}, options || {});
  },
  show : function(){
	this.show(0);
  },
  show: function(imgindex) {
	if(this.images.length==0)return;
	if(imgindex==null)this.index=0;
	else {
	    if(imgindex>=this.images.length)this.index=0;
	    else this.index=imgindex;
    }

	var newImg=new Element('img');
	newImg.src=this.images[this.index].src;
	var imgsrc=newImg.src;
	var newHeight=0;
	var newWidth=0;
	var newLeft=0;
	var newTop=0;
	var Dwidth=(window.innerWidth?window.innerWidth:document.body.clientWidth);
    var Dheight=(window.innerHeight?window.innerHeight:document.body.clientHeight);
	
	var footer='<div id="protoLightBoxFooter'+this.name+'" style="overlow:hidden;"><table cellpadding="0" id="protoLightBoxFooterTable'+this.name+'" cellspacing="0"  border="0" ><tr>';  
	footer+='<td width="100%" align="left" valign="top" style="padding:5px;">';
	footer+=(this.images[this.index].name!=null?('<b style="font:bold 12px/14px Tahoma;" id="protoLightBoxName'+this.name+'"  class="protoLightBoxName" >'+this.images[this.index].name+'</b><br/>'):'');
	footer+=(this.images[this.index].description!=null?('<b style="font:normal 12px/14px Tahoma;" id="protoLightBoxDescription'+this.name+'" class="protoLightBoxDescription">'+this.images[this.index].description+'</b>'):'');
	footer+='</td>';
	footer+='<td valign="bottom" ><img src="res/ac3/img/spacer.gif" width="2" height="1"/></td>';
	footer+='<td valign="bottom" nowrap="nowrap" style="font:normal 12px/14px Tahoma;padding:3px;"><img onmouseout="this.src=\'res/ac3/img/protolightbox_previous.gif\'" onmouseover="this.src=\'res/ac3/img/protolightbox_previous_over.gif\'" src="res/ac3/img/protolightbox_previous.gif" id="protoLightBoxPrevius'+this.name+'" style="cursor:pointer" align=\"absmiddle\" /></td>';
	footer+='<td valign="bottom" nowrap="nowrap" style="font:normal 12px/14px Tahoma;padding:3px;" id="protoLightBoxLegent'+this.name+'"  class="protoLightBoxLegent"><b id="protoLightBoxIndex'+this.name+'"  >'+(this.index+1)+'</b> / <b>'+this.images.length+'</b></td>';
	footer+='<td valign="bottom" nowrap="nowrap" style="font:normal 12px/14px Tahoma;padding:3px;"><img onmouseout="this.src=\'res/ac3/img/protolightbox_next.gif\'" onmouseover="this.src=\'res/ac3/img/protolightbox_next_over.gif\'" src="res/ac3/img/protolightbox_next.gif"  id="protoLightBoxNext'+this.name+'" style="cursor:pointer;"  align=\"absmiddle\" /></td>';
	footer+='</tr></table></div>';
		
	new Insertion.Bottom($(document.body),'<div id="protoLightBoxLayer'+this.name+'" style="position:absolute;top:0px;left:0px;background:#1A1A1A;" ><div>');
    $('protoLightBoxLayer'+this.name+'').style.width=Dwidth+'px';
	$('protoLightBoxLayer'+this.name+'').style.height=document.body.scrollHeight+'px'; //$(document.body).getHeight()+'px';

	
	new Insertion.Bottom($(document.body),'<div id="protoLightBox'+this.name+'" style="display:none;position:absolute;top:0px;left:0px;background:#ffffff;">'
										 +'<table bgcolor="#ffffff" cellspacing="0" border="0" ><tr>'
										 +'<td valign="middle" style="position:relative;"><img id="protoLightBoxClose'+this.name+'" src="res/ac3/img/protolightbox_close.gif" style="cursor:pointer;position:absolute;right:0;border-top:1px solid #ffffff;border-right:1px solid #ffffff;">'
										 +'<img id="protoLightBoxWait'+this.name+'" src="res/ac3/img/protolightbox_wait.gif" style="cursor:pointer;position:absolute;display:none;">'
										 +'<div id="protoLightBoxContainer'+this.name+'"><img src="'+imgsrc+'" ></div>'+footer+''
										 +'</td></tr>'
										 +'</table></div>');
	    										 
	$('protoLightBoxLayer'+this.name+'').setOpacity(this.options.opacity);
    $('protoLightBoxLayer'+this.name+'').style.zIndex=200;
    $('protoLightBox'+this.name+'').style.zIndex=201;
    
	if(newImg.width==0 || newImg.height==0){
    	newImg.onload = function(){
			newWidth=newImg.width;
			newHeight=newImg.height; 
			$('protoLightBoxClose'+this.name+'').style.left=(newWidth-20)+'px';    
			newLeft=parseInt(((Dwidth-newWidth)/2)+document.body.scrollLeft);
 			newTop=parseInt(((Dheight-newHeight)/2));//+document.body.scrollTop)
 			$('protoLightBoxWait'+this.name+'').style.left=parseInt((newWidth-32)/2)+'px';
			$('protoLightBoxWait'+this.name+'').style.top=parseInt((newHeight-32)/2)+'px';
 			$('protoLightBoxNext'+this.name+'').style.display=((this.index==(this.images.length-1)||(this.images.length==1))?'none':'block');
			$('protoLightBoxPrevius'+this.name+'').style.display=((this.index==0)||(this.images.length==1)?'none':'block');
			if(this.images.length==1)$('protoLightBoxLegent'+this.name+'').style.display='none';
			$('protoLightBox'+this.name+'').morph('height:'+newHeight+'px;width:'+newWidth+'px;top:'+newTop+'px;left:'+newLeft+'px;');
			$('protoLightBox'+this.name+'').style.top=newTop+'px';
			$('protoLightBox'+this.name+'').style.left=newLeft+'px';
			
			
			new PeriodicalExecuter(function(pe) {Effect.Appear('protoLightBox'+this.name+'', { duration: 1 });pe.stop();}.bind(this), 0.5);	
		}.bind(this);
	}
	else{
			newWidth=newImg.width;
			newHeight=newImg.height; 
			$('protoLightBoxClose'+this.name+'').style.left=(newWidth-20)+'px';
            newLeft=parseInt(((Dwidth-newWidth)/2)+document.body.scrollLeft);
 			newTop=parseInt(((Dheight-newHeight)/2));//+document.body.scrollTop)
 			$('protoLightBoxWait'+this.name+'').style.left=parseInt((newWidth-32)/2)+'px';
			$('protoLightBoxWait'+this.name+'').style.top=parseInt((newHeight-32)/2)+'px';
			$('protoLightBoxNext'+this.name+'').style.display=((this.index==(this.images.length-1)||(this.images.length==1))?'none':'block');
			$('protoLightBoxPrevius'+this.name+'').style.display=((this.index==0)||(this.images.length==1)?'none':'block');
			if(this.images.length==1)$('protoLightBoxLegent'+this.name+'').style.display='none';
			$('protoLightBox'+this.name+'').morph('height:'+newHeight+'px;width:'+newWidth+'px;top:'+newTop+'px;left:'+newLeft+'px;');
			$('protoLightBox'+this.name+'').style.top=newTop+'px';
			$('protoLightBox'+this.name+'').style.left=newLeft+'px';
			new PeriodicalExecuter(function(pe) {Effect.Appear('protoLightBox'+this.name+'', { duration: 1 });pe.stop();}.bind(this), 0.5);	
	}
	this.addObserver();

  },
  addObserver : function(){
		Event.observe('protoLightBoxLayer' + this.name + '', 'click', this.hide.bind(this))
		Event.observe('protoLightBoxClose' + this.name + '', 'click', this.hide.bind(this))
		Event.observe('protoLightBoxNext' + this.name + '', 'click', this.gonext.bind(this))
		Event.observe('protoLightBoxPrevius' + this.name + '', 'click', this.goprevius.bind(this))
  },
  hide : function(){
	Effect.Fade('protoLightBox'+this.name+'', { duration: 1.0 });
	new PeriodicalExecuter(function(pe) {
		$('protoLightBox'+this.name+'').remove();
		$('protoLightBoxLayer'+this.name+'').remove();
	pe.stop();}.bind(this), 1);
  },
  gonext : function(){
	  if(this.index==this.images.length-1)return;
	  var imgindex=this.index+1;
	  this.goto(imgindex);
  },
  goprevius : function(){
	if(this.index==0)return;
	var imgindex=this.index-1;
	this.goto(imgindex);
  },
  goto : function(imgindex){
	if(this.images[imgindex]==null)return;
	var newImg=new Element('img');
	newImg.src=this.images[imgindex].src;  
	
	var newHeight=0;
	var newWidth=0;
	var newLeft=0;
	var newTop=0;

	if(newImg.width==0 || newImg.height==0){
		newImg.onload = function(){
			
			
			Effect.BlindUp('protoLightBoxFooter'+this.name+'', { duration:0.3 });
			Effect.Fade('protoLightBoxFooter'+this.name+'', { duration:0.2 });
			$('protoLightBoxClose'+this.name+'').style.display='none';
			newWidth=newImg.width;
			newHeight=newImg.height; 
			$('protoLightBoxClose'+this.name+'').style.left=(newWidth-20)+'px';
			new PeriodicalExecuter(function(pe) { $('protoLightBoxContainer'+this.name+'').style.display='none';$('protoLightBoxWait'+this.name+'').style.display='block';pe.stop();}.bind(this), 0.5);
			newLeft=parseInt(((document.body.clientWidth-newWidth)/2));
 			newTop=parseInt(((document.body.clientHeight-newHeight)/2)+document.body.scrollTop);
			//--------------------------- Dont touch---------------------------------------------------------
 			new PeriodicalExecuter(function(pe) { $('protoLightBox'+this.name+'').morph('height:'+newHeight+'px;width:'+newWidth+'px;top:'+newTop+'px;left:'+newLeft+'px;');pe.stop();}.bind(this), 1.2);
			new PeriodicalExecuter(function(pe) { $('protoLightBoxWait'+this.name+'').morph('display:block;top:'+parseInt((newHeight-32)/2)+'px;left:'+parseInt((newWidth-32)/2)+'px;');pe.stop();}.bind(this), 1.2);
			new PeriodicalExecuter(function(pe) { 
				$('protoLightBoxContainer'+this.name+'').update('<img src="'+this.images[imgindex].src+'">');  
				$('protoLightBoxWait'+this.name+'').style.display='none';
				Effect.Appear('protoLightBoxContainer'+this.name+'', { duration: 0.3 });
				new PeriodicalExecuter(function(pe) { 
					$('protoLightBoxNext'+this.name+'').style.display=((imgindex==(this.images.length-1)||(this.images.length==1))?'none':'block');
					$('protoLightBoxPrevius'+this.name+'').style.display=((imgindex==0)||(this.images.length==1)?'none':'block');
					if(this.images.length==1)$('protoLightBoxLegent'+this.name+'').style.display='none';
					$('protoLightBoxIndex'+this.name+'').update(''+(imgindex+1));
					$('protoLightBoxName'+this.name+'').update(''+this.images[imgindex].name);
					$('protoLightBoxDescription'+this.name+'').update(''+this.images[imgindex].description);
					Effect.toggle('protoLightBoxFooter'+this.name+'', 'slide', { delay: 0.1,duration: 0.3 });
					new PeriodicalExecuter(function(pe) { $('protoLightBoxClose'+this.name+'').style.display='block';pe.stop();}.bind(this), 0.4);	
				pe.stop();}.bind(this), 0.6);	
			pe.stop();}.bind(this), 2.2);	
			
			
			this.index =imgindex;
			newImg.remove();
		}.bind(this);
	}
	else{
			Effect.BlindUp('protoLightBoxFooter'+this.name+'', { duration:0.3 });
			Effect.Fade('protoLightBoxFooter'+this.name+'', { duration:0.2 });
			$('protoLightBoxClose'+this.name+'').style.display='none';
			newWidth=newImg.width;
			newHeight=newImg.height; 
			$('protoLightBoxClose'+this.name+'').style.left=(newWidth-20)+'px';
			new PeriodicalExecuter(function(pe) { $('protoLightBoxContainer'+this.name+'').style.display='none';$('protoLightBoxWait'+this.name+'').style.display='block';pe.stop();}.bind(this), 0.5);	
			newLeft=parseInt(((document.body.clientWidth-newWidth)/2));
 			newTop=parseInt(((document.body.clientHeight-newHeight)/2)+document.body.scrollTop);
			//--------------------------- Dont touch---------------------------------------------------------
 			new PeriodicalExecuter(function(pe) { $('protoLightBox'+this.name+'').morph('height:'+newHeight+'px;width:'+newWidth+'px;top:'+newTop+'px;left:'+newLeft+'px;');pe.stop();}.bind(this), 1.2);
			new PeriodicalExecuter(function(pe) { $('protoLightBoxWait'+this.name+'').morph('top:'+parseInt((newHeight-32)/2)+'px;left:'+parseInt((newWidth-32)/2)+'px;');pe.stop();}.bind(this), 1.2);
 			new PeriodicalExecuter(function(pe) { 
				$('protoLightBoxContainer'+this.name+'').update('<img src="'+this.images[imgindex].src+'">');  
				$('protoLightBoxWait'+this.name+'').style.display='none';
				Effect.Appear('protoLightBoxContainer'+this.name+'', { duration: 0.3 });
				new PeriodicalExecuter(function(pe) { 
					$('protoLightBoxNext'+this.name+'').style.display=((imgindex==(this.images.length-1)||(this.images.length==1))?'none':'block');
					$('protoLightBoxPrevius'+this.name+'').style.display=((imgindex==0)||(this.images.length==1)?'none':'block');
					if(this.images.length==1)$('protoLightBoxLegent'+this.name+'').style.display='none';
					$('protoLightBoxIndex'+this.name+'').update(''+(imgindex+1));
					$('protoLightBoxName'+this.name+'').update(''+this.images[imgindex].name);
					$('protoLightBoxDescription'+this.name+'').update(''+this.images[imgindex].description);
					Effect.toggle('protoLightBoxFooter'+this.name+'', 'slide', { delay: 0.1,duration: 0.3 });
					new PeriodicalExecuter(function(pe) { $('protoLightBoxClose'+this.name+'').style.display='block';pe.stop();}.bind(this), 0.4);	
				pe.stop();}.bind(this), 0.6);	
			pe.stop();}.bind(this), 2.2);	
			this.index =imgindex;
			newImg.remove();
	}
  }
 });



//Displays video in popup window
function ShowPopup(idpopup,width,height,title,content,description){
	var newHeight=height;
	var newWidth=width;
			
	var Dwidth=(window.innerWidth?window.innerWidth:document.body.clientWidth);
    var Dheight=(window.innerHeight?window.innerHeight:document.body.clientHeight);
	var newLeft=parseInt(((Dwidth-newWidth)/2)+document.body.scrollLeft);
 	var newTop=parseInt(((Dheight-newHeight)/2));
				
	new Insertion.Bottom($(document.body),'<div id="protoLightBoxLayer'+idpopup+'" style="position:absolute;top:0px;left:0px;background:#1A1A1A;" onclick="$(\'protoLightBox'+idpopup+'\').remove();$(\'protoLightBoxLayer'+idpopup+'\').remove();"><div>');
    $('protoLightBoxLayer'+idpopup+'').style.width=Dwidth+'px';
	$('protoLightBoxLayer'+idpopup+'').style.height=(document.body.scrollHeight)+'px'; 

	new Insertion.Bottom($(document.body),'<div id="protoLightBox'+idpopup+'" class="PopupWindow" style="display:none;position:absolute;top:0px;left:0px;background:#ffffff;" class="PopupWindow">'
										 +'<img id="protoLightBoxClose'+idpopup+'" src="res/ac3/img/protolightbox_close.gif" style="cursor:pointer;position:absolute;right:0;border-top:1px solid #ffffff;border-right:1px solid #ffffff;" onclick="$(\'protoLightBox'+idpopup+'\').remove();$(\'protoLightBoxLayer'+idpopup+'\').remove();">'
										 +'<table bgcolor="#ffffff" cellspacing="3" border="0">'
										 +'<tr><td style="font-weight:bold;" id="protoLightBoxTitle'+idpopup+'" class="PopupWindowTitle">'
										 +'</td><tr>'
										 +'<tr><td align="center" valign="top" >'
										 +'<img id="protoLightBoxWait'+idpopup+'" src="res/ac3/img/protolightbox_wait.gif" style="cursor:pointer;position:absolute;display:none;">'
										 +'<div id="protoLightBoxContainer'+idpopup+'"></div>'
										 +'</td></tr>'
										 +'<tr><td id="protoLightBoxDescription'+idpopup+'" class="PopupWindowDescription"></td><tr>'
										 +'</table></div>');
	    										 
	$('protoLightBoxLayer'+idpopup+'').setOpacity(0.7);
    $('protoLightBoxLayer'+idpopup+'').style.zIndex=200;
    $('protoLightBox'+idpopup+'').style.zIndex=201;
	$('protoLightBoxWait'+idpopup+'').style.left=parseInt((newWidth-32)/2)+'px';
	$('protoLightBoxWait'+idpopup+'').style.top=parseInt((newHeight-32)/2)+'px';
	$('protoLightBoxClose'+idpopup+'').style.left=(newWidth-20)+'px';    
	$('protoLightBox'+idpopup+'').morph('height:'+newHeight+'px;width:'+newWidth+'px;top:'+newTop+'px;left:'+newLeft+'px;');
	$('protoLightBox'+idpopup+'').style.top=newTop+'px';
	$('protoLightBox'+idpopup+'').style.left=newLeft+'px';
	
	new PeriodicalExecuter(function(pe) {Effect.Appear('protoLightBox'+idpopup+'', { duration: 1 });pe.stop();}, 0.5);	
	new PeriodicalExecuter(function(pe) {
		$('protoLightBoxContainer'+idpopup+'').update(content);
		$('protoLightBoxTitle'+idpopup+'').update(title);
		$('protoLightBoxDescription'+idpopup+'').update(description);
		pe.stop();
	}, 0.6);	
    $(document.body).scrollTo();

}

