// JavaScript Document
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadimages_new() { //v3.0
  var d=document; if(d.images_new){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadimages_new.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


var e1=0;
var ee1 = 0;
function validateemailtext()
{
if (document.email_form.email.value.length==0)
{
alert("Please enter your email address before you submit");
e1=1;
document.email_form.email.focus();
}
else
{
e1=0;
if ( document.email_form.email.value != "" )
		{
		if ( !ValidateEmail( document.email_form.email.value ) )
			{
				alert( "Invalid Email " + document.email_form.email.value );
				ee1=1;
            document.email_form.email.focus();
            return false;
            }
         else
     ee1=0;
  }
}

}

function ValidateEmail( txtEmail )
	{
		var atCharPresent = false;
		var dotPresent = false;

		for ( var Idx = 0; Idx < txtEmail.length; Idx++ )
		{
			if ( txtEmail.charAt ( Idx ) == '@' )
				atCharPresent = true;
			if ( txtEmail.charAt ( Idx ) == '.' )
				dotPresent = true;
		}

		if ( !atCharPresent || !dotPresent )
			return false;

		return true;
	}


function subemail()
{ 
validateemailtext();
 
if(e1==0 && ee1==0)
{
  document.email_form.href="email/postemail.asp";
  document.email_form.submit();
 }
//return false
}

function subemail1()
{ 
validateemailtext();
if(e1==0 && ee1==0)
{
  document.email_form.href="email/postemail.asp";
  document.email_form.submit();
 }
return false
}






function AddToBasket(isect)
{
	with(document.sForm)
	{
		var d;
		var c = document.getElementById("listContainer");
		d = c.getElementsByTagName("input");
		var q = "";
		var cats = document.getElementById("hidCat");
		var curPage = document.getElementById("hidCurrentPage");

		for(i=0;i<d.length;i++)
		{
			if(d[i].type=="checkbox")
			{
				if(d[i].checked)
					q += "-" + d[i].value;
			}
		}
		
		if(q.length > 0)
			window.location = "http://travel.nanjilonline.com/inquiry/AddToBasket.aspx?id=" + q + "&isect=" + isect + "&comeback=" + curPage.value;
		else
		{
			if(isect == 1)
				alert("Please Select one or more Companies.");
			else if(isect == 2)
				alert("Please Select one or more Sell Offers.");
			else if(isect == 3)
				alert("Please Select one or more Buy Offers.");

			return false;
		}

	}
	return false;
}


function AddToBasketSingle(isect)
{
	with(document.sForm)
	{
		var d;
		var cats = document.getElementById("hidCat"); //It contains the ID

		window.location = "http://travel.nanjilonline.com/inquiry/AddToBasket.aspx?id=-" + cats.value + "&cat=" + cats.value + "&isect=" + isect;
	}
	return false;
}






function InquireNow(isect)
{
	with(document.sForm)
	{
		var d;
		var c = document.getElementById("listContainer");
		d = c.getElementsByTagName("input");
		var q = "";

		for(i=0;i<d.length;i++)
		{
			if(d[i].type=="checkbox")
			{
				if(d[i].checked)
					q += "-" + d[i].value;
			}
		}


		if(q.length > 0)
		{
			if(isect == 1)
				window.location = "http://travel.nanjilonline.com/minisite/enquiry.aspx?inqitems=" + q;
			else if(isect == 2)
				window.location = "http://travel.nanjilonline.com/sell/contact_online.aspx?inqitems=" + q;
			else if(isect == 3)
				window.location = "http://travel.nanjilonline.com/buy/contact_online.aspx?inqitems=" + q;	
		}
		else
		{
			if(isect == 1)
				alert("Please Select one or more Companies.");
			else if(isect == 2)
				alert("Please Select one or more Sell Offers.");
			else if(isect == 3)
				alert("Please Select one or more Buy Offers.");

			return false;
		}
		
		
	}
	return false;
}


function InquireNowSingle(isect)
{
	with(document.sForm)
	{
		var d;
		var cats = document.getElementById("hidCat"); //It contains the ID

		if(isect == 1)
			window.location = "http://travel.nanjilonline.com/minisite/enquiry.aspx?inqitems=-" + cats.value;
		else if(isect == 2)
			window.location = "http://travel.nanjilonline.com/sell/contact_online.aspx?inqitems=-" + cats.value;
		else if(isect == 3)
			window.location = "http://travel.nanjilonline.com/buy/contact_online.aspx?inqitems=-" + cats.value;	
	}
	return false;
}



function InquireNowFromBasket(container, isect)
{
	with(document.sForm)
	{
		var d;
		var c = document.getElementById(container);
		d = c.getElementsByTagName("input");
		var q = "";

		for(i=0;i<d.length;i++)
		{
			if(d[i].type=="checkbox")
			{
				if(d[i].checked)
					q += "-" + d[i].value;
			}
		}

		if(q.length > 0)
		{
			if(isect == 1)
				window.location = "http://travel.nanjilonline.com/minisite/enquiry.aspx?inqitems=" + q;
			else if(isect == 2)
				window.location = "http://travel.nanjilonline.com/sell/contact_online.aspx?inqitems=" + q;
			else if(isect == 3)
				window.location = "http://travel.nanjilonline.com/buy/contact_online.aspx?inqitems=" + q;	
		}
		else
		{
			if(isect == 1)
				alert("Please Select one or more Companies.");
			else if(isect == 2)
				alert("Please Select one or more Sell Offers.");
			else if(isect == 3)
				alert("Please Select one or more Buy Offers.");

			return false;
		}
		
		
	}
	return false;
}






function checkboxes(cond)
{
	with(document.sForm)
	{
		var d;
		d=document.getElementsByTagName("input");

		for(i=0;i<d.length;i++)
		{
			if(d[i].type=="checkbox")
			{
				if(cond)
					d[i].checked=true;
				else
					d[i].checked=false;
			}
		}

	}
}



function checkSelected(sect)
{
	with(document.sForm)
	{
		var d, ret;
		d=document.getElementsByTagName("input");
		ret=0;

		for(i=0;i<d.length;i++)
		{
			if(d[i].type=="checkbox")
			{
				if(d[i].checked)
					ret+=1;
			}
		}
		
		if(ret > 0)
			return true;
		else
		{
			if(sect == 1)
				alert("Please Select one or more Companies to Inquire.");
			else if(sect == 2)
				alert("Please Select one or more Sell Offers to Inquire.");
			else if(sect == 3)
				alert("Please Select one or more Buy Offers to Inquire.");

			return false;
		}
		
		return ret>0;
	}
}


function checktoggle()
{
	with(document.sForm)
	{
		var d, c;
		d=document.getElementsByTagName("input");
		c=document.sForm.chktoggle;
		
			if(c.checked)
			{
				for(i=0;i<d.length;i++)
				{
					if(d[i].type=="checkbox")
					{
						d[i].checked=true;
					}
				}
			}
			
			else
			{
				for(i=0;i<d.length;i++)
				{
					if(d[i].type=="checkbox")
					{
						d[i].checked=false;
					}
				}
			}
	}
}




function MyPageCheckItems(container, cond)
{
	with(document.sForm)
	{
		var d;
		var c = document.getElementById(container);
		d = c.getElementsByTagName("input");

		for(i=0;i<d.length;i++)
		{
			if(d[i].type=="checkbox")
			{
				if(cond)
					d[i].checked=true;
				else
					d[i].checked=false;
			}
		}

	}
}




function checkSearchVal(container)
{
	var c = document.getElementById(container);
	
	if(c.q.value == "")
	{
		alert("Please enter some text to search");
		c.q.focus();
		return false;
	}
	else
	{
		return true;
	}
}


function checkPhone(container)
{
	var c = document.getElementById(container);
	
	if(c.q.value != "" && c.q.value.indexOf('-')==2 && c.q.value.length==10)
	{
		return true;
	}
	else
	{
		alert("Please enter a valid phone number in the format: 04-3964566");
		c.q.focus();
		return false;
	}
}






function ShowOther() 
{
	if(document.getElementById) 
	{
		var oth = document.getElementById("oth").style;
		
		if(document.getElementById("ddlCustomCat").value == "ADD Category") 
		{
			oth.display = "inline"; 
		}
		else 
		{
			oth.display = "none";	
		}
	} 
}




function ShowContent(enqForm) 
{
	if(document.getElementById) 
	{
		document.getElementById(enqForm).style.display = "block";
	} 
}








function advancedSearch()
{
	if(document.getElementById) 
	{
		var search = document.getElementById("ddlSearch");
		var keyword = document.getElementById("key");
		var city = document.getElementById("searchCity");
		var category = document.getElementById("Category");
		var make = document.getElementById("make");
		var model = document.getElementById("model");
		var priceMin = document.getElementById("priceMin");
		var priceMax = document.getElementById("priceMax");
		
		category.value = category.value.replace(/&/, "_-_");
		
		if(search.value == "companies")
			location.href = "http://travel.nanjilonline.com/companies/search.aspx?incat="+ category.value +"&city="+ city.value + "&q="+ keyword.value;

		else if(search.value == "products")
			location.href = "http://travel.nanjilonline.com/products/search.aspx?incat="+ category.value +"&make="+ make.value +"&model="+ model.value +"&priceMin="+ priceMin.value +"&priceMax="+ priceMax.value +"&q="+ keyword.value;

		else if(search.value == "services")
			location.href = "http://travel.nanjilonline.com/services/search.aspx?incat="+ category.value +"&make="+ make.value +"&model="+ model.value +"&priceMin="+ priceMin.value +"&priceMax="+ priceMax.value +"&q="+ keyword.value;

		else if(search.value == "off2sell")
			location.href = "http://travel.nanjilonline.com/sell/search.aspx?incat="+ category.value +"&city="+ city.value + "&q="+ keyword.value;

		else if(search.value == "off2buy")
			location.href = "http://travel.nanjilonline.com/buy/search.aspx?incat="+ category.value +"&city="+ city.value + "&q="+ keyword.value;
		
	} 
}




function changeSearchType()
{
	if(document.getElementById) 
	{
		var search = document.getElementById("ddlSearch");
		var make = document.getElementById("make");
		var model = document.getElementById("model");
		var priceMin = document.getElementById("priceMin");
		var priceMax = document.getElementById("priceMax");
		
		if(search.value == "products")
		{
			make.disabled = false;
			model.disabled = false;
			priceMin.disabled = false;
			priceMax.disabled = false;
			
			make.style.background="#FFFFFF";
			model.style.background="#FFFFFF";
			priceMin.style.background="#FFFFFF";
			priceMax.style.background="#FFFFFF";
		}
		else
		{
			make.disabled = true;
			model.disabled = true;
			priceMin.disabled = true;
			priceMax.disabled = true;
			
			make.style.background="#e6e6e6";
			model.style.background="#e6e6e6";
			priceMin.style.background="#e6e6e6";
			priceMax.style.background="#e6e6e6";
		}
		
	} 
}



function advancedHotelSearch(frmName)
{
	var hForm = document.getElementById(frmName);
	
	if(document.getElementById) 
	{
		var search = hForm.ddlSearch;
		var keyword = hForm.key;
		var city = hForm.searchCity;
		var hotelType = hForm.hotelType;
		var roomType = hForm.roomType;
		var priceMin = hForm.priceMin;
		var priceMax = hForm.priceMax;
		
		if(search.value == "hotelrooms")
			location.href = "http://travel.nanjilonline.com/services/Hotel_search.aspx?hotelType="+ hotelType.value +"&roomType="+ roomType.value + "&city="+ city.value + "&priceMin="+ priceMin.value +"&priceMax="+ priceMax.value +"&q="+ keyword.value;

		else if(search.value == "hotels")
			location.href = "http://travel.nanjilonline.com/companies/Hotel_search.aspx?hotelType="+ hotelType.value +"&city="+ city.value + "&priceMin="+ priceMin.value +"&priceMax="+ priceMax.value +"&q="+ keyword.value;
		
	} 
}




function changeHotelSearchType(frmName)
{
	var hForm = document.getElementById(frmName);
	
	if(document.getElementById) 
	{
		var search = hForm.ddlSearch;
		var roomType = hForm.roomType;
		var priceMin = hForm.priceMin;
		var priceMax = hForm.priceMax;
		
		if(search.value == "hotelrooms")
		{
			roomType.disabled = false;
			priceMin.disabled = false;
			priceMax.disabled = false;
			
			roomType.style.background="#FFFFFF";
			priceMin.style.background="#FFFFFF";
			priceMax.style.background="#FFFFFF";
		}
		else
		{
			roomType.disabled = true;
			priceMin.disabled = true;
			priceMax.disabled = true;
			
			roomType.style.background="#e6e6e6";
			priceMin.style.background="#e6e6e6";
			priceMax.style.background="#e6e6e6";
		}
		
	} 
}

//-->