
//var Categories= new Array("Spa &amp; Wellness","Shopping Experiences","Performing Arts","Sedan and Limousines");			
var Categories= new Array("Private Dining Reservations","New York Broadway Tickets","Health Club Access","Golf Tee Times");	
//var CategoriesID= new Array(4,23,21,22,24);
var CategoriesID= new Array('30','22','33','31');
var CityCodeByCategoryH=new Array(4);
var CityCodeByCategoryV=new Array(4);
//Only "Premium Seating" in array check box is index 1
//Cities:Chicago,Las Vegas, Los Angeles, New York
CityCodeByCategoryH[3]=",1134";
//Only "Shopping Experiences" in array check box is index 6
//Cities:Atlanta,Boston,Chicago,Dallas,Las Vegas,Los Angeles,Miami,New York,Phoenix,San Diego,San Francisco,Seattle,Washington DC 
//CityCodeByCategoryH[6]=",96,201,312,383,879,928,1028,1134,1253,1423,1424,1479,1752";

//Only "Premium Seating" in array check box is index 4
//Cities:Chicago,Las Vegas, Los Angeles, New York
CityCodeByCategoryV[1]=",1134";
//Only "Shopping Experiences" in array check box is index 3
//Cities:Atlanta,Boston,Chicago,Dallas,Las Vegas,Los Angeles,Miami,New York,Phoenix,San Diego,San Francisco,Seattle,Washington DC 
//CityCodeByCategoryV[3]=",96,201,312,383,879,928,1028,1134,1253,1423,1424,1479,1752";

var TotalCategories=CategoriesID.length; 
var SelectedCategories=0;
var SelectedCategoryIndex=-1;
function SetOnClick(obj_id)
{

	var checkBoxes=document.getElementById(preFix + obj_id).getElementsByTagName('input');					
	for(i=0;i<checkBoxes.length;i++)
	{	
		if(checkBoxes[i].checked)
			SelectedCategories++;
			
		checkBoxes[i].onclick=new Function("SetCategoryMenu(this);SetCityByCategoryH(this.checked," + i.toString() + ")");
	}
}
function SetOnClick2(obj_id)
{
	var checkBoxes=document.getElementById(preFix + obj_id).getElementsByTagName('input');					
	for(i=0;i<checkBoxes.length;i++)
	{	
		if(checkBoxes[i].checked)
		{	SelectedCategoryIndex=i;
			SelectedCategories++;
		}
			
		checkBoxes[i].onclick=new Function("SetCategoryMenu(this);SetCityByCategoryV(this.checked," + i.toString() + ")");
	}
	
	if(SelectedCategories==1)
	{
		SetCityByCategoryV(checkBoxes[SelectedCategoryIndex].checked,SelectedCategoryIndex);
	}
}
var auxOptions=new Array();
var isLoading=true;
//set city by selected category
function SetCityByCategoryH(checked,index)
{
	var obj=document.getElementById(preFix + 'ddlcity');	
	var valid=false;
	var i=0;
	var j=1;
	
	var checkBoxes=document.getElementById(preFix + 'chkListCategories').getElementsByTagName('input');					
	SelectedCategories=0;
	for(i=0;i<checkBoxes.length && SelectedCategories<2;i++){	
		if(checkBoxes[i].checked){
			SelectedCategories++;	
			index=i;
		}
	}
	
	if(isLoading){		
		for(i=1;i<obj.options.length;i++)		
			auxOptions[i-1]=obj.options[i]; 					
	}
	
	if(SelectedCategories==1 && typeof CityCodeByCategoryH[index]!='undefined'){   	
        valid=true;
	    obj.options.length=1;	
	    for(i=1;i<=auxOptions.length;i++){		
		    if(CityCodeByCategoryH[index].indexOf(',' + auxOptions[i-1].value)!=-1){
			    obj.options[j]= auxOptions[i-1];
			    j++;
		    }	
	    }
	}
	else if(obj.options.length!=auxOptions.length+1){
		obj.options.length=1;
		for(i=1;i<=auxOptions.length;i++)
		{
			obj.options[i]= auxOptions[i-1];		
		}
	}		
	isLoading=false;	
}

