to_filter = "agencies_contents";
var xmlHttp = null;
/***********************************Ajax Starts*************************************/
function GetXmlHttpObject()
{
	var xmlHTTP = null;
	//xmlHTTP=null;
	try
	{
	  // Firefox, Opera 8.0+, Safari
	  xmlHTTP=new XMLHttpRequest();
	}
	catch (e)
	{
	  // Internet Explorer
		try
		{
			xmlHTTP=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHTTP=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHTTP;
}

function showContents(url)
{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	xmlHttp.onreadystatechange=showChangedContents;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function showChangedContents() 
{ 
 	if (xmlHttp.readyState==2 || xmlHttp.readyState==3)
	{
		document.getElementById(to_filter).innerHTML='<tr><td colspan="3">loading...<br /><img src="images/loading_animation_liferay.gif" alt="#" /></td></tr>';
	}
	if (xmlHttp.readyState==4)
	{	document.getElementById(to_filter).innerHTML = xmlHttp.responseText;
	}
	
}
/***********************************Ajax Ends*************************************/
function showSelectBoxes(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

// ---------------------------------------------------

function hideSelectBoxes(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}
function hide_all()
{
	document.getElementById("agencies_contents").style.display = 'none';
	document.getElementById("websites_contents").style.display = 'none';
	document.getElementById("lawyers_contents").style.display = 'none';
	document.getElementById("states_contents").style.display = 'none';
	
	document.getElementById("agencies").style.backgroundColor = "#FFFFFF";
	document.getElementById("websites").style.backgroundColor = "#FFFFFF";
	document.getElementById("lawyers").style.backgroundColor = "#FFFFFF";
	document.getElementById("states").style.backgroundColor = "#FFFFFF";
}

function change_contents(td_obj,tbl_id)
{	hide_all();
	document.getElementById(tbl_id).style.display = '';
	td_obj.style.backgroundColor = '#D9D7D8';
	to_filter = tbl_id;
}

function create_review()
{
	if(to_filter == "agencies_contents")
	{
		window.location.href="all_agencies.php";
	}
	else if(to_filter == "websites_contents")
	{
		window.location.href="all_websites.php";
	}
	else if(to_filter == "lawyers_contents")
	{
		window.location.href="all_lawyers.php";
	}
	else if(to_filter == "states_contents")
	{
		window.location.href="all_states.php";
	}
}

function filter_best()
{	if(to_filter == "agencies_contents")
	{
		showContents("filter_best.php?use=agencies&from=best");
	}
	else if(to_filter == "websites_contents")
	{
		showContents("filter_best.php?use=websites&from=best");
	}
	else if(to_filter == "lawyers_contents")
	{
		showContents("filter_best.php?use=lawyers&from=best");
	}
	else if(to_filter == "states_contents")
	{
		showContents("filter_best.php?use=states&from=best");
	}
}

function filter_worst()
{	if(to_filter == "agencies_contents")
	{
		showContents("filter_best.php?use=agencies&from=worst");
	}
	else if(to_filter == "websites_contents")
	{
		showContents("filter_best.php?use=websites&from=worst");
	}
	else if(to_filter == "lawyers_contents")
	{
		showContents("filter_best.php?use=lawyers&from=worst");
	}
	else if(to_filter == "states_contents")
	{
		showContents("filter_best.php?use=states&from=worst");
	}
}

function view_all()
{	if(to_filter == "agencies_contents")	
	{	use = "agencies";
		window.location.href="all_agencies.php";
	}
	else if(to_filter == "websites_contents")	
	{	use = "websites";
		window.location.href="all_websites.php";
	}
	else if(to_filter == "lawyers_contents")	
	{	use = "lawyers";
		window.location.href="all_lawyers.php";
	}
	else if(to_filter == "states_contents")	
	{	use = "states";
		window.location.href="all_states.php";
	}
	hideSelectBoxes();
	//document.getElementById('view_all_panel').innerHTML = '<span onclick="document.getElementById(\'view_all_panel\').style.display=\'none\';showSelectBoxes();" style="margin-top:0;color:#FFFFFF;cursor:pointer;">Close&nbsp;</span><br /><br /><iframe  frameborder="0" scrolling="auto" src="view_all.php?use='+use+'" style="background-color:#FFFFFF;margin-right:1px;" width="448px" height="258px"></iframe>';
	
	//document.getElementById('view_all_panel').style.display = '';
}

/**********************************************************/

/***********************************************
* Drag and Drop Script: © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var dragobject={
z: 0, x: 0, y: 0, offsetx : null, offsety : null, targetobj : null, dragapproved : 0,
initialize:function(){
document.onmousedown=this.drag;
document.onmouseup=function(){this.dragapproved=0;}
},
drag:function(e){
var evtobj=window.event? window.event : e;
this.targetobj=window.event? event.srcElement : e.target;
if (this.targetobj.className=="drag"){
this.dragapproved=1;
if (isNaN(parseInt(this.targetobj.style.left))){this.targetobj.style.left=0;}
if (isNaN(parseInt(this.targetobj.style.top))){this.targetobj.style.top=0;}
this.offsetx=parseInt(this.targetobj.style.left);
this.offsety=parseInt(this.targetobj.style.top);
this.x=evtobj.clientX;
this.y=evtobj.clientY;
if (evtobj.preventDefault)
evtobj.preventDefault();
document.onmousemove=dragobject.moveit;
}
},
moveit:function(e){
var evtobj=window.event? window.event : e;
if (this.dragapproved==1){
this.targetobj.style.left=this.offsetx+evtobj.clientX-this.x+"px";
this.targetobj.style.top=this.offsety+evtobj.clientY-this.y+"px";
return false;
}
}
}

dragobject.initialize();

function check_expense(frm)
{
	if(frm.state.value=="0")
	{
		alert("Please select state");
		frm.state.focus();
		return false;
	}
	if(frm.cred_agency.value=="0")
	{
		alert("Please select Credentialing Agency");
		frm.cred_agency.focus();
		return false;
	}
	/*if(frm.evaluation.value=="0")
	{
		alert("Please select Evaluation type");
		frm.evaluation.focus();
		return false;
	}*/
	
	for(i=0;i<frm.visa.length;i++)
	{
		if(frm.visa[i].checked==true)
		{
		var visa=frm.visa[i].value;
		}
	}
	
	for(i=0;i<frm.toefl.length;i++)
	{
		if(frm.toefl[i].checked==true)
		{
		var toefl=frm.toefl[i].value;
		}
	}
	
	for(i=0;i<frm.tse.length;i++)
	{
		if(frm.tse[i].checked==true)
		{
		 var tse=frm.tse[i].value;
		}
	}
	
		for(i=0;i<frm.lice.length;i++)
	   {
		if(frm.lice[i].checked==true)
		{
		var lice=frm.lice[i].value;
		}
	  }
	  
	  if(!visa)
	  {
		 alert("Please checked VISA Screen"); 
		 return false;
	  }
	  if(!toefl)
	  {
		 alert("Please checked TOEFL"); 
		 return false;
	  }
	  if(!tse)
	  {
		 alert("Please checked TSE"); 
		 return false;
	  }
	  if(!lice)
	  {
		 alert("Please checked Temporary license"); 
		 return false;
	  }
	  return true;
	
}
