window.addEvent('domready', function() {
	
	//create our Accordion instance
	var myAccordion = new Accordion($('accordion'), 'h3.toggler', 'div.element', {
		opacity: false,
		display:-1,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#E5037F'); 
			if(element.getParent().hasClass('why_use_irent')){
				element.setStyle('border-bottom', '5px solid #E5037F'); 
			}
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#575757');
			element.setStyle('border-bottom', 'none'); 
		}
	});
	
	
	
	
	
	//Menu-magic for IE6
	var menuitem = $$('#menu li');

	menuitem.addEvent('mouseenter', function(){
		this.addClass('hover');
	});

	menuitem.addEvent('mouseleave', function(){
		this.removeClass('hover');
	});

	//inform IE6 users about the crapness of their browser
	if(Browser.Engine.trident4){
		goBox() 	
	}
	         
	
});


function appendSuburbs(val){
	var suburbsArry = new Array();
	var found = false;
	
	suburbsArry = ($('listingSuburbs').value).split(",");
	
	for(var i = 0; i < suburbsArry.length; i++){
		if(val == suburbsArry[i]){
			found = true;
		}
	}
	
	if(!found){
		if($('listingSuburbs').value == ""){
			$('listingSuburbs').value = val;
		}else{
			$('listingSuburbs').value += "," + val;
		}
	}
}


function appendPropertyType(val){
	var pTypeArry = new Array();
	var found = false;
	
	pTypeArry = ($('listingPropertyType').value).split(",");
	
	for(var i = 0; i < pTypeArry.length; i++){
		if(val == pTypeArry[i]){
			found = true;
		}
	}
	
	if(!found){
		if($('listingPropertyType').value == ""){
			$('listingPropertyType').value = val;
		}else{
			$('listingPropertyType').value += "," + val;
		}
	}
}


function getOtherOccupantNameFelds(select){
	var num_occupants = select.get('value');
	var html = "";
	var old_first_name;
	var old_surname;
	for(i=1; i<num_occupants; i++){
		if($("other_occupant_first_name_"+i)){
			old_first_name = $("other_occupant_first_name_"+i).get('value'); 
			old_surname = $("other_occupant_surname_"+i).get('value'); 
		}else{
		    old_first_name = "";
		    old_surname = "";
		}
		html += "<label style='width:80px!important'>First Name:</label><input type='text' name='other_occupant_first_name[]' id='other_occupant_first_name_"+i+"' value='"+old_first_name+"'><div class='clear'></div>";
		html += "<label style='width:80px!important'>Surname:</label>  <input type='text' name='other_occupant_surname[]' id='other_occupant_surname_"+i+"'  value='"+old_surname+"'><div class='clear'></div><br />";
	}
	$('other_occupant_names').set('html', html);
}

function goBox(){
	
	var req = new Request({	
		url:'check_session.php', 
		async:'false', 
		onSuccess:  function(responseText){ 
				if(responseText == 'false'){
					SqueezeBox.fromElement('#squeeze_content', {size: {x: 500, y: 250}}); 
				}				
			} 
		}).send();     
	      
}






