// JavaScript Document
$(document).ready(function(){
$("#send").removeAttr("disabled"); 						   
$("#Home").show();
$("#menu a").click(function () {
	var nume = $(this).text();					 
	$("#menu a").each(function () {
		var tab = $(this).text();					 
		$(this).removeClass("active");
		$("#"+tab).hide();
  	});
	$(this).addClass("active");
	$("#"+nume).show();
});
$("#ads").click(function () {
	var nume = "Contact";	
	$("#message").val("I'm interested in advertising here.");
	$("#menu a").each(function () {
		var tab = $(this).text();					 
		$(this).removeClass("active");
		$("#"+tab).hide();
  	});
	$(this).addClass("active");
	$("#"+nume).show();
});

});
function show() {
	if (typeof(xhr) != "undefined") xhr.abort();
	var id = $('#yid').val();
	if (id == "") {
		$("#results").html("<div style=\"padding-top:37px;\">Please enter Y! ID</div>");
		return false;
	}
	$("#results").html("<div style=\"padding-top:50px;\"><br><br><img src=\"images/aloader.gif\" /></div>");
	$('#results').slideDown('normal');
	xhr = $.ajax({
	  url: "status.php",
	  data: "yahooid="+id,
	  cache: false,
	  success: function(html){
		$("#results").html(html);
		$('#yid').val("");
      },
	  error: function(html) {
		$("#results").html("<div style=\"padding-top:17px;\">There was a problem with the request</div>"); 
	  }
	});
}
function sendmail() {
	$.ajax({
   		type: "POST",
	    url: "contact.php",
	    data: $("#cont").serialize(),
	    success: function(msg){
	       $("#sendstatus").html(msg);
		   if (msg == 'Message sent!') {
			   $("#send").attr("disabled", "true"); 
		   }
	   }
 	});
}

var http = createRequestObject();
function createRequestObject() {
	var xmlhttp;
	try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); }
	catch(e) {
		try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
		catch(f) { xmlhttp=null; }
	}
	if(!xmlhttp&&typeof XMLHttpRequest!="undefined") {
		xmlhttp=new XMLHttpRequest();
	}
	return  xmlhttp;
}
function substr_count(string,substring,start,length)
{
 var c = 0;
 if(start) { string = string.substr(start); }
 if(length) { string = string.substr(0,length); }
 for (var i=0;i<string.length;i++)
 {
  if(substring == string.substr(i,substring.length))
  c++;
 }
 return c;
}

function doCheck() {
	if(substr_count(document.getElementById("result").innerHTML,'loader.gif') != 0){
		return false;
	}
	else {
		full_nick = encodeURIComponent(document.getElementById("id_mess").value);
		if (full_nick == '' || full_nick == 'Yahoo!%20ID') {
			alert('Va rugam sa introduceti un ID!');
		}
		else {
			http.open('POST',  'verificaR3.php');
			document.getElementById("result").innerHTML="<div style=\"padding-top:40px;\"><img src=\"images/loader.gif\" /></div>";
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.setRequestHeader('HTTP_X_REQUESTED_WITH', 'XMLHttpRequest');
			http.onreadystatechange = handleResponse;
			http.send('id_mess='+full_nick);
		}
		return false;
	}
}
function Post(url, target) {
	url = encodeURIComponent(document.getElementById(url).value);
	
		http.open('POST',  url);
		document.getElementById(target).innerHTML="<img src='images/loader.gif'>";
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponse;
	return false;
}
function handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			response = http.responseText;
			document.getElementById('result').innerHTML = ''+response+'';
		}
  	}
	catch(e){}
	finally{}
}



