var g = new Array();

//form submitter
function exxiteFormSubmit(mid)
{
	o = document.getElementById(mid);
	o.submit();
}
//layer hiddener
function shSec(id)
{
	if(!document.getElementById) return;
	var o=document.getElementById(id);
	if(o)
	{
		if(o.style.display=="block")
			o.style.display="none";
		else
			o.style.display="block";
	}
}

//show a layer
function hideL(id)
{
	if(!document.getElementById) return;
	var o=document.getElementById(id);
	o.style.display="none";
}

//hide a layer
function showL(id)
{
	if(!document.getElementById) return;
	var o=document.getElementById(id);
	o.style.display="block";
}

//popup opener
function go(wintype,w,h,command)
{
  st=new String("toolbar=no,directories=no,status=no,scrollbars=no,menubar=no,width="+w+",height="+h);
  picture=window.open(wintype+command,"picture",st);
  picture.window.focus();
}

//popup opener
function gox(wintype,w,h,command)
{
  st=new String("toolbar=yes,directories=no,status=yes,scrollbars=yes,menubar=yes,width="+w+",height="+h);
  picture=window.open(wintype+command,"picture",st);
  picture.window.focus();
}

//layer hiddener with iconchanger
function FShow(id,icono,iconc)
{
	if(!document.getElementById) return;
	var o=document.getElementById(id);
	var i=document.getElementById('b'+id);
	if(o)
	{
		if(o.style.display=="block")
		{
			o.style.display="none";
			i.src=iconc;
		}
		else
	 {
			o.style.display="block";
			i.src=icono;
	 }
	}
}

//tabcontrols
function exxiteTab(prefix,me,maxn)
{
	for(i=0; i < maxn; i++)
	{
	  o = document.getElementById(prefix+String(i));
	  o.className='tab';
	  o = document.getElementById('t'+prefix+String(i));
	  o.className='tabpanel';
	}
	o = document.getElementById(prefix+String(me));
	o.className='seltab';
	o = document.getElementById('t'+prefix+String(me));
	o.className='seltabpanel';
}

