var colors = {

	set:function(id, index, value, motiv, pid){
		// set selectedIndex
		if ($(id)){
			$(id).selectedIndex = index;
		}
		
		// set preview
		if ($('mainPic-'+id) && value != "" && motiv != ""){
			$('mainPic-'+id).src = 'colorize.php?pid='+pid+'&c=' + value.replace(/#/,"") + '&i='+motiv;
		}	
	},
	
	setParent:function(id, index, value, motiv, pid){
		// set selectedIndex
		if (parent.document.getElementById(id)){
			parent.document.getElementById(id).selectedIndex = index;
			/* disabled for now :(
			if (parent.document.getElementById('mainPic-'+id) && value != "" && motiv != ""){
				parent.document.getElementById('mainPic-'+id).src = 'colorize.php?pid='+pid+'&c=' + value.replace(/#/,"") + '&i='+motiv;
			}
			*/
		}
		
		// set preview
		if ($('mainPic-'+id) && value != "" && motiv != ""){
			$('mainPic-'+id).src = 'colorize.php?pid='+pid+'&c=' + value.replace(/#/,"") + '&i='+motiv;
		}
		if ($(id)){
			$(id).selectedIndex = index;
		}
	},
	
	setBackground:function(color){
		$('mainPicContainer').setStyle('background-color',color);
	},
	
	setInit:function(id, index, value, motiv, pid){
		// set preview
		if ($('mainPic-'+id) && value != "" && motiv != ""){
			$('mainPic-'+id).src = 'colorize.php?pid='+pid+'&c=' + value.replace(/#/,"") + '&i='+motiv;
		}	
	},
	
	setPic:function(newImg){
		//colors.progress('on');
		//var img = new Image();
		//img.src = "/images/product_images/popup_images/" + newImg;
		$("mainPicContainer").setStyle('background','url(images/product_images/popup_images/' + newImg+')');
		//colors.progress('off');
	},
	
	progress:function(mode){
		switch (mode){
			case "on": $("mainPicContainer").addClass("progress"); break;
			case "off": $("mainPicContainer").removeClass("progress"); break;
		}
	}
}

var fonts = {

	set:function(value){	
		// set preview
		if ($('fontPreview') && value != ""){
			$('fontPreview').src = "/images/fonts/" + value;
		}
	}
}

var highlight = {

	start:function(){
		if ($('prodList')){
			highlight.addSomeEffect();
		}
	},
	
	addSomeEffect:function(){
		var sideblocks1 = $$('#prodList .subcl');
		var sideblocks2 = $$('#prodList .subc');
		var sideblocks3 = $$('#prodList .subcr');
		
		sideblocks1.each(function(el,i){
			if (el.innerHTML != "&nbsp;"){
				el.addEvent('mouseenter',function(e){
					el.addClass('productListingItemHighlight');
				});
				el.addEvent('mouseleave',function(e){
					el.removeClass('productListingItemHighlight');
				});
				
				// Link?
				/*var first = el.getFirst().getFirst();
				if(first || first.getTag()=='a'){
					el.addEvent('click',function(e){
						window.location.href = first.href;
					});
				}*/
			}
		},this);
		
		sideblocks2.each(function(el,i){
			if (el.innerHTML != "&nbsp;"){		
				el.addEvent('mouseenter',function(e){
					el.addClass('productListingItemHighlight');
				});
				el.addEvent('mouseleave',function(e){
					el.removeClass('productListingItemHighlight');
				});
				
				// Link?
				/*var first = el.getFirst().getFirst();
				if(first || first.getTag()=='a'){
					el.addEvent('click',function(e){
						window.location.href = first.href;
					});
				}*/
			}
		},this);
		
		sideblocks3.each(function(el,i){
			if (el.innerHTML != "&nbsp;"){
				el.addEvent('mouseenter',function(e){
					el.addClass('productListingItemHighlight');
				});
				el.addEvent('mouseleave',function(e){
					el.removeClass('productListingItemHighlight');
				});
				
				// Link?
				/*var first = el.getFirst().getFirst();
				if(first || first.getTag()=='a'){
					el.addEvent('click',function(e){
						window.location.href = first.href;
					});
				}*/
			}
		},this);
	}	
}
window.addEvent('load',highlight.start);


