var $j = jQuery.noConflict();

$j(function() {

$j("#sendform").css({display:"none"});
$j("#sendform #inputerror").css({display:"none"});

$j("#SendForm").fancybox({
	'scrolling'		: 'no',
	'autoDimensions'	:false,
	'width'			:350,
	'height'		:350,
	'titleShow'		: false,
	'onClosed'		: function() {
	    	$j("#login_error").hide();
		$j("#sendform").css({display:"none"});
	}
}).click(function() {
$j("#sendform").css({display:"block"});
});

$j("#sendform").bind("submit", function() {

	if ($j("#sendform #name").val().length < 1 || $j("#sendform #email").val().length < 1 || $j("#sendform #recipient").val().length < 1 ) {
	//if (($j("#sendform #name").val().length < 1 || (!(isValidEmailAddress($j("#sendform #email").val())) &&  $j("#sendform #email").val().length < 1))){

		if(isValidEmailAddress($j("#sendform #email").val()) && isValidEmailAddress($j("#sendform #recipient").val())) {
			return true;
			}
			else {
		 $j("#sendform #inputerror").css({display:"inline"});
		    $j.fancybox.resize();
		    return false;
		}
	}

});

function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return pattern.test(emailAddress);
}

$j("#Search #smaller-button").click(function() {
  
    $j("#Search #apSearch").animate({
	width:"280"
	});
    $j("#Search #smaller-button").css({display:"none"});
    $j("#Search #bigger-button").css({display:"block"});
    $j("#Search #searchforbig").animate({
        width:"200"
        });
    $j("#Search #searchforbig").val("Restaurants, Tipps, ...");


  });


$j("#Search #bigger-button").click(function() {
    //$j("#Search #apSearch").css({width:"400"});
    $j("#Search #apSearch").animate({
	width:"400"
	});
    $j("#Search #bigger-button").css({display:"none"});
    $j("#Search #smaller-button").css({display:"block"});
    //$j("#Search #searchforsmall").css({display:"none"});
    $j("#Search #searchforbig").animate({
        width:"320"
        });
    $j("#Search #searchforbig").val("Restaurants, Tipps, ... ");


  });


$j("#Search #searchforbig").focus(function() {
	$j("#Search #searchforbig").val("");
});

$j('#carousel').jCarousel({
  width : 260,
  height : 130,
  speed : 100,
  maxSpeed : 10,
  perspective : 90,
  showImageTitle : true,
  reflection : 0,
  overlayColor : "#cacaca",
  overlay : 70,
  onPicClick : function(b,block,i)
  {
    // your code
  }
  
});      
  


});

function show_search() {
    //$j("#Search #apSearch").css({width:"400"});
    $j("#Search #apSearch").animate({
        width:"400"
        });
    $j("#Search #bigger-button").css({display:"none"});
    $j("#Search #smaller-button").css({display:"block"});
    //$j("#Search #searchforsmall").css({display:"none"});
    $j("#Search #searchforbig").animate({
        width:"320"
        });
    $j("#Search #searchforbig").val("Restaurants, Tipps, ...");
}
function small_search() {
    //$j("#Search #apSearch").css({width:"400"});
	$j("#Search #apSearch").animate({
        width:"280"
        });
    $j("#Search #smaller-button").css({display:"none"});
    $j("#Search #bigger-button").css({display:"block"});
    $j("#Search #searchforbig").animate({
        width:"200"
        });
    $j("#Search #searchforbig").val("Restaurant (Name), Ort, ...");


}






