$(document).ready(function(){
	$("#slide").wslide({
		width: 711,
		height: 393,
		autolink: false,
		duration: 400
	});
});

function css() {
	if(window.screen.height<=1024) {
    	document.write('<link href="style/css/small.css" rel="stylesheet" type="text/css" media="screen" />');
    } else {
    	document.write('<link href="style/css/big.css" rel="stylesheet" type="text/css" media="screen" />');
    }
}

function showHide(id,content) {

	if($('#'+id).is(':hidden')) {
		$('#'+id).fadeIn('slow',function(){
			if(content==1) $('#'+id+'_content').fadeIn('slow');
			$('#'+id+'_button').html('&minus;');
		});
	} else {
		$('#'+id).fadeOut('slow',function(){
			if(content==1) $('#'+id+'_content').fadeOut('slow');
			$('#'+id+'_button').html('+');
		});
	}

}

function viewPhoto(id) {

	var nr_photos = $('#nr_photos').val();

	$('#photo'+nr_photos).fadeOut('slow',function(){
		$('#photo'+id).fadeIn('slow');
		$('#nr_photos').attr('value',id);
	});

}

function contact() {

	var nume = $('#c_nume').val();
	var email = $('#c_mail').val();
	var tel = $('#c_tel').val();
	var mesaj = $('#c_mesaj').val();

	$.post('ajax.php?action=contact',
		{
			nume: nume,
			email: email,
			tel: tel,
			mesaj: mesaj
		},
		function(data){
			$('#contact_form').fadeOut('slow',function(){
				$('#contact_loading').fadeIn('slow',function(){

					if(data==1) {
						$('#contact_loading').fadeOut('slow',function(){
							$('#contact_loading').html('Mesajul dvs. a fost trimis ! Va vom contacta in cel mai scurt timp posibil.<br /><br />Va multumim !');
							$('#contact_loading').fadeIn('slow');
						});
					} else {
						eval(data);
					}

				});
			});
		}
	);

}

function cdo() {

	var nume = $('#cdo_nume').val();
	var email = $('#cdo_mail').val();
	var tel = $('#cdo_tel').val();
	var mesaj = $('#cdo_mesaj').val();

	$.post('ajax.php?action=cdo',
		{
			nume: nume,
			email: email,
			tel: tel,
			mesaj: mesaj
		},
		function(data){
			$('#cdo_form').fadeOut('slow',function(){
				$('#cdo_loading').fadeIn('slow',function(){

					data = data.split('_:#!#:_');

					if(data[0]==1) {
						$('#cdo_loading').fadeOut('slow',function(){
							$('#cdo_loading').html('Mesajul dvs. a fost inregistrat !<br /><br />Va multumim !');
							$('#cdo_loading').fadeIn('slow',function(){
								jQuery('#cdo_mesaje').prepend('<p id="cdo'+data[1]+'" style="display:none"><span><strong>'+data[2]+'</strong> a scris</span>'+data[3]+'</p>');
								jQuery('#cdo'+data[1]).slideDown('slow');
							});
						});
					} else {
						eval(data[1]);
					}

				});
			});
		}
	);

}