/*
Copyright 2008, 2009 Copyleft S. de R.L. de C.V.

This file is part of Editorial Mapas.

Editorial Mapas is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Editorial Mapas is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Editorial Mapas.  If not, see <http://www.gnu.org/licenses/>
*/
$(document).ready(function() {

	//show gallery
    $("#showgal").click(function () {
    	$("#pic_0").trigger('click');		
    });	
	
	//menu roll over
	$(".items li").mouseover(function() {
		$(this).addClass("activeli");
		var title = $(this).find("a").attr("title");
		$(this).parent().parent().find("img").attr("src","uploads/products/"+title);
	});
	$(".items li").mouseout(function() {
		$(this).removeClass("activeli");
		$(this).parent().parent().find("img").attr("src","images/frontend/img-blank.png");
	});

	//menu roll over
	$(".items2 li").mouseover(function() {
		$(this).addClass("activeli");
	});
	$(".items2 li").mouseout(function() {
		$(this).removeClass("activeli");
	});	
	
	//menu top roll over
	$(".menutop").mouseover(function() {			
		$(this).parent().parent().find("img").attr("src","uploads/content/"+this.title);
	});
	$(".menutop").mouseout(function() {		
		//alert(this.alt);
		$(this).parent().parent().find("img").attr("src","uploads/content/"+this.alt);
	});		
	
	// replace text for image
	$(".right-categories").each(function(i) {	
		txtcategories = $(this).text().split(" ");
		urlcategories = $(this).find("a").attr("href");
		$(this).empty();
		for(i=0; i<txtcategories.length; i++) {
			$(this).append('<a href="'+urlcategories+'"><img src="http://txt.editorialmapas.com/includes/imageheader.php?font=AmplitudeCond-Regular&size=11&color=007E91&text='+txtcategories[i].toUpperCase()+'%20" alt="" /></a>');
		}
	});
	
	// replace text for image ON
	$(".right-categories-on").each(function(i) {	
		txtcategorieson = $(this).text().split(" ");
		urlcategorieson = $(this).find("a").attr("href");
		$(this).empty();
		for(i=0; i<txtcategorieson.length; i++) {
			$(this).append('<a href="'+urlcategorieson+'"><img src="http://txt.editorialmapas.com/includes/imageheader.php?font=AmplitudeCond-Regular&size=11&color=D60000&text='+txtcategorieson[i].toUpperCase()+'%20" alt="" /></a>');
		}
	});	

	// menu rollover 
	$(".menu").mouseover(function() {
		var image = $(this).attr("src").replace(".png", "");
		$(this).attr("src",image+"-on.png");
	});
	$(".menu").mouseout(function() {
		var image = $(this).attr("src").replace("-on.png", "");
		$(this).attr("src",image+".png");
	});
	
	// answers
	$('div.demo-show:eq(0)> div').hide();
	$('div.demo-show:eq(0)> h3').click(function() {
		$(this).next().slideToggle('fast');
  });
	$('div.demo-show> div:eq(0)').show();
	
	// toggle selected
	$('div.demo-show h3').click(function() {
		if($(this).attr("class")=="row1-opened") {
			$(this).removeClass("row1-opened");
			$(this).addClass("row1-closed");
		} else if($(this).attr("class")=="row1-closed") {
			$(this).removeClass("row1-closed");
			$(this).addClass("row1-opened");
		} else if($(this).attr("class")=="row2-opened") {
			$(this).removeClass("row2-opened");
			$(this).addClass("row2-closed");
		} else if($(this).attr("class")=="row2-closed") {
			$(this).removeClass("row2-closed");
			$(this).addClass("row2-opened");
		}
	});
});