// JavaScript Document

var flag = false;

var nextL = "";
var prevL = "";


$(document).ready(function(){ //BEGIN main wrapper

	$("div.numeCateg").hover(
		function(){
			if(!flag){
				$(this).animate({
						width: '190px'
					}, 200,
					function(){
						//on animation finish
					}
				);
			}
			
		},
		function(){
			
			if(!flag){
				$(this).animate({
						width: '170px'
					}, 200,
					function(){
						//on animation finish
					}
				);
			}
			
		}	
	);
	
	$("div.numeCateg").click(
		function(){
			var nextL = $(this).attr('id')+"L";
			//alert(currentBTN);
			
			if (!flag ) {
				flag = true;				
				$("ul#"+nextL).fadeIn(200);
				prevL = nextL;
			}
			else {
				//hide currently visible submeniu
				$("ul#"+prevL).fadeOut(100);
				
				$("div.numeCateg").animate({
						width: '170px'
					}, 200,
					function(){
						//on animation finish
					}
				);
				$(this).animate({
						width: '190px'
					}, 200,
					function(){
						//on animation finish show submeniu for current buton
						$("ul#"+nextL).fadeIn(200);
						prevL = nextL;
					}
				);
				
			}
			
		}	
	);
	
	$("ul.scariCateg li a").hover(
		function(){
			$(this).next().fadeIn(100);
			$(this).next().next().fadeIn(100);
		},function(){
			$(this).next().fadeOut(100);
			$(this).next().next().fadeOut(100);
		}							  
	);

});

function loadStair(){
	var category = $('ul.dateScara').attr('id');
	var next = '';
	var nextS = '';
	
	if(category === 'ecoLine') {next = 'eco';}
	else if(category === 'trendLine') {next = 'trend';}
	else if(category === 'profiLine') {next = 'profi';}
	nextS = next + 'L';
	
	flag = true;
	
	$('div#'+next).animate({
						width: '190px'
					}, 200,
					function(){
						//on animation finish show submeniu for current buton
						$('ul#'+nextS).fadeIn(200);
						prevL = nextS;
					}
				);
}

function verifyFormContact(theForm){



	if (theForm.nume.value == ""){

		alert("Bitte geben Sie Ihren Namen.");
		return false;

	}

	if (theForm.telefon.value == ""){

		alert("Bitte geben Sie eine Telefonnummer unter der wir Sie erreichen konnen.");
		return false;

	}

	with (theForm.email.value)

		{

			apos=theForm.email.value.indexOf("@");
			dotpos=theForm.email.value.lastIndexOf(".");

			if (apos<1||dotpos-apos<2) {
				alert("Bitte geben Sie eine gultige Email-Adresse, unter der wir Sie erreichen konnen.");
				return false;

			}

		}

}
