var box;
window.addEvent('domready', function()
{



    
	if($('infobox'))
		$('infobox').setStyle('opacity', 0);
	else if($('infobox2'))
		$('infobox2').setStyle('opacity', 0);
		
		/*$('infobox2').morph({opacity: 0});*/
	
	
	if($('a_portfolio'))
	{
		$('a_portfolio').addEvent('mouseenter', function(){ $('infobox').morph({opacity: 1}); });
		$('content_index').addEvent('mouseleave', function(){ $('infobox').morph({opacity: 0}); });
		$('infobox').addEvent('mouseleave', function(){ $('infobox').morph({opacity: 0}); });
		
	}
	if($('info_button'))
	{
		$('info_button').addEvent('click', function()
		{ 
			$('infobox2').morph({opacity: 1}); 
		});
	}
	if($('portfolio_close'))
	{
		$('portfolio_close').addEvent('click', function(){ 
			if($('infobox'))
				$('infobox').morph({opacity: 0});
			else
				$('infobox2').morph({opacity: 0});	
		});
	}
	
	$$('a').each(function(el) {
		el.addEvent('focus', function(e) {
			this.blur();
		});
	}); 	
			
   //Empty Link Guard
   var baseURL = $(document.head).getElement('base').href;
   $each($$('a'), function(el) { if( el.href == baseURL + '#' ) { el.addEvent( 'click', function( fn ) { return false; } ); } });

   //Search Form & Input
   if( $('searchKeyword') && $('searchForm') )
   {
     var searchKeywordDefault = $('searchKeyword').value;
     $('searchKeyword').addEvent( 'focus', function( fn ) { if( this.value == searchKeywordDefault ) this.value = ''; });
     $('searchKeyword').addEvent( 'blur', function( fn ) { if( this.value == '' ) this.value = searchKeywordDefault; });
     $('searchForm').addEvent( 'submit', function( fn )
     {
        if( $('searchKeyword').value == searchKeywordDefault || $('searchKeyword').value == '' )
        {
          $('searchKeyword').style.backgroundColor = '#e8cfcc';
          $('searchKeyword').morph({backgroundColor: '#9f3a2b'});
          return false;
        }
      });
   }
   
   //Advanced Search Form & Input
   if( $('extSearchKeyword') && $('extSearchForm') )
   {


     var searchExtKeywordDefault = $('extSearchKeyword').value;
     $('extSearchKeyword').addEvent( 'focus', function( fn ) { if( this.value == searchExtKeywordDefault ) this.value = ''; });
     $('extSearchKeyword').addEvent( 'blur', function( fn ) { if( this.value == '' ) this.value = searchExtKeywordDefault; });
     $('extSearchForm').addEvent( 'submit', function( fn )
     {
        if( ( $('extSearchKeyword').get('rel') != 'noDefault' && $('extSearchKeyword').value == searchExtKeywordDefault ) || $('extSearchKeyword').value == '' )
        {
          $('extSearchKeyword').style.backgroundColor = '#e8cfcc';
          $('extSearchKeyword').morph({backgroundColor: '#9f3a2b'});
          return false;
        }
      });

     
   }


   $$('.cbox').getFirst().addEvent( 'click', function( fn )
   {

	  $$( '.category_box' ).setStyle('display','none');
	  $$( '.cbox' ).set('styles', {
          'border': '1px solid #d7d7d7',
          'background-image':'none'
        }); 
	  $$( '.cbox a' ).set('styles', {
          'color':'#4C4C50'
        }); 
	  $( this.getParent().id + '_cbox' ).set('styles', {
	       'display': 'block'
	     });

	  this.getParent().set('styles', {
		  'background-image': 'url(./template/www/img/cbox_bg.gif)',
		  'border': '1px solid #e5ac6d'
        }); 
      this.set('styles', {
          'color': '#ffffff'
        }); 
});
   $$('.cb_item').addEvent( 'mouseover', function( fn )
   {
	      this.getFirst('a').set('styles', {
	          'background-image': 'url(./template/www/img/bullet.png)',
	          'padding-left': '23px'
	        }); 
   });

   $$('.cb_item').addEvent( 'mouseout', function( fn )
   {
	   this.getFirst('a').set('styles', {
	       'padding-left': '11px',
	       'background-image':'none'
	     });
   });
   
   /*
   box = new slimbox('.zoom_buttonnn', {
       //useOverlay: true,
      showControls: false
     });*/
      
});
function selectAll( objClass )
{
   $$(objClass).each(function(el) { el.checked = true; });
}

function unselectAll( objClass )
{
   $$(objClass).each(function(el) { el.checked = false; });
}
function open_gal( )
{ 
/*   zb = $$('caption_buttons');
   if(zb)
   {
	  // zb.fireEvent('click');
	   alert(zb.getElementById('zoom_button'));
	   alert(zb);
   }*/
	//alert($('zoom_buttonnn'));
   //$('zoom_buttonnn').fireEvent('click');
	
	/*$$('.cbutton').each(function(el) { alert(el); });
	alert($$('cbutton'));*/
	
	
	box.open($('zoom_buttonnn'));
}


