/* ***********************************************************************
* Plugins initialization
*/

/*  Accordion */
function initAccordion() {
	if ( jQuery("#exampleAccordion").length ) {
	    jQuery("#exampleAccordion").accordion({
	        active: false, // By default the first child element is displayed. Set active to false and no child element is displayed.
	        showSpeed: 500  
	    });
	}
}

/* Jquery Flash -  remplacement content html for swf file */
function initFlash(){
	$('#exampleFlashPlugin').flash(
        { 
		  /** PARA DRUPAL **/
		  //src: '/sites/all/themes/CDtemplate/swf/example.swf',
		  src: 'swf/example.swf',
          width: 320,
          height: 240 },
        { version: 8 }
    );
}
/* Newsslider */
function InitNewsslider(){
    jQuery("#banner  .news_slider").accessNews({
        newsHeadline: "Noticias recientes",
        newsSpeed: "slow",
        easing: "BounceEaseOut",
        slide: 1
    });
    jQuery("#banner .columns .news_slider").accessNews({
        newsHeadline: "Productos destacados como bloque",
        newsSpeed: "slow",
        easing: "BounceEaseOut",
        slide: 1
    });
    jQuery("#main_content  .news_slider").accessNews({
        newsHeadline: "Productos destacados",
        newsSpeed: "slow",
        easing: "BounceEaseOut",
        slide: 1
    });
}


/* JqueryPager */
function initPager() {
    $('.texts').pager('p', { navClass: 'navTexts',  prevText: '&laquo; anterior', nextText: 'siguiente &raquo;', linkText: ['1', '2', '3', '4'] });
}
/*  Jquery istant */
function initIstant(){
     if(isIE){addIEInstant(); }else {addInstant();}
}

function initPngFix(){
	//Inicializando el "TRANSPARENTADOR" de PNGs (perdon por el palabro) Todas las etiquetas img que contengan un png
	if ( jQuery("h1").length ) {
	    jQuery("h1").ifixpng();
	}
}

/*  Jquery Table sorter */
function initTableSorter(){
	 $("#tablesorter-demo").tablesorter(); 
}

/*  Jquery Scroll TO */
function initScrollTo(){
    if ( jQuery("#scrollToID").length ) {
    jQuery('#scrollToID').click(function(e){
        jQuery.scrollTo( jQuery('#scrollToID').attr('href'), {speed:2500} );
        return false;
    });
}	
}


/*  Jquery Ui Diaglog */
function initUiDialog(){
     $(".informacion").dialog(); 
}

/* ***********************************************************************
* Event handlers
*/

function domloader() {
    //InitNewsslider();
	//initFlash();
	//initAccordion();
    //initPager();
	initPngFix();
	//initScrollTo();
    //initUiDialog();
}

function windowloader() {
	 initIstant();
	 initTableSorter();
}

/** Event resize**/
function windowOnResize() {
    InitNewsslider();
};





/* ***********************************************************************
* Secondary functions
*/



/* ***********************************************************************
* Event controllers
*/

/**
addDOMLoadEvent(domloader); 
window.onload = windowloader;
var resizeTimer = null;
$(window).bind('resize', function() {
    if (resizeTimer) clearTimeout(resizeTimer);
    resizeTimer = setTimeout(windowOnResize, 100);
});

**/


$(document).ready(function(){
 //alert('PROBANDO');
 domloader();    
 windowloader();
 windowOnResize();
});


