function imgMouseOverEvents(outString, overString, selector) {
	$$(selector).each(function(image) {
		image = $(image);
		if (image.hasClass('active'))
			{
			// set active
			if ($type(image.src)) image.src = image.src.replace(outString, overString);
			}
			
		if ($type(image.src)) {
			if (image.src.indexOf(outString) > 0) {
				image.addEvent('mouseenter',function(){
					image.src = image.src.replace(outString, overString);
				}).addEvent('mouseleave', function(){
					image.src = image.src.replace(overString, outString);
				});
			}
		}
	});
};
//window.addEvent('domready', function(){imgMouseOverEvents('_off', '_on', 'div#navigation img');});


function checkMail(email){
  var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
 	if (filter.test(email)) {
     return true;
   }
   return false;
}


function updateselboxes(curselbox) {
	// var addoption = new Element ( 'option' , { 'value' : '12' , 'html' : 'TEST' }) ;
   // $('sb1').adopt(addoption);
	remonselect = '';
	
	Array.each($(curselbox).options, function(option, i) {
		if(option.getProperty('selected')) {
			remonselect = option.getProperty('value');
		}
	});

	$$('.selb').each(function(el){
		if(el.get('id') != curselbox && remonselect != 0) {
			
			Array.each(el.options, function(option) {
				//alert("Element:" + el.get('id') + "    Option:" + "   Value: " + option.getProperty('value') + " Text:" + option.getProperty('html') + " curselbox: " + curselbox);
				if(option && option.getProperty('value') == remonselect) {
					option.dispose();
				}
			});
		}
	});
	
	/*
	Array.each($('sb2').options, function(option, i) {
		if(option.getProperty('value') == remonselect) {
			option.dispose();
		}
	});
	
	*/
}


function showpan(op) {
	if(op == 'pann_one') {
		$('pann_three').fade('hide');
		$('pann_two').fade('hide');
		$('pann_one').fade('show');
	}
	if(op == 'pann_two') {
		$('pann_three').fade('hide');
		$('pann_one').fade('hide');
		$('pann_two').fade('show');
	}
	if(op == 'pann_three') {
		$('pann_one').fade('hide');
		$('pann_two').fade('hide');
		$('pann_three').fade('show');
	}
}


window.addEvent('domready', function() {

if($('pann_main'))
	{
		$('pann_main').fade('hide');
	}

if($('pann_none'))
	{
		$('pann_none').fade('hide');
	}
	
	
	
	    
	    


if($('choosea'))
	{
			$('over_a').fade('hide');
			$('choosea').addEvent('mouseenter', function(event) {
	 	 				$('over_a').fade('in');
	 	 				$('over_a').setStyle('cursor','pointer');
	 		});
	 		$('choosea').addEvent('mouseleave', function(event) {
	 	 				$('over_a').fade('out');
	 		});
	 		$('choosea').addEvent('click', function(event) {
	 	 				$('choice').fade('out');
	 	 				$('pann_main').fade('in');
	 		});
 	}

if($('chooseb'))
	{
			$('over_b').fade('hide');
			$('chooseb').addEvent('mouseenter', function(event) {
	 	 				$('over_b').fade('in');
	 	 				$('over_b').setStyle('cursor','pointer');
	 		});
	 		$('chooseb').addEvent('mouseleave', function(event) {
	 	 				$('over_b').fade('out');
	 		});
	 		$('chooseb').addEvent('click', function(event) {
	 	 				$('choice').fade('out');
	 	 				$('pann_none').fade('in');
	 		});
 	}


if($('retour_one'))
	{
			$('retour_one').addEvent('mouseenter', function(event) {
	 	 				$('retour_one').setStyle('cursor','pointer');
	 		});
	 		$('retour_one').addEvent('click', function(event) {
	 	 				$('pann_main').fade('out');
	 	 				$('choice').fade('in');
	 		});
 	}

if($('retour_two'))
	{
			$('retour_two').addEvent('mouseenter', function(event) {
	 	 				$('retour_two').setStyle('cursor','pointer');
	 		});
	 		$('retour_two').addEvent('click', function(event) {
	 	 				$('pann_none').fade('out');
	 	 				$('choice').fade('in');
	 		});
 	}


if($('uinf')) {
	$('guessform').addEvent('submit', function(event) {
		event.stop();
		var reqpostform = new Request.HTML({
			method:'post',
			data:{"g1":$('sb1').get('value'), "g2":$('sb2').get('value'), "g3":$('sb3').get('value'), "g4":$('sb4').get('value'), "g5":$('sb5').get('value'), "g6":$('sb6').get('value'), "g7":$('sb7').get('value'), "g8":$('sb8').get('value'), "g9":$('sb9').get('value'), "bbcode":$('bbcode').get('value'), "bbvname":$('bbv').get('value'), "bbnname":$('bbn').get('value'), "bbemail":$('bbem').get('value')},
			url:'http://www.pannobile.com/blackbox/tmpl/guess.php',
			onSuccess: function(html) {
				$('uinf').set('text', '');
				$('uinf').adopt(html);
			},
			onFailure: function() {
				$('uinf').set('text', 'The request failed.');
			}
		});
		if($('bbcode').get('value') && $('bbv').get('value') && $('bbn').get('value') && $('bbem').get('value')) {
			if (checkMail($('bbem').get('value'))) {	
				reqpostform.send(); 
			} else {
				alert('E-Mail ung&uuml;ltig');
			}
		} else {
			alert('Bitte füllen Sie alle Felder korrekt aus !');
		} 
		
	});	
}

}); // end DOMREADY

