//---------------------send email	
function addPlaylist(id)
{
	OpenBox("/playlist_add.php?id="+id);
}

function SendEmail(url){
	if (CheckFormEmail()){
		  var name = $("input#name").val();
		  var email = $("input#email").val();
		  var name_friend = $("input#name_friend").val();
		  var email_friend = $("input#email_friend").val();
		  var id = $("input#id").val();
		  var dataString = 'send=send&id='+ id + '&name='+ name + '&email=' + email + '&name_friend=' + name_friend + '&email_friend=' + email_friend;
  		
		    $.ajax({
			  type: "POST",
			  url: url,
			  data: dataString,
			  success: function(data,text) {
				$("#box_email").html(data);
			  }
			});
			return false;
	}	 
}

function CheckFormEmail(){
	
	if( $("#name").attr("value") == "" )
	{
		alert( 'Nu ati completat campul Nume' );
		$('#name').focus();
		return false;
	}
	
	if( $('#email').attr("value") == "" )
	{
		alert( 'Nu ati completat campul Email' );
		$('#email').focus();
		return false;
	}
	var temp= new String($('#email').attr("value"));
	var len=temp.length - 3;
	if(temp=="" || temp.indexOf("@")<0 || temp.indexOf(".")<0 || temp.lastIndexOf(".")> len || temp.length-temp.lastIndexOf(".")>4)
	{
		alert("Va rugam introduceti o adresa de email corecta!");
	//	$('#email').attr("value") = "";
		$('#email').focus();
		return false;
	}
	
	
	if( $("#name_friend").attr("value") == "" )
	{
		alert( 'Nu ati completat campul Nume prieten' );
		$('#name_friend').focus();
		return false;
	}
	
	
	if( $('#email_friend').attr("value") == "" )
	{
		alert( 'Nu ati completat campul Email' );
		$('#email_friend').focus();
		return false;
	}
	var temp= new String($('#email_friend').attr("value"));
	var len=temp.length - 3;
	if(temp=="" || temp.indexOf("@")<0 || temp.indexOf(".")<0 || temp.lastIndexOf(".")> len || temp.length-temp.lastIndexOf(".")>4)
	{
		alert("Va rugam introduceti o adresa de email corecta!");
	//	$('#email').attr("value") = "";
		$('#email_friend').focus();
		return false;
	}
	
	return true;
}
function SendContact(){
	if (CheckFormContact()){
		
		document.getElementById("form_contact").submit();
	}
}

function CheckFormContact(){
	
	if( $("#u_name").attr("value") == "" )
	{
		alert( 'Nu ati completat campul Nume' );
		$('#u_name').focus();
		return false;
	}
	
	if( $('#u_email').attr("value") == "" )
	{
		alert( 'Nu ati completat campul Email' );
		$('#u_email').focus();
		return false;
	}
	var temp= new String($('#u_email').attr("value"));
	var len=temp.length - 3;
	if(temp=="" || temp.indexOf("@")<0 || temp.indexOf(".")<0 || temp.lastIndexOf(".")> len || temp.length-temp.lastIndexOf(".")>4)
	{
		alert("Va rugam introduceti o adresa de email corecta!");
	//	$('#email').attr("value") = "";
		$('#u_email').focus();
		return false;
	}
	
	
	if( $("#u_message").attr("value") == "" )
	{
		alert( 'Nu ati completat campul Mesaj' );
		$('#u_message').focus();
		return false;
	}
	return true;
}


function OpenBox(url){
	 $("#box_email").load(url);
	 
	ttop=0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		ttop=window.pageYOffset;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		ttop=document.documentElement.scrollTop;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
		ttop=document.body.scrollTop;
	}

	l = (myWidth-700)/2;
	t = (myHeight-300)/2+ttop ; 
	
	 $('#box_email').css('left','150'+'px');
	 $('#box_email').css('top' , t+'px'); 
	 
	 $('#box_email').css('display','block');
}

function Close(name){
	$('#'+name).css('display','none');
} 