// PropertyDrive global mootools functions
window.addEvent('domready', function() {
	//store titles and text  
    $$('.mootips').each(function(element,index) {  
    	var content = element.get('title').split('::');  
        element.store('tip:title', content[0]);  
        element.store('tip:text', content[1]);  
    });  
	
	// creating tips      
	var myTips = new Tips($$('.mootips'), {
		className: 'tipwrap',
		fixed: 'true',
		onShow: function(tip) {
			tip.set('opacity', 0);
			tip.fade('in');
		},
		onHide: function(tip) {
			tip.fade('out');
		}
	});	
	
	// home page gallery
	if ($('home_gallery')) {
		new SimpleCarousel($('home_gallery'), $$('#home_gallery li'), '', {
			slideInterval: 5000
		});
	}
	
	// Image hover function	
	$$('.ro').each(function(el, i) {
		var ExampleFx = new Fx.Tween(el, { 
		wait: false,
		duration: 600,
		transition: Fx.Transitions.linear});
			el.addEvent('mouseenter', function() { ExampleFx.start('opacity', 1, 0.01); });
			el.addEvent('mouseleave', function() { ExampleFx.start('opacity', 0.01, 1); });
	});		

	// badge drag and elastic effect.
	var fx = new Fx.Morph($('Badge'), {duration: 1000, transition: Fx.Transitions.Elastic.easeOut, wait: false});
	new Drag($('Badge'), {	 
		onComplete: function(el){
			fx.start({
				'left': '700px',
				'top': '60px'
			});
		}
	});

	// Sponsor banner
	$$('.sponsor .by').each(function(element) {
		var fx = new Fx.Tween(element, {duration:200, wait:false});
		element.addEvent('mouseenter', function(){
			fx.start('width','90');
		});
	 
		element.addEvent('mouseleave', function(){
			fx.start('width','13');
		});
	});

	// Submit Nav Toggler 
	if ($('submitNav')) {
		var navSlide = new Fx.Slide('submitNav').hide();
	}
	
	if ($('submitClick')) {
		$('submitClick').addEvent('click', function(e){
			e = new Event(e);
			navSlide.toggle();
			e.stop();
		});
	}
}); 

function splitEmail(username, hostname) {
	var linktext = username + "@" + hostname;
	document.write("<a href=" + "mail" + "to:" + username + "@" + hostname + ">" + linktext + "</" + "a>");
}

function set_default_form_button(event, el) {
    var key = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    if (key == 13) {
        event.returnValue = false;
        event.cancel = true;
        $(el).click();
    }
}

