
//---------------------- B E G I N --- code for sites.php page

function delete_site(site_id,site_name)
{
	if(confirm("Are you sure you want to delete site: " + site_name + "?"))
	{
	  	//document.getElementById('option').value="delete";
	  	document.getElementById('del_site_id').value=site_id;
		document.delete_site.submit();
	}
		
}


function edit_site(site_id,site_name,site_url)
{
	//document.getElementById('option').value="edit";
	document.getElementById('site_id').value=site_id;
	document.getElementById('site_name').value=site_name;
	document.getElementById('site_url').value=site_url;
		
}

function sites_validation()
{
	if(document.getElementById('site_name').value=="")
	{
		alert("Site Name is invalid or blank!");
		return false; 
	}
	else
	if(document.getElementById('site_url').value=="")
	{
		alert("Site URL is invalid or blank!");
		return false; 
	}
	
   if(document.getElementById('option').value!='add')
   {
   	if (confirm("Are you sure you want to modify this Site?")) {
   		return true;
   	}
   	else
   	{
   		return false;

   	}
   }
	
}
// ------- E N D ---- code for sites.php

function change_css_code_content()
{
  	index=document.getElementById('css').value;
  	document.location="css_manager.php?id="+index;
}

//---------------------- B E G I N --- code for categories.php page

function populate(category_id,category_name,keywords,display_order)
{
	//alert(category_name);		
	document.getElementById('category_name').value=category_name;
	document.getElementById('keywords').value=keywords;
	document.getElementById('display_order').value=display_order;
	document.getElementById('submit_add').value="Edit";	
	document.getElementById('add').value="edit";	
}

// ------- E N D ---- code for categories.php

function backup_confirm()
{
	if(confirm("Are you sure you want to backup Database?"))
	{
      return true;
   	}
   	else
   	{
   	  return false;
   	}
}

function restore_confirm(date)
{
	if(confirm("Are you sure you want to restore Database created on "+date+"?"))
	{
      return true;
   	}
   	else
   	{
   	  return false;
   	}
}


function confirmDelete(delUrl,item) {
  if (confirm("Are you sure you want to delete this "+item + "")) {
    document.location = delUrl;
  }
}

function confirmAprove(aprvUrl,item) {
  if (confirm("Are you sure you want to aprove this "+item + "?")) {
    document.location = aprvUrl;
  }
}

function confirmSuspend(suspUrl,item) {
  if (confirm("Are you sure you want to suspend this "+item + "?")) {
    document.location = suspUrl;
  }
}

function confirmEdit(item) {
	
  if (confirm("Are you sure you want to modify this "+item+ "?"))
  	return true;	
  else
   	return false;
    
}

function confirmReportBad(Url) {
  if (confirm("Are you sure you want to report this free Ad as a bad Ad?")) {  	
     document.location = Url;         
  }
  
}

function SelectAll(field)
{
			var opt = document.getElementById(field);
			var i;
			for (i=0; i<opt.length; i++)
				opt.options[i].selected=true;
}	

function CountCharacters (field,out_field)
{

	document.getElementById(out_field).value=document.getElementById(field).value.length;	
	
}


function get_url()
{
if (add_image_ad.url.value.indexOf('http://')==-1)
 { 
  alert('Error: Your url should begin with http://');
  return false;
 }
else	
 return true;

}

