// JavaScript Document
jQuery.noConflict();


jQuery(document).ready(function(){	

jQuery(".panelbut").click(function () {
      jQuery("#newssignup").slideToggle("slow");
    });								
			
			
//newsletter
jQuery('table#newsletter').wrap('<div class="newsletterwrap"></div>')
//navigations
jQuery('#nav li ul').append('<div class="roundCorner"><!-- --></div>')

var dropdowns = jQuery('.menu li#current ul').length;
if(dropdowns == '0'){	
		var submenu = jQuery('.menu li#current').parent().html();	
	}
else if(dropdowns > '0'){
		var submenu = jQuery('.menu li#current ul:first').html();	
	}
else if(dropdowns == '3'){	
		var submenu = "";	
	}

jQuery('.sendtofriend').prepend('<button></button>');

jQuery('.share').click(function(){
	jQuery('.sendtofriend').fadeIn();								
})
jQuery('.sendtofriend button').click(function(){
		jQuery('.sendtofriend').fadeOut();										  
		})
jQuery('.printthis').click(function(){
								window.print();									
	})

jQuery('.flashFrame').append('<div class="subnav"><ul class="menu">'+submenu+'</ul></div>')
jQuery('.subnav li:has(ul)').parent().remove();
//jQuery('.subnav li)').parent().remove();
jQuery('.subnav .roundCorner').remove();
jQuery('.rightCol .moduletable:last').css('border','none');
jQuery('#page h2.contentheading:first').remove();
jQuery('.attractions .article_row').eq(0).addClass('attrac');
jQuery('.attractions .article_row').eq(1).addClass('museums_row');
jQuery('.wineoil table tr td:first-child').addClass('wineoilname');
jQuery('br[mce_bogus], .jg_gallerystats').remove();
jQuery('.sectiontableheader').eq(1).remove();
jQuery('.subscribe ~ form').addClass('newsForm');

//gallery
jQuery('.gallery').after('<br class="clear" />');
jQuery('.jg_element_txt li').hide();
jQuery('.jg_element_txt li:first-child').show();
//jQuery('.gallery').prepend('<a href="index.php?option=com_joomgallery&Itemid=53" class="backtogallery">< back to our gallery</a>');
jQuery('.gallery').append('<a class="download" href="javascript:win1()">DOWNLOAD GALLERY ALBUMS</a>');
//jQuery('.gallery').prepend('<span class="download"><a class="download" href="javascript:win1()>DOWNLOAD GALLERY ALBUMS ></a></span>');
jQuery('.gallery').append('<div class="dottedline"></div>');
//jQuery('.gallery').append('<a class="download" href="javascript:win1()>DOWNLOAD GALLERY ALBUMS ></a>');
//jQuery('.gallery').remove('<span class="download2"><INPUT TYPE="button" VALUE="< Back" onClick="history.go(-1)"></span>');
//jQuery('.gallery .jg_category').after('<span class="download2"><INPUT TYPE="button" VALUE="< Back" onClick="history.go(-1)"></span>');
//jQuery('.gallery .jg_category .dottedline').after('<span class="download2"><INPUT TYPE="button" VALUE="< Back" onClick="history.go(-1)"></span>');
//		window.location = "http://www.mangiacane.com/demo/index.php?option=com_joomgallery&func=detail&id=102&Itemid=53";									
//jQuery('.gallery .jg_category').addClass('test');

		//										 })
jQuery('.jg_mygal a').text('my gallery');
jQuery('.creategallery img').show();
jQuery('table.mod_login tr:eq(2) td').html('<a href="index.php?option=com_comprofiler&task=registers">Register for an account</a>');

var bread = jQuery('.breadcrumbs a');
if(bread.length == 0){
	jQuery('.crumbs').remove();
	};

//quicklinks
if(!jQuery('.contentdescription').parent().hasClass('pressSection')){			
				jQuery('.contentdescription').append('<div class="bookmarks"></div>');
				jQuery('.article_row').prepend('<div class="toTop"><a href="#bookmarkstop">&nbsp;</a></div>');
				//jQuery('.toTop').wrapInner('<div class="toTopRC"></div>');
			}
jQuery('.toTop').hover(function(){
	if(!jQuery(this).hasClass('booknow')){
		jQuery(this).css('background','url(templates/beez/images/btnBackToTop_1.gif) no-repeat');
	}
}, function(){
	if(!jQuery(this).hasClass('booknow')){
	jQuery(this).css('background','url(templates/beez/images/btnBackToTop_0.gif) no-repeat');
	}
	});
  

jQuery('.jg_toplist a').wrap('<div class="toplistWrap"></div>')
jQuery('.moduletable:last').addClass('last');
var artRows = jQuery('.blog .article_row');	
for(var n=0;n<artRows.length;n++){
	
	if(artRows.length>1){
		jQuery('.bookmarks').append('<a class="anchor'+n+'" href="#anchor'+n+'"></a>');		
		jQuery('a.anchor'+n).text(jQuery('.article_row').eq(n).find('h2.contentheading').text());	
		jQuery(artRows[n]).attr('id', 'anchor'+n);
	}
	};
	
jQuery('.accomsection .toTop, .specialpackages .toTop').addClass('booknow');	
jQuery('.toTop').click( function(){
		if(jQuery(this).parent().hasClass('accomsection')){						 
			window.location = "http://www.mangiacane.com/demo/index.php?option=com_content&view=article&id=9&Itemid=5";
		}
		else if(jQuery(this).parent().hasClass('specialpackages')){
				window.location = "http://www.mangiacane.com/demo/index.php?option=com_content&view=article&id=143&Itemid=6";
			}
		else{
			//jQuery('html,body').animate({scrollTop: parseInt(jQuery('.bookmarks').offset().top)-100}, 1000);			
			}
			
	});	


//attractions
//jQuery('.bookmarks a.anchor0').before('<h2 class="quicklinks">Quicklinks</h2>');
//jQuery('.activities .bookmarks h2.quicklinks').text('Events');
//jQuery('.activities .bookmarks a.anchor1').before('<br><h2>Atttractions</h2>');
jQuery('.activities .bookmarks a.anchor0').before('<h2 class="contentheading">Wine Tours</h2>');
jQuery('.activities .bookmarks a.anchor3').before('<h2 class="contentheading"><br />Tours to Surrounding Cities / Areas</h2>');
jQuery('.activities .bookmarks a.anchor11').before('<h2 class="contentheading"><br />Shopping</h2>');
jQuery('.activities .bookmarks a.anchor16').before('<h2 class="contentheading"><br />Arts & Culture</h2>');
jQuery('.activities .bookmarks a.anchor20').before('<h2 class="contentheading"><br />Outdoors</h2>');
jQuery('.activities .article_row').eq(0).addClass('wine');
jQuery('.activities .article_row').eq(3).addClass('areas');
jQuery('.activities .article_row').eq(11).addClass('shopping');
jQuery('.activities .article_row').eq(16).addClass('arts');
jQuery('.activities .article_row').eq(20).addClass('outdoors');

//press section
jQuery('.pressSection .article_row span.article_separator').remove();
jQuery('.pressSection .article_row a:not(.thumbnail)').addClass('downloadPress');
var pressContact = jQuery('.pressContact').html();
jQuery('.pressContact').remove();
jQuery('.pressSection .article_row:last').after('<div class="pressContact">'+pressContact+'</div>');
jQuery('.leftCol .pressSection .article_row').eq(0).show();
//jQuery('.leftCol .pressSection').append('<h2 class="contentheading">In The Press</h2>');

//press articles
jQuery('.pressArticles .article_row:first').before('<h1 class="componentheading pressSection">Press Releases</h1>');
jQuery('.pressArticles .article_row span.article_separator').remove();
jQuery('.pressArticles .article_row a:not(.thumbnail)').addClass('downloadPress');

	
	
	
	jQuery('#nav>li.parent').hover( function(e){			
			jQuery(this).find('>ul').hoverFlow(e.type, {'opacity':'show'});
			jQuery(this).find('li.parent:first').addClass('menuhover');
			//jQuery(this).find('ul ul:first').fadeIn('fast');
	}, function(e){
			jQuery(this).find('>ul ul').hide();	
			jQuery(this).find('>ul').hoverFlow(e.type, {'opacity':'hide'}, 'fast');	
			
	});		
	
	jQuery('#nav li').hover( function(e){
			jQuery(this).addClass('menuhover');		 
	},function(e){
			if(!jQuery(this).hasClass('active')){			
				jQuery(this).removeClass('menuhover');
			}
	});	
	
//jQuery('.pressSection .article_row:last .article_column').removeClass('cols3');
	
//art special menu
	jQuery('.art .bookmarks a.anchor2').after('<div class="featuredArtist"></div>');
	var artist = jQuery('.shonaArtists h4');
	for(i=0;i<artist.length;i++){
			jQuery(artist[i]).parent().attr('id','shonaanchor'+i);
			jQuery('.featuredArtist').append('<a href="#shonaanchor'+i+'">'+jQuery(artist[i]).text()+'</a>')
		}
	jQuery('.art .bookmarks a.anchor2').removeAttr('rel');	

//sendtofriend close window
jQuery('.sendtofriend .button').remove('');
//jQuery('.sendtofriend').append('<div><input type=button value="Close This Window" onClick="javascript:window.close();"></div>')
	
//jQuery('.flashTitle').append('<div>test</div>');
	
	
//jQuery('#system-message').append('<span>test</span>');
});


// olive oil toTop remove
/*var article_column = jQuery('.toTop a');
if(article_column.length<2){
	jQuery('.toTop').remove();
	};*/
//videos

//gallery login

//jQuery('subnav .ul').remove();
//jQuery('cb_cb_comp_login').append('<div>testing</div>');