/* functii cautare top */
Event.observe(window, 'load', 
			function() {
			/* hide all forms*/
						
			//if($('top_cautare')) Event.observe('top_cautare', 'click',switch_topsearch);
			if($('home_img')) Event.observe($('home_img'), 'contextmenu',stopIt);
			if($('cauta_op')) Event.observe('cauta_op', 'click',adv_op);
			if($('ctop_poze')) Event.observe('ctop_poze', 'click',switch_topsearch);
			if($('ctop_membri')) Event.observe('ctop_membri', 'click',switch_topsearch);
			if($('ctop_albume')) Event.observe('ctop_albume', 'click',switch_topsearch);
			//var a=$$('ctop_poze','ctop_membri','ctop_albume')
			//a.invoke('hide');
            if($('loading')){
                Event.observe(window, 'scroll', function() {
    			    $('loading').style.top=(document.viewport.getScrollOffsets().top)+"px"; 
                    $('loading').style.left=((document.viewport.getDimensions().width-$('loading').getDimensions().width-100)/2)+"px";
                      			    
    			});
            }
			
			}
);

function move_loading(){
    
    
}
function switch_topsearch(event){
	var elt1 = Event.element(event);
	
	
	//alert(elt1.id);
	
	switch(elt1.id){
		case 'ctop_poze': 
			//do_topsearch('/cautare/'); 
			$('form_top').action='/cautare/';
		break;
		case 'ctop_albume': 
			//do_topsearch('/cautare/albume/');
			$('form_top').action='/cautare/albume/';
		break;
		case 'ctop_membri': 
			//do_topsearch('/cautare/membri/'); 
			$('form_top').action='/cautare/membri/';
		break;
		
		}
		// schimb clasele
		['ctop_poze','ctop_membri','ctop_albume'].each(function(s) {   $(s).up('li').className ='off'; }); 
		elt1.up('li').className ='on';
	
	}

function do_topsearch(path){
	var qpath='?';
	/* get fields */
	path=$('form_top').action;
	//alert(path);
	if($('q_top').value!='') qpath=qpath+'q='+encodeURIComponent($('q_top').value);

	// daca calea e goala
	if(qpath=='?') qpath='';
	window.location.href=path+qpath.sub('%20','+');
	
	/* IE issue */
	var browserName=navigator.appName; 
	if (browserName=="Microsoft Internet Explorer") {  window.event.returnValue=false; }
	return false;	
}

function stopIt(e){ e.stop(); }