/////////////////////////////////////////////////////////////////////////////////////
// Start Jquery                                                                    //
/////////////////////////////////////////////////////////////////////////////////////

$( function ()
	{	//useFuncMainMenu();

		$( 'LI.liCatalog' ).children( 'DIV' ).hide();
		$( 'LI.liCatalog' ).click( function () {
			var checkElement = $( this ).children( 'DIV' );
			if( checkElement.is(':visible') ) {	$( this ).children( 'DIV' ).hide(); } else { $( this ).children( 'DIV' ).show(); }
		} ).mouseleave( function () {
			$( this ).children( 'DIV' ).hide(); } );

		if ( $( 'SELECT.selectCountry' ).length != 0 ) {
			$( 'SELECT.selectCountry' ).change( function() { 
				var strSelectVal = $( 'SELECT.selectCountry' ).val();
				funcChangeCountryValue( strSelectVal ); } ); }

		if ( $( 'SELECT.selectShop' ).length != 0 ) {
			$( 'SELECT.selectShop' ).change( function() { 
				var strSelectVal = $( 'SELECT.selectShop' ).val();
				funcChangeShopValue( strSelectVal ); } ); }

		if ( $( 'DIV.divDetail' ).length != 0 ) {

			$( '#tabsProduct' ).tabs({
					show: function(event, ui) { 
						var strSelectTab = '' + ui.tab;
							strSelectTab = strSelectTab.substring( strSelectTab.indexOf('#panel') ).replace( 'panel' , 'table' );
						$( 'TABLE.tableHeaderContent' ).hide();
						$( strSelectTab ).show(); } });

			$( 'TABLE#table-specs.tableHeaderContent TR , TABLE#table-details.tableHeaderContent TR , TABLE.tableExtra DIV.divExtraDetail' ).hide();
			$( 'TR#trSpecs0 , TR#trDetails0 , DIV#divExtraDetail0' ).show();

			$( 'DIV#panel-specs A.aProdItem' ).click( function () {
				$( 'TABLE#table-specs.tableHeaderContent TR' ).hide();
				var strActiveItem = $( this ).attr( 'id' ); 
				$( '#tr' + strActiveItem ).show(); });

			$( 'DIV#panel-details A.aProdItem' ).click( function () {
				$( 'TABLE#table-details.tableHeaderContent TR' ).hide();
				var strActiveItem = $( this ).attr( 'id' ); 
				$( '#tr' + strActiveItem ).show(); });
			
			$( 'TABLE.tableHeaderContent A.aBtnDetailText' ).click( function () {
				$( 'TABLE.tableExtra DIV.divExtraDetail' ).hide();
				var strActiveItem = $( this ).attr( 'id' ); 
				$( '#div' + strActiveItem ).show(); });			
			
			}
			
		if ( $( 'A.aBtnBuy' ).length != 0 ) {
		
			$('BODY').append('<div id="divPluginLoader">teste</div>');
			$('#divPluginLoader').hide();
			$('#divPluginLoader').dialog( {
				autoOpen : false,
				modal : true,
				width: 600,
				height: 500,
				position: [ 'center' , 100 ],
				//open: function (event, ui) { $('BODY').css('overflow', 'hidden'); $('.ui-widget-overlay').css('width', '100%'); },
				//close: function (event, ui) { $('BODY').css('overflow', 'auto'); },
				draggable : false,
				resizable : false });
				
			$( 'A.aBtnBuy' ).click( function () { $('#divPluginLoader').dialog( 'open' ); } );

		}
		
		if ( $( 'A.aDialogWindowOpen' ).length != 0 ) {
		
			$('BODY').append('<div id="divDialogWindowOpen"><img id="imgDialogWindowOpen" alt="" /></div>');
			$('#divDialogWindowOpen').hide();
			$('#divDialogWindowOpen').dialog( {
				dialogClass : 'divHomeMoreInformation',
				autoOpen : false,
				modal : true,
				width: 1068,
				height: 534,
				position: [ 'center' , 'center' ],
				open: function (event, ui) { $('BODY').css('overflow', 'hidden'); $('.ui-widget-overlay').css('width', '100%').click( function() { $('#divDialogWindowOpen').dialog( 'close' ); } ); },
				close: function (event, ui) { $('BODY').css('overflow', 'auto'); },
				draggable : false,
				resizable : false });
				
			$( 'A.aDialogWindowOpen' ).click( function ()
				{
					$('#imgDialogWindowOpen').attr( 'src' , $(this).attr( 'rel' ) );
					$('#divDialogWindowOpen').dialog( 'open' );
				} );

		}
	});


/////////////////////////////////////////////////////////////////////////////////////
// Accordion Menu                                                                  //
/////////////////////////////////////////////////////////////////////////////////////

function useFuncMainMenu( )
	{	var i  = 1; var y = 1;

		$( 'UL.ulLeftColumn UL' ).hide();
		$( 'UL.ulLeftColumn LI A' ).removeClass( 'Active' );

		$( 'UL.ulLeftColumn > LI > UL > LI > A' ).each( function() {
			$( this ).addClass( 'intMSL' +  y ).click( function() { $.cookie( 'intMSL' , $( this ).attr( 'class' ) ); } );  y++ } );

		$( 'UL.ulLeftColumn > LI > A' ).each( function()
			{	$( this ).addClass( 'intMFL' + i ).mouseover( function()
					{	$.cookie( 'intMFL' , $( this ).attr( 'class' ) );
						var checkElement = $( this ).next();
						if((checkElement.is('ul')) && (checkElement.is(':visible')))
							{	return false; }
						if((checkElement.is('ul')) && (!checkElement.is(':visible')))
							{	$( 'UL.ulLeftColumn ul:visible' ).slideUp('normal')
								checkElement.slideDown('normal');
								$( 'UL.ulLeftColumn > LI > A' ).removeClass( 'Active' );
								$( 'UL.ulLeftColumn A.' + $.cookie( 'intMFL' ) ).addClass( 'Active' );
								return false; }
					});

					i++; });
		$( 'UL.ulLeftColumn > LI > A.' + $.cookie( 'intMFL' ) ).next().show(); 
		$( 'UL.ulLeftColumn A.' + $.cookie( 'intMFL' ) + ', UL.ulLeftColumn A.' + $.cookie( 'intMSL' ) ).addClass( 'Active' );

		if ( $.cookie( 'intMFL' ) == null && $.cookie( 'intMSL' ) == null )
			{	$( 'UL.ulLeftColumn LI A' ).removeClass( 'Active' );
				$( 'UL.ulLeftColumn > LI > A:first' ).addClass( 'Active' ); } }


/////////////////////////////////////////////////////////////////////////////////////
// Google Maps - Contacts                                                          //
/////////////////////////////////////////////////////////////////////////////////////		

function loadScript( )
	{	var script = document.createElement( 'script' );
		script.type = 'text/javascript';
		script.src = 'http://maps.google.com/maps/api/js?sensor=false&callback=initialize';
		document.body.appendChild( script ); }


/////////////////////////////////////////////////////////////////////////////////////
// Google Maps - Where To Buy                                                      //
/////////////////////////////////////////////////////////////////////////////////////		

function loadScriptSecond( )
	{	var script = document.createElement( 'script' );
		script.type = 'text/javascript';
		script.src = 'http://maps.google.com/maps/api/js?sensor=false&callback=initialize';
		document.body.appendChild( script ); }