function SetCityByCategoryV(checked,index)
{
	var obj=document.getElementById(preFix + 'ddlcity');	
	var valid=false;
	var i=0;
	var j=1;
	
	var checkBoxes=document.getElementById(preFix + 'chkListCategories').getElementsByTagName('input');					
	SelectedCategories=0;
	for(i=0;i<checkBoxes.length && SelectedCategories<2;i++){	
		if(checkBoxes[i].checked){
			SelectedCategories++;	
			index=i;
		}
	}
	if(isLoading){		
		for(i=1;i<obj.options.length;i++)
			auxOptions[i-1]=obj.options[i]; 					
	}
	if(SelectedCategories==1 && typeof CityCodeByCategoryV[index]!='undefined'){  
        valid=true;
	    var selectValue=obj.value;
	    obj.options.length=1;			
	    for(i=1;i<=auxOptions.length;i++){		
		    if(CityCodeByCategoryV[index].indexOf(',' + auxOptions[i-1].value)!=-1){
			    obj.options[j]= auxOptions[i-1];
			    if(selectValue==auxOptions[i-1].value)
				    obj.options[j].selected=true;
			    j++;				
		    }	
	    }     	
	}
	else if(obj.options.length!=auxOptions.length+1)
	{
		obj.options.length=1;
		for(i=1;i<=auxOptions.length;i++)
		{
			obj.options[i]= auxOptions[i-1];		
		}
	}		
	isLoading=false;	
}

function setAll(objid)
{	var i=0;
    
    var hasSelectedCategory=(typeof selectedCategoryIndex!="undefined")?selectedCategoryIndex:'-1'; //Selected Category in Home Search var defined in QuickSearch2
    //alert(hasSelectedCategory);
	if(document.getElementById(objid).checked)
	{
		while(document.getElementById(preFixCat + i)!=null)
		{	document.getElementById(preFixCat + i).checked=true; 
			i++;
		}
	}
	else
	{
		while(document.getElementById(preFixCat + i)!=null)
		{	
			if(hasSelectedCategory!=i)			
				document.getElementById(preFixCat + i).checked=false; 
			i++;
		}
	} 
}

function QuickSearching()
{ var i=0;
var numCat=0;
var nameCat="";
var IDCat;
var strXMLCategories="#SearchResultsByCity?#QueryParameter?";

var objtxtidlistcategory=document.getElementById('qck_idlistcategory');
			
var objtxtnamecategory=document.getElementById('qck_namecategory');
var objtxtcitycode=document.getElementById('qck_citycode');
var objtxtfromdate=document.getElementById('qck_fromdate');
var objtxttodate=document.getElementById('qck_todate');
var objtxtcityname=document.getElementById('qck_namecity');
	
var objselectcity=document.getElementById(preFix + 'ddlcity');

						
if(objselectcity.selectedIndex==0)
{	alert("Please select city.");
	objselectcity.focus();
	return false;
}

objtxtcityname.value=objselectcity.options[objselectcity.selectedIndex].text;
objtxtfromdate.value=document.getElementById(preFix + 'txtdatefrom_txtdate').value;
objtxttodate.value=document.getElementById(preFix + 'txtdateto_txtdate').value;

strXMLCategories +="#DateFrom?" + objtxtfromdate.value + " 00:00" + "#/DateFrom?";
strXMLCategories +="#DateTo?" + objtxttodate.value + " 23:59" + "#/DateTo?";
strXMLCategories +="#City?" + objselectcity.value + "#/City?";
strXMLCategories +="#CategoryList?" 
if(document.getElementById(preFix + "chkAllCategories").checked)
{
	for(i=0;CategoriesID.length>i;i++)
		strXMLCategories +="#Category code=\"" + CategoriesID[i] + "\" /?"; 			
		
	numCat=CategoriesID.length;	
}
else
{
	while(document.getElementById(preFixCat + i)!=null)
	{	
		if(document.getElementById(preFixCat + i).checked) 
		{	strXMLCategories +="#Category code=\"" + CategoriesID[i] + "\" /?"; 			
			nameCat=Categories[i];
			IDCat=CategoriesID[i];
			numCat++;
		}
				
		i++;	
	}
}
strXMLCategories +="#/CategoryList?" 
strXMLCategories +="#/QueryParameter?#/SearchResultsByCity?";

if(numCat==0)
{	alert("Please select category.");				
	return false;
}

objtxtidlistcategory.value=strXMLCategories;
//alert(objtxtidlistcategory.value);

objtxtcitycode.value=objselectcity.options[objselectcity.selectedIndex].value;
if(numCat==1)
{	if(IDCat!=22){	
	    objtxtnamecategory.value=nameCat;
		objtxtidlistcategory.value=IDCat;
	}
	else{
	    window.location.href='http://iseatz.mastercard.com/world/iseatz_priceless_results_events.aspx?sdate='+objtxtfromdate.value+'&edate='+objtxttodate.value+'&stateid=70,NY&cityn=&key=Broadway&type=2'; 
	    return false; 
	}
}

return true;
	
}

