// JavaScript Document
$(document).ready(function(){
	$("#send").removeAttr("disabled");
	$("#reclamamain").show();
	$("#resultbody").hide();
	$("#yid").focus();
});

function stripos( f_haystack, f_needle, f_offset ){
	var haystack = (f_haystack+'').toLowerCase();
	var needle = (f_needle+'').toLowerCase();
	var index = 0;

	if ((index = haystack.indexOf(needle, f_offset)) !== -1) {
		return index;
	}
	return false;
}

function show() {
	if (typeof(xhr) != "undefined") xhr.abort();

	$("#reclamamain").hide();
	//$('#reclamadreapta').hide();
	//$('#reclamajos').hide();
	$("#resultbody").hide();
	$("#resultbody").fadeIn("normal");

	var id = $('#yid').val();
	if (id == "" || id == "ID Yahoo!") {
		$("#descriere").html("<div class=\"centered\">Introdu te rog ID-ul Yahoo!</div>");
		return false;
	}

	$("#descriere").html("<div class=\"centered\">Verific... Te rog aşteaptă...<br /><br /><img src=\"images/loader.gif\" /></div>");

	var scanner = $('#scanner').val();
	xhr = $.ajax({
	  type: "POST",
	  url: "checkro.php",
	  data: "yid="+id+"&scanner="+scanner,
	  cache: false,
	  success: function(html) {
			$("#resultbody").hide();
			$("#resultbody").fadeIn("fast");
			$("#descriere").html(html);
			//$('#reclamadreapta').show();
			//$('#reclamajos').show();
			$('#yid').val("");
    },
	  error: function(html) {
			$("#descriere").html("<div class=\"centered\">A fost o problemă cu request-ul.</div>");
	  }
	});
}

function sendmail() {
	$.ajax({
		type: "POST",
		url: "sendro.php",
		data: $("#contact").serialize(),
		success: function(msg) {
			$("#sendstatus").html(msg);
			if (msg == 'Mesaj trimis!') {
			   $("#send").attr("disabled", "true");
			 }
	   }
 	});
}
