$('a#slick-show').click(function() {
    $('.slickbox').show('slow');
    return false;
});
  

jQuery(window).bind("load", function() {
	jQuery("div#slider1").codaSlider()
	// jQuery("div#slider2").codaSlider()
	// etc, etc. Beware of cross-linking difficulties if using multiple sliders on one page.
});


function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}


$(document).ready(function() { 

// default settings for modal image link

$("a.fancybox").fancybox({ 

	'hideOnContentClick': true,
	'centerOnScroll': true, 
	'overlayOpacity': .7,
	'padding': 4

}); 
 



function setAccountTypeForSignup() {
	$('#fancy_div').find('#account_type').val(current_account_type);
	
	var options = { 
        target:        '#output1',   // target element(s) to be updated with server response 
        beforeSubmit:  function() {  $('#fancy_div').find('#indicators').show()  },  // pre-submit callback 
        success:       function(response) { 
				$('#fancy_div').find('#indicators').hide();
				
				
				
				if(response.process == false) {
					str = '';
					for(key in response.error_messages) {
						str = str + response.error_messages[key] + "<br>";
					}
					
					$('#fancy_div').find("#error_messages").html(str);
					$('#fancy_div').find("#error_messages").show();
					$('#fancy_div').find("#form_description").hide();
					
					
					
				} else {
					location.href = "/account/confirm/" + current_account_type;
				}
				
		
		
		
	
		},
		type:      	   'post',
		dataType:      'json' 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true        // clear all form fields after successful submit 
        //resetForm: true        // reset the form after successful submit 

        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
    };
	
	$('#fancy_div').find('#signup-form').ajaxForm(options);
	
	//$('#fancy_div').find('#submit').click(function() {
	//	submit_form();
	//	return false;
	//})
}

// custom settings for inline signup form

$("a.fancybox-inline-signup").fancybox({ 
	'hideOnContentClick': false,
	'frameWidth': 650,
	'frameHeight': 370,
	'centerOnScroll': true, 
	'overlayOpacity': .7,
	'padding': 4,
	'callbackOnShow': setAccountTypeForSignup
});


$("a.iframe").fancybox({ 
	'hideOnContentClick': false,
	'frameWidth': 670,
	'frameHeight': 370,
	'centerOnScroll': true, 
	'overlayOpacity': .7,
	'padding': 4
});






// custom settings for inline login form 

$("a.fancybox-inline-login").fancybox({ 

	'hideOnContentClick': false,
	'frameWidth': 360,
	'frameHeight': 200,
	'centerOnScroll': true, 
	'overlayOpacity': .7,
	'padding': 4 

}); 


$("a.fancybox-inline-videos").fancybox({ 

	'hideOnContentClick': false,
	'frameWidth': 640,
	'frameHeight': 480,
	'centerOnScroll': true, 
	'overlayOpacity': .7,
	'padding': 4 

});

$("a.group").fancybox({ 

	'zoomSpeedIn': 300, 
	'zoomSpeedOut': 300, 
	'overlayShow': false, 
	'centerOnScroll': true, 
	'overlayOpacity': .7,
	'padding': 4 
	
}); });

//tooltips

$.fn.qtip.styles.hippostyle = { // Last part is the name of the style
   width: 275,
   background: '#CFE9AA',
   color: '#4f6b34',
   textAlign: 'left',
   border: { width: 3, radius: 6, color: '#A9DC66' },
   tip: 'bottomLeft'
}

// Create the tooltips only on document load
$(document).ready(function() 
{
   // Notice the use of the each() method to acquire access to each elements attributes
   $('a[tooltip]').each(function()
   {
      $(this).qtip({
         content: $(this).attr('tooltip'), // Use the tooltip attribute of the element for the content
         style: 'hippostyle', // custom tooltip style
         position: {
      		corner: {
         		target: 'topRight',
         		tooltip: 'bottomLeft'
      		}
  		 }
      });
   });
});


function set_referral_cookie() {
	if (location.hash.slice(1)) {
		var expires_date = new Date();
		expires_date.setDate(expires_date.getDate() + 30);
		domain = document.domain.split(/\./);
		domain = domain[domain.length-2] + ".com";
		document.cookie = 'promo=' + location.hash.slice(1) + ';domain=.' + domain+ ';expires=' + expires_date.toGMTString() + '; path=/';
	}
}


