/**
 * @author .DeV!L
 */

var previews = [
	[
		'http://www.readyphotosite.com/preview/ecommerce/skin7',
		'http://www.readyphotosite.com/preview/ecommerce/skin7'
	],
	[
		'http://www.readyphotosite.com/preview/ecommerce/skin8',
		'http://www.readyphotosite.com/preview/ecommerce/skin8'
	],
	[
		'http://www.readyphotosite.com/preview/ecommerce/skin9',
		'http://www.readyphotosite.com/preview/ecommerce/skin9'
	],
	[
		'http://www.readyphotosite.com/preview/ecommerce/skin10',
		'http://www.readyphotosite.com/preview/ecommerce/skin10'
	]
];

var buys = [
	[
		[
			'http://www.readyphotosite.com/store/cart.php?a=add&pid=62',
			'http://www.readyphotosite.com/store/cart.php?a=add&pid=64'
		],
		[
			'http://www.readyphotosite.com/store/cart.php?a=add&pid=68',
			'http://www.readyphotosite.com/store/cart.php?a=add&pid=70'
		],
		[
			'http://www.readyphotosite.com/store/cart.php?a=add&pid=72',
			'http://www.readyphotosite.com/store/cart.php?a=add&pid=74'
		],
		[
			'http://www.readyphotosite.com/store/cart.php?a=add&pid=80',
			'http://www.readyphotosite.com/store/cart.php?a=add&pid=82'
		]
	],
	[
		[
			'http://www.readyphotosite.com/store/cart.php?a=add&pid=61',
			'http://www.readyphotosite.com/store/cart.php?a=add&pid=63'
		],
		[
			'http://www.readyphotosite.com/store/cart.php?a=add&pid=67',
			'http://www.readyphotosite.com/store/cart.php?a=add&pid=69'
		]
		,
		[
			'http://www.readyphotosite.com/store/cart.php?a=add&pid=71',
			'http://www.readyphotosite.com/store/cart.php?a=add&pid=73'
		]
		,
		[
			'http://www.readyphotosite.com/store/cart.php?a=add&pid=79',
			'http://www.readyphotosite.com/store/cart.php?a=add&pid=81'
		]
	]
];


 $(function(){
 	//panel
 	$('#switcher > span').click(function(){
		var p = $('#panel');
		if (p.css('display') == 'block'){
			p.slideUp();
			$(this).html("Show the panel").css('background-image', 'url(images/arr_down.gif)');
		}else{
			p.slideDown();
			$(this).html("Hide the panel").css('background-image', 'url(images/arr_up.gif)');
		}
	});
	
	$('#arr1').click(function(){
		$('#block2').show().effect('bounce', {}, 120);
		setTimeout(function(){
			$('#arr2').fadeIn('slow');	
		}, 1000);
		$(this).css('cursor', 'default').unbind('click');
	});
	
	$('#arr2').click(function(){
		$('#block3').show().effect('bounce', {}, 120);
		setTimeout(function(){
			$('#buy').fadeIn('slow');
		}, 1000);
		$(this).css('cursor', 'default').unbind('click');
	});
	
	setupCarousel(location.hash.substring(1));
	
	$('div#pics > img').click(function(){
		if ($(this).hasClass('active')){
			var theme = $(this).attr('ind');
			var tp = $('#package').val();
			$('#f').height(1000);
			$('#f').get(0).src = previews[theme][tp];
		}
	});
	
	$('#package').change(function(){
		var tp = $(this).val();
		var pdata = [
			'Ecommerce package: $199',
			'Premium package: $250'
		];
		var theme = $('div#pics > img.active').attr('ind');
		$('#f').height(1000);
		$('#f').get(0).src = previews[theme][tp];
		$('#pack_name > span').html(pdata[tp]);
	});
	
	$('#hosting').change(function(){
		if ($(this).val() == 0){
			$('#host_price').show();
			$('#block3 > .inner > .info').eq(0).show();
			$('#block3 > .inner > .info').eq(1).hide();
		}else{
			$('#host_price').hide();
			$('#block3 > .inner > .info').eq(0).hide();
			$('#block3 > .inner > .info').eq(1).show();
		}
	});
	
	$('#buy').click(function(){
		var h = $('#hosting').val();
		var theme = $('div#pics > img.active').attr('ind');
		var tp = $('#package').val();
		window.open(buys[h][theme][tp], '_top');
	});
	
	//tooltips
	$('#pack_name > *').mouseover(function(){
		var p = $('#package').val();
		var tips = [
			'*General Settings Editor<br />\
			*Menu Editor<br />\
			*Metadata Manager<br />\
			*Text Pages Builder<br />\
			*Contact Page Editor<br />\
			*News Block Editor<br />\
			*Events Calendar<br />\
			*MP3 Tracks Editor<br />\
			*Photo Galleries<br />\
			*Slideshow Creator<br />\
			*Video Galleries<br />\
			*Password Protected Galleries<br />\
			*Shopping Cart',
			'*General Settings Editor<br />\
			*Menu Editor, Metadata Manager<br />\
			*Text Pages Builder, Contact Page Editor<br />\
			*News Block Editor, Events Calendar<br />\
			*MP3 Tracks Editor<br />\
			*Photo Galleries, Video Galleries<br />\
			*Slideshow Creator<br />\
			*Shopping Cart, Password Protected Galleries<br />&nbsp;<br />\
			Premium package <b style="color:#AC0000">includes .fla of the design skin</b> allowing to accomplish website graphical and layout changes.'
		];
		Tip(tips[p], BORDERCOLOR, '#eac797', BGCOLOR, '#ffeed6', TITLE, 'Package Features', TITLEBGCOLOR, '#eac797', TITLEFONTCOLOR, '#000000', TITLEFONTFACE, 'Tahoma', TITLEFONTSIZE, '12px', WIDTH, 276, SHADOW, true, SHADOWCOLOR, '#d6bf9f');
	}).mouseout(function(){
		UnTip();
	});
	
	var h = $('#block3 > .inner > .info');
	h.eq(0).mouseover(function(){
		Tip('* Free Instant Setup<br />\
    		* 3Gb Disk Space<br />\
		    * Unlimited Bandwidth<br />\
		    * 5 FTP Accounts<br />\
		    * 1 MySQL Database<br />\
		    * MySQL, IMAP, POP<br />\
		    * 99.9% Uptime Guarantee<br />\
		    * CGI, PHP 5, RoR, Perl<br />\
		    * IMAP, POP<br />\
		    * cPanel Hosting<br />\
		    * 24/7/365 Upgraded Support', BORDERCOLOR, '#eac797', BGCOLOR, '#ffeed6', TITLE, 'Hosting details', TITLEBGCOLOR, '#eac797', TITLEFONTCOLOR, '#000000', TITLEFONTFACE, 'Tahoma', TITLEFONTSIZE, '12px', WIDTH, 276, SHADOW, true, SHADOWCOLOR, '#d6bf9f');
	}).mouseout(function(){
		UnTip();
	});
	
	h.eq(1).mouseover(function(){
		Tip('Web server (hosting) based on Linux/FreeBSD supporting PHP5, ZendOptimizer, ZendEncoder.<br /><br />\
			We highly recommend to host with us to avoid any installation or set-up problems.', BORDERCOLOR, '#eac797', BGCOLOR, '#ffeed6', TITLE, 'Hosting requirements', TITLEBGCOLOR, '#eac797', TITLEFONTCOLOR, '#000000', TITLEFONTFACE, 'Tahoma', TITLEFONTSIZE, '12px', WIDTH, 276, SHADOW, true, SHADOWCOLOR, '#d6bf9f');
	}).mouseout(function(){
		UnTip();
	});
 });
 
 function setupCarousel(name)
 {
	name = name.replace(/\%20/ig, ' ');
 	$('div#pics > img').css({
		'opacity': 0,
		'display': 'block'
	});
	
	var li = $('div#pics > img');
	li.each(function(i){
		$(this).attr('ind', i);
	});
	
	if (name == ''){
		$(li.get(li.size()-1)).addClass('left');
		$(li.get(0)).addClass('active');
		$(li.get(1)).addClass('right');
	}else{
		n = $('div#pics > img[alt="'+name+'"]');
		var ni = li.index(n);
		n.addClass('active');
		
		if (ni == 0){
			$(li.get(li.size()-1)).addClass('left');
			$(li.get(1)).addClass('right');
		}else{
			if (ni == li.size() - 1){
				$(li.get(ni - 1)).addClass('left');
				$(li.get(0)).addClass('right');
			}else{
				$(li.get(ni - 1)).addClass('left');
				$(li.get(ni + 1)).addClass('right');
			}
		}
	}
	
	$('div#pics > img.left, div#pics > img.right').css('opacity', 0.7);
	$('div#pics > img.active').css('opacity', 1);
	$('div#pics > img[class=""]').css({
		'height': '74px',
		'top': '10px',
		'left': '60px'
	});
	
	$('#go_left').click(function(){
		var left = $('div#pics > img.left');
		var right = $('div#pics > img.right');
		var active = $('div#pics > img.active');
		var lind = li.index(left);
		var rind = li.index(right);
		var aind = li.index(active);
		
		if (rind < li.size() - 1){
			var s = $(li.get(rind+1));
		}else{
			var s = $(li.get(0));
		}
		
		left.css({
			'height': '74px',
			'top': '10px'
		}).animate({
			'opacity': 0.0,
			'left': '60px',
			'heigh': '74px'
		}, 500).removeClass('left');
		active.animate({
			'opacity': 0.7,
			'z-index': 1,
			'top': '10px',
			'left': '5px',
			'height': '74px'
		}, 500).removeClass('active').addClass('left');
		right.animate({
			'opacity': 1.0,
			'z-index': 5,
			'top': '1px',
			'left': '60px',
			'height': '91px'
		}, 500).removeClass('right').addClass('active');
		s.show().animate({
			'opacity': 0.7,
			'left': '144px',
			'z-index': 1,
			'top': '10px',
			'height': '74px'  
		}, 500).addClass('right');
		
		$('#theme_name').html(right.attr('alt'));
	});
	
	$('#go_right').click(function(){
		var left = $('div#pics > img.left');
		var right = $('div#pics > img.right');
		var active = $('div#pics > img.active');
		var lind = li.index(left);
		var rind = li.index(right);
		var aind = li.index(active);
		
		if (lind > 0){
			var s = $(li.get(lind - 1));
		}else{
			var s = $(li.get(li.size() - 1));
		}
		
		left.animate({
			'opacity': 1.0,
			'z-index': 5,
			'top': '1px',
			'left': '60px',
			'height': '91px'
		}, 500).removeClass('left').addClass('active');
		
		active.animate({
			'opacity': 0.7,
			'left': '144px',
			'z-index': 1,
			'top': '10px',
			'height': '74px'  
		}, 500).removeClass('active').addClass('right')
		
		right.css({
			'height': '74px',
			'top': '10px'
		}).animate({
			'opacity': 0.0,
			'left': '60px',
			'heigh': '74px'
		}, 500).removeClass('right');
		
		s.show().animate({
			'opacity': 0.7,
			'z-index': 1,
			'top': '10px',
			'left': '5px',
			'height': '74px'
		}, 500).addClass('left');
		
		$('#theme_name').html(left.attr('alt'));
	});
	
	//show active theme name
	$('#theme_name').html($('div#pics > img.active').attr('alt'));
	$('#f').height(1000);
	$('#f').get(0).src = previews[$('div#pics > img.active').attr('ind')][1];

	var img_temp = $('<img src="images/step_1.png" />');
	var img_temp = $('<img src="images/step_2.png" />');
	var img_temp = $('<img src="images/step_3.png" />');
 }
