// JavaScript Document
var myURL=$(document).url();

function setUp(q) {
	switch(q) {
		case "index":
			$(document).ready(function(){
				$(".productos").hover(
					function(){$(".catprod").css("display","block")},
					function(){$(".catprod").css("display","none");}	
				);
				$(".subcats").click(function(){
					var esto=$(this);
					$(".subCont").hide(.5,function(){$(esto).next(".subCont").show(.5);});
					
				});
			});
		break;	
		case "contacto":
			$("#formContacto").validationEngine();
		break;
		case "presupuestos":
			$("#formPresupuestos").validationEngine();
		break;
		case "portada":
			$(document).ready(function(){
				$(".bloque a").hover(
					function(){
						$(this).children(".bloqueimg").css("border-color","#A91C20");
						$(this).children(".bloquetexto").children("h1").css("color","#EEEEEE");
						$(this).children(".bloquetexto").children("span").css("color","#A91C20");
						$(this).children(".bloquetexto").stop(true,true);$(this).children(".bloquetexto").animate({backgroundPosition: '-10px -43px'},1);
						$(this).children(".bloquetexto").children("span").stop(true,true);$(this).children(".bloquetexto").children("span").animate({marginLeft: '15px'},1);
					},
					function(){
						$(this).children(".bloqueimg").css("border-color","#222222");						
						$(this).children(".bloquetexto").children("h1").css("color","#A91C20");
						$(this).children(".bloquetexto").children("span").css("color","#A91C20");
						$(this).children(".bloquetexto").stop(true,true);$(this).children(".bloquetexto").animate({backgroundPosition: '-10px 1px'},1);
						$(this).children(".bloquetexto").children("span").stop(true,true);$(this).children(".bloquetexto").children("span").animate({marginLeft: '10px'},1);
					}
				);	
				$('#mycarousel').jcarousel({
					
				});
				
				$('#slider').nivoSlider({
					effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
					slices:1,
					animSpeed:250, //Slide transition speed
					pauseTime:8000,
					startSlide:0, //Set starting Slide (0 index)
					directionNav:false, //Next & Prev
					directionNavHide:false, //Only show on hover
					controlNav:false, //1,2,3...
					controlNavThumbs:false, //Use thumbnails for Control Nav
					controlNavThumbsFromRel:false, //Use image rel for thumbs
					controlNavThumbsSearch: '.jpg', //Replace this with...
					controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
					keyboardNav:false, //Use left & right arrows
					pauseOnHover:false, //Stop animation while hovering
					manualAdvance:false, //Force manual transitions
					captionOpacity:.7
				});
			});
		break;
		case "productos":
			$(document).ready(function(){		
				$(".artic_ a").click(function(event){
					event.preventDefault();
					var id=$(this).attr("relid");
					myURL.attr("hash","BTp"+id);
					$.colorbox({
						href:'agw.php?mod=productos&func=ampliar&id='+id,
						innerWidth:710,
						innerHeight:610,
						onClosed:function(){myURL.attr("hash","top");},
						onComplete:function(){setupProductoAmpliado();}
					});
				});
				try{console.debug(myURL.attr('hash'));}catch(e){}
				if(myURL.attr('hash')!=null) {
				
						$("#"+myURL.attr('hash')).click();
				
				}
			});
		break;
	}
}

function setupProductoAmpliado(){
	$("._productos img").css("cursor","pointer");
	$("._productos img").click(function(){
		var src=$(this).attr("src");
		src=src.replace("repo/th/","");
		$("._columna_uno img").attr("src","repo/"+src);			
		$("._columna_uno img").attr("alt",$(this).attr("alt"))
		$(".pieProd").html($(this).attr("alt"));
		
	});	
	
	$("#cotizar").css("cursor","pointer");
	$("#cotizar").click(function(){
		location.href="index.php?mod=html&func=load&value=presupuestos&id="+$(this).attr("pid");	
	});
	
	
}
