// Advanced Search Collapse
var d = document;
var go;

// Hide onLoad Adv Search Container
function hideAdv(contID,formID){
	d.getElementById("equalColumns").style.position = "relative";
	var adv = d.getElementById(contID);
	var advForm = d.getElementById(formID);
	window.q = (adv.className == "bookDet") ? (adv.firstChild.offsetHeight - 2) : (adv.firstChild.offsetHeight - 1);
	window.h = adv.offsetHeight;
	if(adv){
		with(adv.style){
			height = window.q + "px";
			display = "none";
			visibility = "visible";
			width = 500 + "px";
		};
		if(adv.className == "bookDet"){advForm.style.display = 'none'};
	}
}

function minHeight(){
	var w = d.getElementById("equalColumns");
	var o = d.getElementById("bookDet");
	if(o && d.getElementById("siteDet")){
		if(o.offsetTop >= d.getElementById("siteDet").offsetTop - 30){
			if(w.offsetHeight < window.b + o.offsetTop){
				w.style.height = window.b + o.offsetTop + "px";
			}else{
				w.style.height = "auto";
			}
		}
	}else{
		if(w.offsetHeight < window.h + 30){
			w.style.height = window.h + 101+ "px";
		}else{
			w.style.height = "auto";	
		}
	}
}

// Open/Hide Adv Search onClick
function openAdv(contID,formID){
	var adv = d.getElementById(contID);
	var advForm = d.getElementById(formID);	
	if(adv.style.display != "block"){
		adv.style.display = "block";
		if(contID != "tarDet" && contID != "venueDet"){
			minHeight();
		};
		show(adv,advForm);
	}else{
		window.clearTimeout(go);
		hide(adv,advForm);
	}	
}

// Show Adv Search Container
function show(adv,advForm){
	if(adv.id == "advSearch"){		 
		with(d.getElementById("basicVenueSearchPicker").style){
			display = "none";
			position = "absolute";
			left = - 2000 + "px";
		}
		d.getElementById("featuresPicker").style.display = "none";
	}
	var plus = true;
	var x = adv.offsetHeight;
	var y = adv.offsetWidth;
	var lowV = (Browser.isIe7) ? 18 : 2;
	if(y < 900){
		goAnim(adv,advForm,y,40,plus);
	}else if(y < 958){		
		goAnim(adv,advForm,y,4,plus);
	}else if(adv.className != "bookDet" && x < 340){
			adv.style.width = 958 + "px";
			if(advForm.className != "blockC"){advForm.className = "blockC"};
			goAnim(adv,advForm,x,18,plus);
	}else if(adv.className == "bookDet" && x < 400){			
			if(advForm.style.display != 'block'){
				adv.style.width = 958 + "px";
				advForm.style.display = 'block';
			}
			goAnim(adv,advForm,x,18,plus)
	}else if(adv.className != "bookDet" && x < 382){
			goAnim(adv,advForm,x,lowV,plus);
	}else if(adv.className == "bookDet" && x < (advForm.offsetHeight + advForm.offsetTop)){
			goAnim(adv,advForm,x,lowV,plus);
	}else{
		if(adv.id == "advSearch"){		 
			with(d.getElementById("basicVenueSearchPicker").style){
				display = "block";
				position = "static";
				left = "auto";
			}
			d.getElementById("featuresPicker").style.display = "block";
		}
		if(adv.className == "bookDet"){
			adv.style.height = "auto";
			layerBg();
		}
	}
}

function layerBg(){
		 	var layDiv = d.createElement("DIV");
			layDiv.id = "layer";
			d.getElementById("equalColumns").appendChild(layDiv);
			d.getElementById("layer").style.display="block";
			d.getElementById("layer").style.height = d.getElementById("equalColumns").offsetHeight + "px";
			if(Browser.isIe && d.getElementById("siteCalendarDivId")){
				var sel = d.getElementById("siteCalendarDivId").getElementsByTagName("SELECT");
				if(sel){
					for(var i =0; i < sel.length; i++){
						if(sel[i].className == "ui-calendar-navigation-sel") sel[i].style.visibility = "hidden";
					}
				}
			}
}

// Hide Adv Search Container
function hide(adv,advForm){
	if(adv.id == "advSearch"){
		with(d.getElementById("basicVenueSearchPicker").style){
			display = "none";
			position = "absolute";
			left = - 2000 + "px";
		}
		d.getElementById("featuresPicker").style.display = "none";
	}
	var x = adv.offsetHeight;
	var y = adv.offsetWidth;
		if(x > 40){
			goAnim(adv,advForm,x,18);
		}else if(adv.className != "bookDet" && y > 320){
			adv.style.height = window.q + 'px';
			if(advForm.className == "blockC"){advForm.className = "noneC"};
			goAnim(adv,advForm,y,30);
		}else if(adv.className == "bookDet" && y > 110){
			adv.style.height = window.q + 'px';
			advForm.style.display = 'none';
			goAnim(adv,advForm,y,30);
		}else{
			minHeight();
			adv.style.display = 'none';
			if(d.getElementById("tarDet") && d.getElementById("layer")){
				d.getElementById("layer").style.display="none"
				if(Browser.isIe && d.getElementById("siteCalendarDivId")){
				var sel = document.getElementById("siteCalendarDivId").getElementsByTagName("SELECT");
				if(sel){
					for(var i =0; i < sel.length; i++){
						if(sel[i].className == "ui-calendar-navigation-sel") sel[i].style.visibility = "visible";
					}
				}
			}
			};
		};	
}

// TimeOut Animation
function goAnim(adv,x,property,step,action){
		if(action == true){
			if(property == adv.offsetWidth){
				adv.style.width =  property + step + 'px';
			}else{
				adv.style.height =  property + step + 'px';
			}
			go = window.setTimeout(function(){show(adv,x)},10);
		}else{
			if(property == adv.offsetWidth){
				adv.style.width =  property - step + 'px';
			}else{
				adv.style.height =  property - step + 'px';
			}		
			go = window.setTimeout(function(){hide(adv,x)},10);
		}
}

// Search Field Disabled
	function getDisDiv(mark){
		var n = mark;
		while(n.nodeName != "DIV" && n.className != "disableDiv"){
			n = n.nextSibling;
		}	
		return n;
	}
	
	function disableFields(){
		var inp1 = d.getElementById("abc");
		var inp2 = d.getElementById("famele");
		var inp3 = d.getElementById("item06");
		var er = [inp1, inp2, inp3];
			for(var i = 0; i < er.length; i++){
			if(er[i].checked == true){
				var n = getDisDiv(er[i]);
				n.style.display = "none";
			}
		}
	}

	function disableNode(mark){
		var n = getDisDiv(mark);
		if(mark.checked == true){
			n.style.display = "none";
		} else {
			n.style.display = "block";	
		}
}
	function disableLoc(){
		
}