/**
 * @author Ismael Burciaga
 */

// no conflicts with other frameworks
var $j = jQuery.noConflict();

$j(function() 
{
	
		//fix png transparency in IE<6
		$j('img[@src$=.png]').ifixpng();

		$j("a.fancybox").fancybox({
			'zoomSpeedIn': 300,
			'zoomSpeedOut': 300,
			'imageScale': false,
			'centerOnScroll': false,
		});
		
		// tooltips on class=gbt_tooltip
		$j(".gbt_tooltip").tooltip({
			track: true, 
		    delay: 0, 
		    showURL: false, 
		    showBody: " - ", 
		    fade: 250,
			top: 15,
			left: 15
		});
		
		$j(".form_right_column input, .form_right_column textarea").focus(function() {
			$j(this)
				.parent()
					.addClass("curFocus")
				.children("div")
					.toggle();
		});
		$j(".form_right_column input, .form_right_column textarea").blur(function() {
			$j(this)
				.parent()
					.removeClass("curFocus")
				.children("div")
					.toggle();
		});
		
		/* options can be found within the plugin js */
		$j.fn.HoverImageText.defaults.AnimShow = {height: "show"};
		$j('.featured_stories a, .listing_images a').HoverImageText();
		
		$j('.big_text_field').click(function() {
            if (this.value == this.defaultValue) {
                this.value = '';
            }
        });
        
        $j('.big_text_field').blur(function() {
            if (this.value == '') {
                this.value = this.defaultValue;
            }
        });
	
		
});

/*
Clear default form value script- by JavaScriptKit.com
Featured on JavaScript Kit (http://javascriptkit.com)
Visit javascriptkit.com for 400+ free scripts!
*/

function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
} 


/*****************************************************************************************
 *
 *                           General helper functions
 *
 *****************************************************************************************/

/**
 * Extend the String object so that we can use the trim() function like; sVar.trim();
 *
 *     var first_name = "Chris ";
 *     first_name = first_name.trim();
 *
 * @return string
 */
String.prototype.trim = function() {
  var a = this.replace(/^\s+/, '');
  return a.replace(/\s+$/, '');
};

/**
 * Write an email address to the screen. Helps so that bots can't parse email addresses from the site.
 *
 *     writeEmail("info", "info", "churchmedia.cc");
 *
 * @param string
 * @param string
 * @param string
 */
function writeEmail(contact, email, emailHost) {
  document.write("<a href=" + "&#109a&#105l" + "&#116&#111:" + email + "@" + emailHost+ ">" + contact + "@" + emailHost+"</a>");
}
