var catfish_interval, catfish_i;

function loadCatfish() {
	if( typeof( jQuery('#catfish').tcmedia_catfish ) == 'function' ) {
		jQuery('#catfish').tcmedia_catfish( {
			closeLink: '#catfish-close',
			height: 80
		} );
		window.clearInterval( catfish_interval );
	} else {
		
	}
	catfish_i++;
}

function loadPlugin1() {
	var script_tag = document.createElement('script');
    script_tag.setAttribute("type","text/javascript");
    script_tag.setAttribute("src",
      "http://cdn.jquerytools.org/1.2.6/all/jquery.tools.min.js")
    script_tag.onload = loadPlugin2; // Run main() once jQuery has loaded
    script_tag.onreadystatechange = function () { // Same thing but for IE
      if (this.readyState == 'complete' || this.readyState == 'loaded') loadPlugin2();
    }
    document.getElementsByTagName("head")[0].appendChild(script_tag);
}

function loadPlugin2() {
	if( jQuery.browser.msie && jQuery.browser.version.substr(0,1) == 6 ) {
		var script_tag = document.createElement('script');
	    script_tag.setAttribute("type","text/javascript");
	    script_tag.setAttribute("src",
	      "http://www.transcontinentalmedia.com/wp-content/themes/tcm/media/scripts/dd_belatedpng.js")
	    script_tag.onload = loadPlugin3; // Run main() once jQuery has loaded
	    script_tag.onreadystatechange = function () { // Same thing but for IE
	      if (this.readyState == 'complete' || this.readyState == 'loaded') loadPlugin3();
	    }
	    document.getElementsByTagName("head")[0].appendChild(script_tag);
	} else {
		loadPlugin3();
	}
}

function loadPlugin3() {
	var script_tag = document.createElement('script');
    script_tag.setAttribute("type","text/javascript");
    script_tag.setAttribute("src",
      "http://www.transcontinentalmedia.com/wp-content/themes/tcm/media/scripts/catfish.js")
    script_tag.onload = main; // Run main() once jQuery has loaded
    script_tag.onreadystatechange = function () { // Same thing but for IE
      if (this.readyState == 'complete' || this.readyState == 'loaded') main();
    }
    document.getElementsByTagName("head")[0].appendChild(script_tag);
}

function main() {
	if( ad_tag_loaded_jquery ) {
		$.noConflict();
	}
	
	if( typeof( autoLoad ) == 'undefined' ) autoLoad = true;
	
	if(autoLoad == true){
		jQuery( "#brand" ).overlay( { top: 50 , mask: { color: '#000', loadSpeed: 200, opacity: 0.7 }, closeOnClick: true, load: true } );
	}
		
	var triggers = jQuery("#catfish-open").overlay({ top: 50 , mask: { color: '#000', loadSpeed: 200, opacity: 0.7 }, closeOnClick: true });
	
	
	if( jQuery.browser.msie && jQuery.browser.version.substr(0,1) == 6 ) {
		DD_belatedPNG.fix("img, .png_bg"); // Fix any <img> or .png_bg bg-images. Also, please read goo.gl/mZiyb 
	}
	
	catfish_interval = setInterval( 'loadCatfish()', 1000 );
	catfish_i = 1;
}