/*new gallery stuff begin*/
function getPageSize()
{
	var xScroll, yScroll;
  if(window.innerHeight && window.scrollMaxY)
  {
	  xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if(document.body.scrollHeight > document.body.offsetHeight)
	{ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
	}
	else
	{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;

	if(self.innerHeight)
	{	// all except Explorer
			if(document.documentElement.clientWidth)
			{
				windowWidth = document.documentElement.clientWidth;
			}
			else
			{
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{ // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
	}
	else if(document.body)
	{ // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
	}

		// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight)
	{
			pageHeight = windowHeight;
	}
	else
	{
			pageHeight = yScroll;
	}

		// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth)
	{
			pageWidth = xScroll;
	}
	else
	{
			pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}

  var g = new Array();

  function galleryShowVideo(video,still,w,h,mid)
  {
    var so = new SWFObject(g["path"]+"/mp.swf", mid, w, h, "8", "#000000");
    so.addParam("scale", "noscale");
    so.addParam("wmode", "opaque");
    so.addVariable("file", video);
    so.addVariable("image",still);
    so.addVariable("autostart",true);
    so.write(mid+'FlashContainer');
  }

  function galleryPreloadImg(mid,imgnum,maxn,glob)
  {
    if(glob[mid][imgnum][4]=='i')
    {
    	var cacheImage = document.createElement('img');
      cacheImage.src = glob[mid][imgnum][0];
    }
    if((imgnum-1) >= 0)
    {
    	if(glob[mid][imgnum-1][4]=='i')
    	{
    	  var cacheImage = document.createElement('img');
        cacheImage.src = glob[mid][imgnum-1][0];
      }
    }
    if((imgnum+1) < maxn)
    {
    	if(glob[mid][imgnum+1][4]=='i')
    	{
    	  var cacheImage = document.createElement('img');
        cacheImage.src = glob[mid][imgnum+1][0];
      }
    }
  }

  function galleryImageChange(mid,imgnum,glob)
  {
  	w = glob[mid][imgnum][1];
    h = glob[mid][imgnum][2];
    maxn=glob[mid].length;
    galleryPreloadImg(mid,imgnum,maxn,glob);
    c=glob[mid+'c']+1;

  	$('#'+mid+'Next').hide();
    $('#'+mid+'Prev').hide();
    $('#'+mid+'Txt').fadeTo(1,0.01);

    $('#'+mid+'Close').hide();
  	$('#'+mid+'Img').fadeOut(100, function(){

  		if(glob[mid][imgnum][4]=='i')
  		{
  		  $('#'+mid+'FlashContainer').hide();
  		  $('#'+mid+'FlashContainer').empty();
  		  $('#'+mid+'Img').attr('src',glob[mid][imgnum][0]);
  		  $('#'+mid+'Title').text(glob[mid][imgnum][3]);
        if(maxn!=1) $('#'+mid+'Count').text(maxn+"/"+c);

        hh = h+40;
        $('#'+mid+'Pop').animate({width : w,height : hh},600,function() {
        if(maxn!=1)
        {
          if(c == maxn)
          {
      	    $('#'+mid+'Prev').width(w);
            $('#'+mid+'Prev').show();
          }
          else
          {
      	    if(c == 1)
            {
        	    $('#'+mid+'Next').width(w);
      	      $('#'+mid+'Next').show();
            }
            else
            {
              $('#'+mid+'Next').width(Math.round(w/2)-2);
              $('#'+mid+'Prev').width(Math.round(w/2)-2);
              $('#'+mid+'Next').show();
              $('#'+mid+'Prev').show();
            }
          }
          $('#'+mid+'Next').height(h);
          $('#'+mid+'Prev').height(h);
        }
        else
        {
          $('#'+mid+'Img').click(function(){galleryOff(mid);});
        }
    	  $('#'+mid+'ImgContainer').width(w);
  	    $('#'+mid+'ImgContainer').height(h);
  	    $('#'+mid+'Img').fadeIn(600,function(){
            $('#'+mid+'Close').show();
            $('#'+mid+'Txt').fadeTo(1,1);
      	  });
    	  });
    	}
    	else
    	{
    		$('#'+mid+'Close').show();
        $('#'+mid+'Title').text(glob[mid][imgnum][3]);
    		hh = h+40;
    		$('#'+mid+'Pop').animate({width : w,height : hh},600,function() {
    		galleryShowVideo(glob[mid][imgnum][0],glob[mid][imgnum][4],glob[mid][imgnum][1],glob[mid][imgnum][2],mid);
    		if(maxn!=1)
        {
          if(c == maxn)
          {
      	    $('#'+mid+'Prev').width(w);
            $('#'+mid+'Prev').show();
          }
          else
          {
      	    if(c == 1)
            {
        	    $('#'+mid+'Next').width(w);
      	      $('#'+mid+'Next').show();
            }
            else
            {
              $('#'+mid+'Next').width(Math.round(w/3)-2);
              $('#'+mid+'Prev').width(Math.round(w/3)-2);
              $('#'+mid+'Next').show();
              $('#'+mid+'Prev').show();
            }
          }
          $('#'+mid+'Next').height(h-40);
          $('#'+mid+'Prev').height(h-40);
        }
    	  $('#'+mid+'ImgContainer').width(w);
  	    $('#'+mid+'ImgContainer').height(h);
        $('#'+mid+'FlashContainer').fadeIn(600,function(){
            if(maxn!=1) $('#'+mid+'Count').text(maxn+"/"+c);
            $('#'+mid+'Txt').fadeTo(1,1);
      	  });
    	  });
    	}
    });
  }

	function galleryOn(mid,imgnum,glob)
	{
		$('body').append('<div class=\"gallerycurtain\" id=\"'+mid+'Curtain\"></div><div class=\"gallerypopcontainer\" id=\"'+mid+'Container\"><div class=\"gallerypop\" id=\"'+mid+'Pop\"><div id=\"'+mid+'Close\" class=\"galleryclose\"><a href=\"javascript:galleryOff(\''+mid+'\')\" title=\"'+glob[mid+'close']+'\"><img src=\"'+glob['path']+'/close.png\"></a></div><div id=\"'+mid+'ImgContainer\" style=\"position:absolute; overflow:hidden;\"><a id=\"'+mid+'Next\" class=\"gallerynext\" href=\"javascript:galleryNext(\''+mid+'\',g);\" title=\"'+glob[mid+'next']+'\"> </a><a id=\"'+mid+'Prev\" class=\"galleryprev\" href=\"javascript:galleryPrev(\''+mid+'\',g);\" title=\"'+glob[mid+'prev']+'\"> </a></div><img id=\"'+mid+'Img\" src=\"'+glob['path']+'/t.gif\" alt=\"\"><div id=\"'+mid+'FlashContainer\"></div><div id=\"'+mid+'Txt\" class=\"gallerytxt\"><div id=\"'+mid+'Title\" class=\"gallerytitle\"> </div><div id=\"'+mid+'Count\" class=\"gallerycount\"> </div><div class=\"clear\"></div></div></div>');
	  glob[mid+'c']=imgnum;
	  s = getPageSize();
	  $('#'+mid+'Curtain').height(s[1]);
	  $('#'+mid+'Curtain').fadeTo(600,0.7,function(){$('#'+mid+'Pop').fadeIn(600,galleryImageChange(mid,imgnum,glob));});
  }

	function galleryOff(mid)
	{
		$('#'+mid+'Next').hide();
    $('#'+mid+'Prev').hide();
    $('#'+mid+'Pop').fadeOut(600,function()
    {$('#'+mid+'Curtain').fadeOut(600,function(){
    	$('#'+mid+'Img').attr('src','');
      $('#'+mid+'FlashContainer').empty();
      $('.gallerycurtain').remove();
      $('.gallerypopcontainer').remove();
     });
    });
	}

	function galleryNext(mid,glob)
	{
    var maxn = glob[mid].length-1;
    var c =  glob[mid+'c']+1;
    if(c > maxn) c=maxn; if(c < 0) c=0;
    glob[mid+'c']=c;
    galleryImageChange(mid,c,glob);
	}

	function galleryPrev(mid,glob)
	{
    var maxn = glob[mid].length;
    var c =  glob[mid+'c']-1;
    if(c > maxn) c=maxn; if(c < 0) c=0;
    glob[mid+'c']=c;
    galleryImageChange(mid,c,glob);
	}
/*new gallery stuff end*/
