function loop(banner, image) {
	if (image == 5) {
		image = 1;
	} else {
		image++;
	}
	$('homebanner'+banner).src = 'images/home'+image+'.jpg';
	return image;
}

function fade(toggle, opacity, image) {
	$('homebanner2').style.visibility = 'visible';
	if (toggle == 0) {
		if (opacity >= 0) {
			setOpacity('homebanner2', opacity);
			opacity = opacity-1;
			setTimeout('fade(0, '+(opacity)+', '+image+')', 10);
		} else {
			image = loop(2, image);
			setTimeout('fade(1, 0, '+image+')', 10000);
		}
	}
	if (toggle == 1) {
		if (opacity <= 100) {
			setOpacity('homebanner2', opacity);
			opacity = opacity+1;
			setTimeout('fade(1, '+(opacity)+', '+image+')', 10);
		} else {
			image = loop(1, image);
			setTimeout('fade(0, 100, '+image+')', 10000);
		}
	}
}

function home_nav(id) {
	selections = new Array('popular', 'hotels', 'tours', 'flights', 'rentals', 'sailing', 'specials', 'lastminute');
	for (i = 0; i < selections.length; i++) {
		$('h_'+selections[i]).style.display = 'none';
		$('t_'+selections[i]).className = '';
	}
	/*$('t_specials').className = 'specials';
	$('t_lastminute').className = 'lastminute';	*/
	$('h_'+id).style.display = '';
	$('t_'+id).className = 'active';
}

function home_search(type, page, input) {
	$('hotels_grid').style.display = 'none';
	if (type) {
		url_type = '&type='+type;	
	} else {
		url_type = '';	
	}
	if (page > 0) {
		url_page = '&page='+page;
		scrollTo(0, 250);
	} else {
		url_page = '';	
	}
	if (input == 'region') {
		if ($('region_hotels').selectedIndex == 0) {
			$('hotels_grid').style.display = 'block';
			$('home_hotels_search').innerHTML = '';
			return false;
		}
		if (type == 'hotels') {
			$('keyword_hotels').value = 'Search by hotel name';
		} else if (type == 'tours') {
			$('keyword_tours').value = 'Search by tour name';
		}
	}
	if (input == 'keyword') {
		if ($('keyword_'+type).value == '') {
			$('hotels_grid').style.display = 'block';
			$('home_hotels_search').innerHTML = '';
			return false;
		}
		$('region_'+type).selectedIndex = 0;
		$('region_'+type).options[0].selected = 0;
		url_keyword = '&keyword='+$('keyword_'+type).value;
	} else {
		url_keyword = '';	
	}

	try {
		if ($('sort_'+type).value) {
			url_sortby = '&sortby='+$('sort_'+type).value;	
		} else {
			url_sortby = '';	
		}
	} catch(e) { url_sortby = ''; }
	try {
		if ($($('region_'+type).value+'_'+type+'_subregion').value) {
			url_subregion = '&subregion='+$($('region_'+type).value+'_'+type+'_subregion').value;	
		} else {
			url_subregion = '&subregion=';
		}
	} catch(e) { url_subregion = '&subregion='; }
	try {
		if ($($('region_'+type).value+'_'+type+'_tourtype').value) {
			url_tourtype = '&tourtype='+$($('region_'+type).value+'_'+type+'_tourtype').value;	
		} else {
			url_tourtype = '&tourtype=';
		}
	} catch(e) { url_tourtype = '&tourtype='; }
	ajax('ajax.php', '?action=search&region='+$('region_'+type).value+url_keyword+url_type+url_page+url_sortby+url_subregion+url_tourtype, 'div', 'home_'+type+'_search');
	return false;
}

function select_region(type, id) {
	$('region_'+type).selectedIndex = id;
	$('region_'+type).options[id].selected = true;
	home_search(type, 0, 'region')
}

function home_map(type) {
	$('region_'+type).selectedIndex = 0;
	$('region_'+type).options[0].selected = true;
	home_search(type, 0, 'region')
}

function keyword_focus(type) {
	if (type == 'hotels') {
		if ($('keyword_hotels').value == 'Search by hotel name') {
			$('keyword_hotels').style.fontStyle = 'normal';
			$('keyword_hotels').style.color = '#000000';
			$('keyword_hotels').value = '';
		}
	} else if (type == 'tours') {
		if ($('keyword_tours').value == 'Search by tour name') {
			$('keyword_tours').style.fontStyle = 'normal';
			$('keyword_tours').style.color = '#000000';
			$('keyword_tours').value = '';	
		}
	}
}
function keyword_blur(type) {
	if (type == 'hotels') {
		if ($('keyword_hotels').value == '') {
			$('keyword_hotels').style.fontStyle = 'italic';
			$('keyword_hotels').style.color = '#999999';
			$('keyword_hotels').value = 'Search by hotel name';	
		}
	} else if (type == 'tours') {
		if ($('keyword_tours').value == '') {
			$('keyword_tours').style.fontStyle = 'italic';
			$('keyword_tours').style.color = '#999999';
			$('keyword_tours').value = 'Search by tour name';	
		}
	}
}




























