


$(document).ready(function()
{ 
  
   
   news();
      
});


function  navigation(data)
{
  $.post("./navigation.php",{id:data},  function(data)
    { 
	   if(data.length>0)
	   { 	  
		 $("#navigation").html(data); 
		 
	   } 
	   else
	   {
		 document.getElementById("#navigation").innerHTML="<b><br> No details News ...</b>"; 
	   }
	});
}

function news()
{
  $.post("./news.php",  function(data)
    { 
	   if(data.length>0)
	   { 	  
		 $("#news").html(data); 
		 setTimeout("news()", 5000);
	   } 
	   else
	   {
		 document.getElementById("#news").innerHTML="<b><br>No image available...</b>"; 
	   }
	});
}

function loginvalidation()
{
var mail=document.getElementById("mail").value;
 var pass=document.getElementById("pass").value; 

 if(mail.indexOf('@')==-1 ||mail.indexOf('.')==-1 ||mail.indexOf('@')>mail.lastIndexOf('.') ||mail.split('@.').length==2 ||mail.split('.@').length==2 )
{
		alert("please enter the correct email ");
	    document.getElementById("mail").focus();
		return false;
}
else if(pass=="")
 {
 alert("Please  Enter the password  ");
 document.getElementById("pass").focus();
 return false;
 }

else
{
	
	$.post("./verify.php",{mail:mail,pass:pass},function(data)
      {
		  if(data.length>0)
		  {
			 $("#items").html(data);
		  }
		  else
		  {
			  document.getElementById("items").innerHTML="<b> No user Avilable</b>";
		  }
	  });
}
}


function newuser()
{
	$.post("./newuser.html",function(data)
	{
		if(data.length>0)
	{
		$("#items").html(data);
	}
	});
}

function validation()
{
 var name=document.getElementById("name").value;
 var mail=document.getElementById("mail").value;
 var pass=document.getElementById("pass").value; 
 var number=document.getElementById("phone").value;
 var address=document.getElementById("address").value;

if(name=="")
 {
 alert("Please  enter  your name");
 document.getElementById("name").focus();
 return false;
 }
 else if(mail.indexOf('@')==-1 ||mail.indexOf('.')==-1 ||mail.indexOf('@')>mail.lastIndexOf('.') ||mail.split('@.').length==2 ||mail.split('.@').length==2 )
{
		alert("please enter  your correct email address ");
	    document.getElementById("mail").focus();
		return false;
}
else if(pass==""||pass.length<6)
 {
 alert("Please  enter your  password  ");
 document.getElementById("pass").focus();
 return false;
 }

else if(number==""||isNumeric(number)==false||number.length>12)
 {
 alert("Please enter your  correct number");
 document.getElementById("number").focus();
 return false;
 }
 else if(address=="")
 {
 alert("Please  enter  your address  ");
 document.getElementById("address").focus();
 return false;
 }
else
{
	
	$.post("./insert.php",{name:name,mail:mail,pass:pass,number:number,address:address},function(data)
      {
		  if(data.length>0)
		  {
			 $("#items").html(data);
		  }
		  else
		  {
			  document.getElementById("items").innerHTML="<b> No user Avilable</b>";
		  }
	  });
}
}
function isNumeric(num)
{
  var number="+0123456789";
  var m=0;
  for(i=0;i<num.length;i++)
  {
	for(j=0;j<number.length;j++)
	{
	  if(num.charAt(i)==number.charAt(j))
	  {
		  m=m+1;
	  }
	}
  }
  
  if(m==num.length)
  {
	  return true;
  }
  else
  {
	  return false;
  }
}

