var Site = {
	
	start: function(){
		// Home page accordian
		if ($('kwick')) Site.parseIndexAccordian();

		// Internet Explorer 6 global PNG fix
		//Site.ie6PNGfix();

		// <input> focus and blurring
		Site.inputTagStyles();

		// Set smooth scrolling for anchor tag links
		new SmoothScroll();
		
		// Nice tooltips
		Site.toolTips();
		
		// Generic rounded DIV's
		Site.genericRoundedDIVs();
		
		// Rounded wizard
		Site.roundedWizardSteps();
		
		// Round highlighted adverts if applicable
		Site.roundedHighlightedAdverts();
	},
	
	parseIndexAccordian: function(){
		var kwicks = $$('#kwick .kwick');
		var fx = new Fx.Elements(kwicks, {wait: false, duration: 200, transition: Fx.Transitions.Back.easeOut});
		kwicks.each(function(kwick, i){
			kwick.addEvent('mouseenter', function(e){
				var obj = {};
				obj[i] = {
					'width': [kwick.getStyle('width').toInt(), 175]
				};
				kwicks.each(function(other, j){
					if (other != kwick){
						var w = other.getStyle('width').toInt();
						if (w != 92) obj[j] = {'width': [w, 92]};
					}
				});
				fx.start(obj);
			});
		});
		
		$('kwick').addEvent('mouseleave', function(e){
			var obj = {};
			kwicks.each(function(other, j){
				obj[j] = {'width': [other.getStyle('width').toInt(), 113]};
			});
			fx.start(obj);
		});
	},
	
	ie6PNGfix: function() {
		if (is_ie6) {
			if (document.all && document.styleSheets && document.styleSheets[0] && document.styleSheets[0].addRule) {
				document.styleSheets[0].addRule('*', 'behavior: url(/css/iepngfix.htc)');
			}	
		}
	},
	
	inputTagStyles: function() {
		var textarea = $ES("textarea");
		var selecta = $ES("select");
		var inputTexts     = $$("input").filterByAttribute("type","=","text");
		var inputButtons   = $$("input").filterByAttribute("type","=","button");
		var inputSubmits   = $$("input").filterByAttribute("type","=","submit");
		var inputPasswords = $$("input").filterByAttribute("type","=","password");

		inputTexts.each(function(theinput, i){
			theinput.className = "input_textbox";
			theinput.addEvent('focus', function(e){
				theinput.style.background = "#cccccc";
				theinput.style.border = "1px solid #33ccff";
				theinput.style.color = "#333333";
			});
			theinput.addEvent('blur', function(e){
				theinput.style.background = "#e5e5e5";
				theinput.style.border = "1px solid #999";
				theinput.style.color = "#333333";
			});
		});
		inputPasswords.each(function(theinput, i){
			theinput.className = "input_password";
			theinput.addEvent('focus', function(e){
				theinput.style.background = "#cccccc";
				theinput.style.border = "1px solid #33ccff";
			});
			theinput.addEvent('blur', function(e){
				theinput.style.background = "#e5e5e5";
				theinput.style.border = "1px solid #999";
			});
		});
		textarea.each(function(theinput, i){
			theinput.className = "input_textbox";
		});
		selecta.each(function(theinput, i){
			theinput.className = "input_textbox";
		});
		inputButtons.each(function(theinput, i){
			theinput.className = "input_button";
		});
		inputSubmits.each(function(theinput, i){
			theinput.className = "input_submit";
		});
	
	},
	
	toolTips: function() {
		var Tips2 = new Tips($$('.tooltip'), {
			initialize:function(){
				this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
			},
			onShow: function(toolTip) {
				this.fx.start(1);
			},
			onHide: function(toolTip) {
				this.fx.start(0);
			}
		});
	},
	
	genericRoundedDIVs: function() {
		var border_setUpParaBox = RUZEE.ShadedBorder.create({ corner:15 });
		border_setUpParaBox.render( $$('.setUpParaBox') );
	},
	
	roundedWizardSteps: function() {
		var border_wizardLeft = RUZEE.ShadedBorder.create({ corner:10, edges: "tbl" });
		border_wizardLeft.render( $$('#firstStep') );
		
		var border_wizardRight = RUZEE.ShadedBorder.create({ corner:10, edges: "tbr" });
		border_wizardRight.render( $$('#lastStep') );
	},
	
	roundedHighlightedAdverts: function() {
		var border_highlightedAdverts = RUZEE.ShadedBorder.create({ corner:10, border:1 });
		border_highlightedAdverts.render( $$('.searchResultRow_Highlighted') );
		border_highlightedAdverts.render( $$('.searchResultRow_Highlighted_Last') );
	}
	
};

window.addEvent('domready', Site.start);






