// JavaScript Document

function validate12()
{

	if(document.headersearch.search.value=="")
	{
		alert("Please enter the search keyword");
		document.headersearch.search.focus();
		return false;
	}
	return true;
}

function showroomfirsttime()
{
	document.getElementById('directory_1').style.display='block';
}
function firstload()
{
	submenu='<b>Biz Directory &raquo; </b><a style="text-decoration: none;" href="/directories/index_all.html" class="sublink"><font color="#000000">Business Directory</font></a> | <a style="text-decoration: none;" href="/directories/seller-directory.asp" class="sublink"><font color="#000000">Sellers Directory</font></a> | <a style="text-decoration: none;" href="/directories/buyer-directory.asp" class="sublink"><font color="#000000">Buyers Directory</font></a> | <a style="text-decoration: none;" href="/profile/directory/editmyprofile.asp" class="sublink"><font color="#000000">Add Company Profile</font></a>'
document.getElementById('span1').innerHTML=submenu

}
function validate()
{
	if(document.search1.txtSearch.value=="")
	{
		alert("Please enter the search keyword");
		document.search1.txtSearch.focus();
		return false;
	}
	return true;
}
function getOpt(selObject)
{
	if (selObject.options[selObject.selectedIndex].value != "")
	{ 
		location.href="recent_"+selObject.options[selObject.selectedIndex].value+"_1.html";
    }
}
function selchkbox()
{
	if(document.frmpost.chkall.checked== true)
	{
		len=document.frmpost.chkpost.length;
		for(i=0;i<len;i++)
		{
			document.frmpost.chkpost[i].checked=true;	
		}
	}
	else
	{
		len=document.frmpost.chkpost.length;
		for(i=0;i<len;i++)
		{
			document.frmpost.chkpost[i].checked=false;	
		}
	}
}
function listcount()
{
	if(document.getElementById('user_id').value != "")
	{
		if(document.frmpost.addlist.checked == true)
		{
			z=0;
			len=document.frmpost.chkpost.length;
			for(i=0;i<len;i++)
			{
				if(document.frmpost.chkpost[i].checked==true)
				z=1;	
			}
			if(z==0)
			{
				alert('Please select any one product before choose this one');
				return false;
			}
			else if(z==1)
			{
				if(confirm('Are you sure want to add your Lists for selected all?'))
				{
					var a="";
					for(i=0;i<len;i++)
					{
						if (document.frmpost.chkpost[i].checked)
						{
							a=a+document.frmpost.chkpost[i].value+",";
							
						}
					}
					xmlHttp=GetXmlHttpObject();
					if (xmlHttp==null)
					{
					  alert ("Your browser does not support AJAX!");
					  return;
					} 
					var url="/directories/addtolist.asp";
					url=url+"?adlist=add&bizid="+a;
					xmlHttp.onreadystatechange=AddToListState;
					xmlHttp.open("GET",url,true);
					xmlHttp.send(null);
				}
			}			
		}
	}
	else
	{
		if(confirm('Please login to choose this one. Do you want to login now?'))
		location.href='/login.asp';
	}
}
function AddToListState() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		alert('Product Successfully Inserted');
		len=document.frmpost.chkpost.length;
		for(i=0;i<len;i++)
		{
			if (document.frmpost.chkpost[i].checked)
			{
				document.frmpost.chkpost[i].checked=false;
			}
		}
		if(document.frmpost.addlist.checked == true)
		{
			document.frmpost.addlist.checked=false;
		}
	}
}
function GetXmlHttpObject()
{
	var 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 sendquery()
{
	
	z=0;
	var a;
	len=document.frmpost.chkpost.length;
	for(i=0;i<len;i++)
	{
		if(document.frmpost.chkpost[i].checked==true)
		z=1;
	}
	if(z==0)
	{
		alert('Please select any one product before choose this one');
		return false;
	}
	else if(z==1)
	{
		if(confirm('Are you sure want to send enquiry for selected all?'))
		{
			for(i=0;i<len;i++)
			{
				if (document.frmpost.chkpost[i].checked)
				{
					if (a==undefined)
					{
						a=document.frmpost.chkpost[i].value;
					}
					else
					{
						a=a+","+document.frmpost.chkpost[i].value;
					}
				}
			}
			
			location.href="/profile/contact-owner.asp?protype=directory&chkpost="+a;	
		}
	}
}				
var a
function addBasket()
{
	if(document.getElementById('user_id').value != "")
	{
		z=0;
		len=document.frmpost.chkpost.length;
		for(i=0;i<len;i++)
		{
			if(document.frmpost.chkpost[i].checked==true)
			z=1;	
		}
		if(z==0)
		{
			alert('Please select any one product before choose this one');
			return false;
		}
		else if(z==1)
		{
			if(confirm('Are you sure want to add your Lists for selected all?'))
			{
				var a="";
				bizid="";
				for(i=0;i<len;i++)
				{
					if (document.frmpost.chkpost[i].checked)
					{
						a=a+document.frmpost.chkpost[i].value+",";
					}
				}
				xmlHttp=GetXmlHttpObject();
				if (xmlHttp==null)
				{
				  alert ("Your browser does not support AJAX!");
				  return;
				} 
				var url="/directories/addtolist.asp";
				url=url+"?adbasket=add&bizid="+a;
				//alert(url);
				xmlHttp.onreadystatechange=AddToListState;
				xmlHttp.open("GET",url,true);
				xmlHttp.send(null);
			}
		}
	}			
	else
	{
		if(confirm('Please login to choose this one. Do you want to login now?'))
		location.href='/login.asp';
	}	
}
function openBasket()
{
	if(document.getElementById('user_id').value != "")
		location.href="/directories/ViewBasket.asp";
	else
	{
		if(confirm('Please login to choose this one. Do you want to login now?'))
		location.href='/login.asp';
	}
}
function buyer_validate()
{
	var off_type=document.getElementById('biz_id').value;
	var trust_type=document.getElementById('trust_id').value;
	var login_type=document.getElementById('user_id').value;
	if(trust_type==0 && (off_type=='buy' || off_type=='all'))
	{
		if(login_type=="")
		{
			if(confirm('Only allactiontrade member can access this. Do you want to login now?'))
			{
				location.href='/login.asp';
				return false;
			}
			else
			{
				return false;
			}
		}
		else
		{
			if(confirm('Only Verified member can contact this product. Do you want upgrade your membership?'))
			{
				location.href='/profile/marketing/glossary/membership.asp?premium=trust';
				return false;
			}
			else
			{
				return false;
			}
		}
	}
}
