// JavaScript Document

 function show(id)
{
	el = document.getElementById(id);
	if (el.style.display == 'none')
	{
		el.style.display = '';
		el = document.getElementById('upload' + id);
		el.innerHTML = 'less...';
	} else {
		el.style.display = 'none';
		el = document.getElementById('upload' + id);
		el.innerHTML = '#Popup for upload menu...';
	}
}

 function showmenu(id)
{
	e2 = document.getElementById(id);
	if (e2.style.display == 'none')
	{
		e2.style.display = '';
		e2 = document.getElementById('menu' + id);
		e2.innerHTML = 'less...';
	} else {
		e2.style.display = 'none';
		e2 = document.getElementById('menu' + id);
		e2.innerHTML = '#Popup for menu...';
	}
}

function rental_validation()
{
	if(document.furnished_rentals.LodgingTypeID.value==0)
	{
		alert("Please select type.");
		document.furnished_rentals.LodgingTypeID.focus();
		return false;
	}

	if(document.furnished_rentals.ProximityID.value==0)
	{
		alert("Please select proximity type.");
		document.furnished_rentals.ProximityID.focus();
		return false;
	}

	if(document.furnished_rentals.LodgingPrivacyLevelID.value==0)
	{
		alert("Please select lodging type.");
		document.furnished_rentals.LodgingPrivacyLevelID.focus();
		return false;
	}	
}

function dining_validation()
{
	if(document.getElementById('cuisine').selectedIndex==-1)
	{
		alert("please select cuisine.");
		document.getElementById('cuisine').focus();
		return false;		
	}
	
    var obj = document.dining_category.Aboutus;		
	if (obj.value.length>=500 )
	{
		alert("Characters must be enter upto 500.");
		//document.dining_category.Aboutus.value="";
		document.dining_category.Aboutus.focus="";
		return false;
	}
	
	var obj1 = document.dining_category.AboutFood;		
	if (obj1.value.length >= 500)
	{
		alert("Characters must be enter upto 500.");
		//document.dining_category.AboutFood.value="";
		document.dining_category.AboutFood.focus="";
		return false;
	} 
	
	
	/*--------------------------------------------------*/
	   // check if more than 5 options are selected from Cuisine
		// check if less than 1 options are selected
		var numSelected = 0;
		var i;
		for (i = 0;  i < dining_category.cusine.length;  i++)
		{
		if (dining_category.cusine.options[i].selected)
		numSelected++;
		}
		if (numSelected > 2)
		{
		alert("Please select at most 2 of the \"cusines\" options.");
		dining_category.cusine.focus();
		return (false);
		}
		if (numSelected < 1)
		{
		alert("Please select at least 1 of the \"cusines\" options.");
		dining_category.cusine.focus();
		return (false);
		}
	
    /*--------------------------------------------------*/	
	
	
	/*--------------------------------------------------*/
	   // check if more than 2 options are selected from Alcohol
		// check if less than 1 options are selected
		var numSelected1 = 0;
		var j;
		for (j = 0;  j < dining_category.alcohol.length;  j++)
		{
		if (dining_category.alcohol.options[j].selected)
		numSelected1++;
		}
		if (numSelected1 > 2)
		{
		alert("Please select at most 2 of the \"alcohol\" options.");
		dining_category.alcohol.focus();
		return (false);
		}
		if (numSelected1 < 1)
		{
		alert("Please select at least 1 of the \"alcohol\" options.");
		dining_category.alcohol.focus();
		return (false);
		}
	
    /*--------------------------------------------------*/	
	
	
	return true;
}

 
function viewpage()
{
	//window.location="../profile/dining_category_view.php";
	var pdf = document.getElementById("uplodedpdf");
	//alert (pdf.value);
	window.open(pdf.value ,'mywindow','width=600,height=500,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes, resizable=yes');
}

function homepage()
{
	window.location="../profile/dining_category.php";

}

function check_cuisine()
	   {
		    
			var oRadio = document.dining_category["CuisineID[]"];
			
			//alert(oRadio.length);		
			//alert(oRadio.selectedIndex);
			var cnt = 0;
			for(i=0;i<oRadio.length;i++)
			{				
				if(document.dining_category["CuisineID[]"][i].selected)
				{  
					ind = i;					
					cnt++;
				}				
			if(cnt > 4)
			{
				//alert('You cant select more than 4 cuisines');
				document.dining_category["CuisineID[]"][ind].selected=false;
				//return false;
			}
				
			} 			
			
		
	   }