function checkUsername(username)
{ 	
      
	  if(username!=""){	
		  $.post("/includes/username-check.php", {
			 
				username: $('#username').val()
			  }, function(response){
				$('#usernameResult').hide();
				setTimeout("finishAjax('usernameResult', '"+escape(response)+"')", 400);
				$('#usernameLoading').show();
			return false;
		 
		});
	} else {
		$('#usernameResult').hide();	
	}
}

function checkPassword(pass1,pass2)
{ 	
	  if(pass1==pass2){	
				$('#passwordResult').hide();
		} else {
				$('#passwordResult').show();	
		}
}


function finishAjax(id, response) {
  $('#usernameLoading').hide();
  $('#'+id).html(unescape(response));
  $('#'+id).fadeIn();
} //finishAjax}


function embedVid(vid)
{
	var vid_embed;
	vid_embed = "<object width=\"360\" height=\"240\"><param name=\"movie\" value=\"http://www.youtube.com/v/"+vid+"&hl=en&fs=1&\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/"+vid+"&hl=en&fs=1&\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"360\" height=\"240\"></embed></object>";
	return vid_embed;
}

function getScreen( url, size )
{ 
//alert(url);
  if(url == "")
  { 
    $('#video-check').html("<p class='alert info'>Are you sure you entered someting here?...</p>"); 
	//alert('blank');
	return "";
  }

	  size = (size === null) ? "big" : size;
	  var vid;
	  //var vid2;
	  var results;
	  //var results2;
	
	  results = url.match("[\\?&]v=([^&#]*)");
	  if (results === null)
	  {
	  	results = url.match("[v][/]([^&#]*)");
	  }
	  
	  if (results === null)
	  {
		$('#video-check').html("<p class='alert error'>We are having problems with the video Code please copy the url and paste it here</p>"); 
	  }
	  
	  vid = ( results === null ) ? url : results[1];
	  //vid2 = ( results2 === null ) ? url : results2[1];
	  $("#video_id").val(vid);
	  //alert(vid);
	  var vid_url;
	  var vid_embed;
	  
	  vid_embed = embedVid(vid);
	  
	  if(size == "small"){
		  vid_url="http://img.youtube.com/vi/"+vid+"/2.jpg";
		  
		//return "http://img.youtube.com/vi/"+vid+"/2.jpg";
	  }else {
		  vid_url="http://img.youtube.com/vi/"+vid+"/0.jpg";
		  
		  //$('#reg-test').html("<img src='http://img.youtube.com/vi/"+vid+"/0.jpg</p>'");
			//return "http://img.youtube.com/vi/"+vid+"/0.jpg";
	  }  	
		$('.video-wrap').height(250);
		$('#video-thumb').animate({'height':'240px'},1500);
		 
		 	var img = new Image();
			$(img).load(function () {
			$('#video-thumb').removeClass('loading').html(this);
			$(this).fadeIn();		
			//$('#video-thumb').animate({opacity:0.1},1000);
	
		}).error(function () {
			// notify the user that the image could not be loaded
		}).attr('src', vid_embed);
		$('#video-thumb').html(vid_embed);
}

function loadImage(vid_url)
{
	var img = new Image();
	$(img).load(function () {
		//$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
		$(this).hide();
		$('#video-thumb').removeClass('loading').append(this);
		$(this).fadeIn();
		//$('#video-thumb').height(240);
		$('#video-thumb').animate({'height':'240px'},1500);
		//$('#video-thumb').animate({opacity:0.1},1000);

	}).error(function () {
		// notify the user that the image could not be loaded
	}).attr('src', vid_url);
	
}

function approveAccounts(user_id,str,type)
{
	//alert(user_id+str+type);
	
	if ($('#denyAccount').is(':checked')) {
		 $('.filters-text').innerHTML="<p>Working...</p>";
		 //a/lert("user_id="+user_id+" str="+str);
		 $('#denial_text').show('slide');
	} else {
		$("#denial_text").hide('slide');
		//alert("not selected"+str);
	}
	//alert(type);
	$('.filters-text').innerHTML="<p>Working...</p>";
	var pars = "user_id="+user_id+"&q="+str+"&type="+type;
	$('#message').load('/admin/admin-user-approval.php?'+pars);

}
