/***********************************************
* jQuery functions execute
***********************************************/

jQuery(document).ready(function(){                  
              
	/*cmx form */
	if(jQuery.browser.mozilla) {
		$('form.cmxform').hide().find('label:not(.nocmx)').each(function(){
                          	var $labelContent = $(this).html();
                                       var $labelWidth = $(this).css('width');
                                       $(this).empty();
                                       $(this).append('<span style="display: block; width: '+$labelWidth+';">');
                                       $(this).prepend('</span>');
                                       $(this).css('display', '-moz-inline-box');
                                       $(this).find('span').html($labelContent);
                                       $('form.cmxform').show();
                                });
                };             


	/*external link*/
	$('a[rel*=external]').click( function(){this.target = "_blank";});
	/*slimbox*/
	$('#lbOverlay').css('cursor', 'pointer');
	/*image link*/	
	$("#logo, #logo-text").css('cursor', 'pointer').click( function() { window.location = './';});
	/*email protect*/
	$("span.safermailing").each(function(){
		exp = $(this).text().search(/\((.*?)\)/) != -1 ? new RegExp(/(.*?) \((.*?)\)/) : new RegExp(/.*/);
		match = exp.exec($(this).text());
		addr = match[1] ? match[1].replace(/ at /,"@").replace(/ dot /g,".") : match[0].replace(/ at /,"@").replace(/ dot /g,".");
		link = match[2] ? match[2] : addr;
		subject = $(this).attr('title') ? "?subject="+$(this).attr('title').replace(/ /g,"%20") : "";
		$(this).after('<a href="mailto:'+addr+subject+'">'+ link + '</a>');
		$(this).remove();
	});
	
	/*on focus for input boxes*/
	$.fn.search = function() {
		return this.focus(function() {if( this.value == this.defaultValue ) {this.value = "";}})
		.blur(function() {if( !this.value.length ) {this.value = this.defaultValue;}});};
	$("input#Search_Keyword").search();

	/*accordion navigation - accordion.js + easing.js. + dimension.js*/
	/*simplify version first div always open onload
	$('ul#catalogue-nav').accordion({
			active: false,
			header: '.firstlevel',
			navigation: true,
			event: 'click',
			autoheight: true,
			alwaysOpen: false
		});*/
			
	/*if image cycle
	$('#main-banner').cycle({ 
		fx:     'fade', 
		speed:   500, 
		timeout: 8000, 
		next:   '#main-banner', 
		pause:   1 
	});*/
	
	/*set hover class for anything*/
	$('form.cmxform input.searchnow').css('cursor', 'pointer').hover(function() {$(this).addClass('searchover');}, function() {$(this).removeClass('searchover');});
	$('form.cmxform input.send').css('cursor', 'pointer').hover(function() {$(this).addClass('inputhover');}, function() {$(this).removeClass('inputhover');});
	$('ul#about-listings li').css('cursor', 'pointer').hover(function() {$(this).addClass('iabouthover');}, function() {$(this).removeClass('abouthover');});
	$('ul#about-listings li').click(function(){window.location = $(this).find('a').attr("href");});
	
	/*dimming images on hover*/
	$('.dimmer').css('opacity', '0.4').css('cursor', 'pointer');
	$('.dimmer').hover(function() {$(this).css('opacity', '1.0');}, function() {$(this).css('opacity', '0.4')});
	$('body#contact-page #contact-details').css('opacity', '0.15');
	
	/*ie6 dropdown fix*/
	//$('ul#nav li').hover(function(){$(this).find('ul').slideDown('fast');return false;},function(){$(this).find('ul').slideUp(100);});
	$('ul#nav li').hover(function() {$(this).addClass('over');}, function() {$(this).removeClass('over');});
	$('ul#nav ul').hover(function() {$('.over a').addClass('onsection');}, function() {$('.over a').removeClass('onsection');});
	$('ul#nav li li').hover(function() {$('.over a').addClass('onsection');}, function() {$('.over a').removeClass('onsection');});
		
	//advanced hide and show
	$('ul#services-info li> div.info-section').hide();
	$('ul#services-info li> #firstitem').show();
	$('ul#services-info li> h2').css('cursor', 'pointer').click(function() {
	$(this).next('div').slideToggle('fast')
	.parent().siblings('li').find('div.info-section:visible').slideUp('fast');});
	
	/*$("#EnquiryForm").submit(function() {
      var s1 = 'oscar';
      var s2 = '@';
      var s3 = 'hubcreative.com.au';
      $(this).append('<input type="hidden" name="recipient" value="' + s1 + s2 + s3 + '" />');
    });*/
	
	$("#Mailinglist_Subscription_Form").submit(function() {
      var s1 = 'liz';
      var s2 = '@';
      var s3 = 'midlandvet.com.au';
      $(this).append('<input type="hidden" name="recipient" value="' + s1 + s2 + s3 + '" />');
    });


});

