$(document).ready(function(){
    $('#customize_template').click(function(e){
		window.open('http://customizationservice.com/step2.php?templ='+$(this).attr('tpl')+'&a=customize', '_blank', '');
		 return false;
    });

	/*
	$('a.add_to_cart').click(function(e){
		window.open($(this).attr('path')+"/cart.php?id="+$(this).attr('tpl'), 'ice', 'width=850, height=600, status=yes, scrollbars=yes');
		return false;
	});
	*/
	
	$('#number').focus(function(){
		if ($('#number').attr('value') == 'Enter Template #'){
			$('#number').attr('value', '');
		}
	});
	$('#number').blur(function(){
		if ($('#number').attr('value') == ''){
			$('#number').attr('value', 'Enter Template #');
		}
	});

	$('#keywords').focus(function(e){
		if ($('#keywords').attr('value') == 'Enter Keyword(s)'){
			$('#keywords').attr('value', '');
		}
	});
	$('#keywords').blur(function(e){
		if ($('#keywords').attr('value') == ''){
			$('#keywords').attr('value', 'Enter Keyword(s)');
		}
	});

	$('#srch_but').click(function() {
		if ($('#number').attr('value') == 'Enter Template #'){
			$('#number').attr('value', '');
		}
		if ($('#keywords').attr('value') == 'Enter Keyword(s)'){
			$('#keywords').attr('value', '');
		}
	});
	
	$('.carusel_cont').each(function(){
		var obj = $(this);
		var templates = $('.template', this);
		obj.attr('ind', 0);
		obj.attr('count', templates.length);
		$('.carusel_left', obj).click(function(){
			var p = $(this).parent();
			var ind = p.attr('ind');
			if (ind > 0){
				$('.carusel > table', p).animate({
					'marginLeft': '+=187px'
				}, 'slow');
				p.attr('ind', --ind);
			}
		});
		$('.carusel_right', obj).click(function(){
			var p = $(this).parent();
			var ind = p.attr('ind');
			var count = p.attr('count');
			if (ind < count-3){
				$('.carusel > table', p).animate({
					'marginLeft': '-=187px'
				}, 'slow');
				p.attr('ind', ++ind);
			}else{
				top.location = 'show-'+p.attr('type')+'.html'
			}
		});
	});
	
	$('#adv_search').click(function(){
		$.post('counter.php', {adv_search: 1});
	});
});