
	function a(which, page){

		$('p_nou').className = 'item_default';
		$('p_of').className = 'item_default';
		$('p_ev').className = 'item_default';
		new Effect.Opacity('content_small', { from: 1.0, to: 0.2, duration: 0.3 });
		new Effect.Opacity('loading_small', { from: 0, to: 0.8 });
		if(which == 'of'){
			$('p_of').className = 'item_selected';
			fetchOffers(page);
		}
		if(which == 'ev'){
			$('p_ev').className = 'item_selected';
			fetchEvents(page);
		}
		if(which == 'nou'){
			$('p_nou').className = 'item_selected';
			fetchNews(page);
		}

	}


	function fetchNews(page){
		var url_ = 'index.php?p=news&page='+page;
		var options_={
			method:'GET',
			asyncronous:true,
			onSuccess: function(t) {
				$('content_small').innerHTML = t.responseText;
				new Effect.Opacity('content_small', { from: 0.2, to: 1, duration: 0.3 });
				new Effect.Opacity('loading_small', { from: 0.8, to: 0  });
			},
			onFailure: function(t) {
					alert('failure:' + t.responseText);
			}

		};

		new Ajax.Request(url_, options_);
	}

	function fetchEvents(page){
		var url_ = 'index.php?p=events&page='+page;
		var options_={
			method:'GET',
			asyncronous:true,
			onSuccess: function(t) {
				$('content_small').innerHTML = t.responseText;
				new Effect.Opacity('content_small', { from: 0.2, to: 1, duration: 0.3 });
				new Effect.Opacity('loading_small', { from: 0.8, to: 0 });
			},
			onFailure: function(t) {
					alert('failure:' + t.responseText);
			}

		};
		new Ajax.Request(url_, options_);

	}

	function fetchOffers(page){
		var url_ = 'index.php?p=oferte&page='+page;
		var options_={
			method:'GET',
			asyncronous:true,
			onSuccess: function(t) {
				$('content_small').innerHTML = t.responseText;
				new Effect.Opacity('content_small', { from: 0.2, to: 1, duration: 0.3 });
				new Effect.Opacity('loading_small', { from: 0.8, to: 0  });
			},
			onFailure: function(t) {
					alert('failure:' + t.responseText);
			}

		};
		new Ajax.Request(url_, options_);

	}

	function sayLoading(){
		new Effect.Opacity('loading_', { from: 0, to: 0.8  });
	}

	function stopLoading(){
		new Effect.Opacity('loading_', { from: 0.8, to: 0  });
	}

	function loadPage(pid, pageType){
		//console.log(pageType);
		if(pageType == 'produs'){
			var url_ = 'index.php?p=produs&pid='+pid;
			$('active_content_box_').style.backgroundImage = '';
			$('active_content_box_').style.padding = '0';
			$('active_content_box_').style.width = '640px';
		} else {
			var url_ = 'index.php?p=supliment&scid='+pid;
		}

		var options_={
			method:'GET',
			asyncronous:true,
			onSuccess: function(t) {
				$('active_content_box_').innerHTML = t.responseText;
				stopLoading();
			},
			onFailure: function(t) {
					alert('failure:' + t.responseText);
			}

		};
		new Ajax.Request(url_, options_);
	}

	function toggleSubmenu(mid){
		var id_ = "submenu_holder_"+mid;
		if($(id_).style.display == 'none'){
			$(id_).style.display = 'block';
		} else {
			$(id_).style.display = 'none';
		}
	}

	function sendEmail(){

		new Effect.Opacity('cformHolder', { from: 1, to: 0.1, duration: 1 });
		var url_ = 'index.php?p=sendemail';
		pb  = 'nume=' + escape($('nume').value) + '&prenume=' + escape($('prenume').value);
		pb += '&telefon=' + escape($('telefon').value) + '&email='+ escape($('email').value);
		pb += '&mesaj=' + escape($('mesaj').value);

		var options_={
			method:'POST',
			asyncronous:true,
			postBody:pb,
			onSuccess: function(t) {
				if(t.responseText == 'success'){
					$('messageTextHolder').style.color = 'yellow';
					$('messageTextHolder').innerHTML = 'Mesajul dumneavoastra a fost trimis. Veti primi un raspuns in cel mai scurt timp posibil. Multumim.';
				} else {
					$('messageTextHolder').style.color = 'red';
					$('messageTextHolder').innerHTML = 'Mesajul dumneavoastra nu poate fi trimis. Va rugam sa incercati mai tarziu sau sa ne contactati telefonic la numerele afisate in pagina pe coloana din stanga.';
				}
				new Effect.Opacity('messageHolder', { from: 0, to: 1, duration: 1 });

				setTimeout( "new Effect.Opacity('cformHolder', {from: 0.1, to: 1,duration:1})", 1000);
				setTimeout( "$('messageHolder').fade({duration:1})", 3000);
			},
			onFailure: function(t) {
				//console.log('failure');
			}
		};
		new Ajax.Request(url_, options_);
		document.getElementById("MForm").reset(); 
	}

	function changePhoto(){
		var current = $('photo_'+counter);
		if( counter != 5){
			counter++;
		} else {
			counter=1;
		}
		var next = $('photo_' + counter);
		current.fade({ duration: 3.0 });
		next.appear({ duration: 3.0 });
	}

