function isValidEmail(sValue)
{	
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!sValue.match(re))
        return false;
    return true;
}

function checkGuestbook(oForm, checkEmail)
{
	var bRet = true, oElem;
	
	document.getElementById('emailValidError').style.display = 'none';
	document.getElementById('finnal_message').style.display = 'none';
	
	if(document.getElementById('userName').value == '')
	{
		document.getElementById('userNameError').style.display = 'inline';
		bRet = false;
	}
	if(document.getElementById('valid_text').value == '')
	{
		document.getElementById('valid_textError').style.display = 'inline';
		bRet = false;
	}
	/*
	if(document.getElementById('userEmail').value == '')
	{
		document.getElementById('userEmailError').style.display = 'inline';
		bRet = false;
	}
	
	if(checkEmail == 1)
	{
		if(document.getElementById('userEmail').value == '')
		{
			document.getElementById('userEmailError').style.display = 'inline';
			bRet = false;
		}
	}
	*/
	
	if(document.getElementById('userComment').value == '')
	{
		document.getElementById('userCommentError').style.display = 'inline';
		bRet = false;
	}
	
/*		
	for(var i=0; i<oForm.elements.length; i++)
	{
		oElem = oForm.elements[i];
		
		if(oElem.type != 'text') continue;
		
		document.getElementById(oElem.name + 'Error').style.display = 'none';
			
		if(!oElem.value)
		{
			document.getElementById(oElem.name + 'Error').style.display = 'inline';		
			bRet = false;			
		}			
	}
*/	
	//email validation
	if (checkEmail == 1 && oForm.userEmail.value && !isValidEmail(oForm.userEmail.value))
	{		
		document.getElementById('emailValidError').style.display = 'inline';
		bRet = false;	
	}
		
	if(bRet == false)
		document.getElementById('finnal_message').style.display = 'inline';	
	else
		document.getElementById('finnal_message').style.display = 'none';			
	return bRet;
}

$(document).ready(function(){
	$('#slideStatus a').css('color','#fff');
	//startclock();
	$(".menu_link").each(function(){
		
		$(this).hover(
				function() { /*$(this).children("a").css("color","#333333");*/
				//$(".submenu").not($(this).children(".submenu")).stop().css("width","1px").hide();$(this).children(".submenu").animate({width:"159px"},200);
				$(".submenu").not($(this).children(".submenu")).hide();$(this).children(".submenu").show();
				},
				
				function() {/*$(this).children("a").css("color","#FFFFFF");*/}
		
		);
		
		
	});
	
	$(".submenu").each(function(){
		$(this).hover(
				function(){$(this).show();},
				function(){$(this).hide();
						
						
					}
				
				);
	});
	
});

var cycle_stop = true;

function toggleCycle()
{
	if(cycle_stop) {
		$("#cycle_holder").cycle('resume');
		$("#lycontrol a").html("Stop");
	}	
	else
		{$("#cycle_holder").cycle('pause');
		$("#lycontrol a").html("Start");
		}
	
	cycle_stop = !cycle_stop;

}

function onBefore() { 
    $(".thumb_holder").css("background-color","#666666");
    //alert("#thumb_"+$(this).attr("sid"));
  //  console.log(this);
    var current_id = parseInt($(this).children("img").attr("sid"));
    $("#thumb_"+current_id).css("background-color","#FFFFFF");
    
    if(current_id%4 == 0)
    		public_car.scroll((current_id/4) + 1);
}

var public_car;

function mycarousel_initCallback(carousel) {
    
		public_car = carousel;
		
}

