/*
	JavaScript Document for YMinvisible.com 
	Copyright (c) 2009 - All Rights Reserved.
	Author: Mirel - www.CDMirel.com
*/
function doCheck() {
	if (typeof(xhr) != "undefined") xhr.abort();
	var id = $('#ymid').val();
	if (id == "") {
		$("#results").html("<div class=\"info\">Please enter Yahoo! Messenger ID.</div>");
		return false;
	}
	$("#results").html("<div class=\"info\">Loading...<br /><img src=\"img/loading.gif\" alt=\"Loading...\" /></div>");
	$('#results').slideDown('normal');
	xhr = $.ajax({
	  url: "check.php",
	  data: "id="+id,
	  cache: false,
	  success: function(html){
		$("#results").html(html);
		$('#ymid').val(id);
      },
	  error: function(html) {
		$("#results").html("<div class=\"info\">There was a problem with the request.</div>"); 
	  }
	});
}
function generateCode(){
var user;
var img;
user=document.getElementById("ymid").value;
radio = 1;
while(true)
{
if ($("#status"+radio).attr('checked'))
		{
			img = radio;
			break;
		} else {
			radio++;
		}
}
	if(user=="" || img==""){
		alert("Type Yahoo! ID or chose status image!");
	}
	else
	{
		//document.getElementById("showCode").innerHTML="&lt;!--START Status Indicator - YMinvisible.com--&gt;\n&lt;iframe style=\"padding:0;\" src=\"http://mirel.zapto.org/ym/"+user+"-"+img+".html\" frameBorder=\"0\" width=\"32\" height=\"32\" marginwidth=\"0\" marginheight=\"0\">&lt;/iframe&gt;\n&lt;!--END Status Indicator - YMinvisible.com--&gt;";	

		document.getElementById("showCode").innerHTML="&lt;!-- START YMinvisible.com - Status Indicator --&gt;\n&lt;iframe src=\"http://www.YMinvisible.com/status-indicator/"+user+"-"+img+"\" frameBorder=\"0\" marginwidth=\"0\" marginheight=\"0\"&gt;&lt;/iframe&gt;\n&lt;noscript&gt;\n&lt;a href=\"http://www.YMinvisible.com\" title=\"YM invisible - Invisible Scanner / Detector\"&gt;YM invisible - Invisible Scanner / Detector&lt;/a&gt;\n&lt;/noscript&gt;\n&lt;!-- END YMinvisible.com - Status Indicator --&gt;";
	}
}
function verify(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
		alert("E-mail address is not valid!")
	return false
	}

    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		alert("E-mail address is not valid!")
	return false
    }

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("E-mail address is not valid!")
	return false
	}

	if (str.indexOf(at,(lat+1))!=-1){
		alert("E-mail address is not valid!")
	return false
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("E-mail address is not valid!")
	return false
	}

	if (str.indexOf(dot,(lat+2))==-1){
		alert("E-mail address is not valid!")
    return false
	}
	if (str.indexOf(" ")!=-1){
		alert("E-mail address is not valid!")
	return false
	}

 	return true
}
function validateForm(contact) {
	if(contact.name.value == "") {
		alert("Please enter your full name.");
		return false;
	}
	if(contact.email.value == "") {
		alert("Please enter your email address.");
		return false;
	}
	if(contact.subject.value == "") {
		alert("Please enter your subject.");
		return false;
	}
	if(contact.message.value == "") {
		alert("Please enter your message.");
		return false;
	}
	else {
		return true;
	}
}
function validateEmail(){
	var emailID=document.contact.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter your email address.")
		emailID.focus()
		return false
	}
	if (verify(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true	
}
