// JavaScript Document

$(document).ready(function(){

if($.browser.safari){
	$(".comments").addClass("safcom")				 
}

$("div.comments div").hide();
function sp_products(nowmoving,sw,comments){	
	var randnum = Math.floor( Math.random() * $("div#"+sw+" img").length)+1;
	if(randnum==1){$("div#"+sw).find("img").eq(0).attr({ src: "images/selected.jpg"});$("div#"+comments).find("div").eq(0).fadeIn(400,function(){nowmoving = false;});
	$(this).delay(360,function(){$("div#"+comments).find("div").eq(0).stop();nowmoving = false;});
	}else if(randnum==2){$("div#"+sw).find("img").eq(1).attr({ src: "images/selected.jpg"});$("div#"+comments).find("div").eq(1).fadeIn(400,function(){nowmoving = false;});
	$(this).delay(360,function(){$("div#"+comments).find("div").eq(1).stop();nowmoving = false;});
	}else if(randnum==3){$("div#"+sw).find("img").eq(2).attr({ src: "images/selected.jpg"});$("div#"+comments).find("div").eq(2).fadeIn(400,function(){nowmoving = false;});
	$(this).delay(360,function(){$("div#"+comments).find("div").eq(2).stop();nowmoving = false;});
	}else if(randnum==4){$("div#"+sw).find("img").eq(3).attr({ src: "images/selected.jpg"});$("div#"+comments).find("div").eq(3).fadeIn(400,function(){nowmoving = false;});
	$(this).delay(360,function(){$("div#"+comments).find("div").eq(3).stop();nowmoving = false;});
	}else if(randnum==5){$("div#"+sw).find("img").eq(4).attr({ src: "images/selected.jpg"});$("div#"+comments).find("div").eq(4).fadeIn(400,function(){nowmoving = false;});
	$(this).delay(360,function(){	$("div#"+comments).find("div").eq(4).stop();nowmoving = false;});}
	
	$("div#"+sw).find("img").eq(0).click(function(ev){if($(this).attr("src")!="images/selected.jpg"){
	if(nowmoving==false){$("div#"+sw).find("img").attr({ src: "images/no_select.jpg"});
	$(this).attr({ src: "images/selected.jpg"});nowmoving = true;$("div#"+comments).find("div").fadeOut(300);
	$(this).delay(300,function(){$("div#"+comments).find("div").eq(0).fadeIn(400,function(){nowmoving = false;});
	$(this).delay(370,function(){$("div#"+comments).find("div").eq(0).stop();nowmoving = false;});});}}})
	
	$("div#"+sw).find("img").eq(1).click(function(ev){if($(this).attr("src")!="images/selected.jpg"){
	if(nowmoving==false){$("div#"+sw).find("img").attr({ src: "images/no_select.jpg"});
	$(this).attr({ src: "images/selected.jpg"});nowmoving = true;$("div#"+comments).find("div").fadeOut(300);
	$(this).delay(300,function(){$("div#"+comments).find("div").eq(1).fadeIn(400,function(){nowmoving = false;});
	$(this).delay(370,function(){$("div#"+comments).find("div").eq(1).stop();nowmoving = false;});});}}})
	
	$("div#"+sw).find("img").eq(2).click(function(ev){if($(this).attr("src")!="images/selected.jpg"){
	if(nowmoving==false){$("div#"+sw).find("img").attr({ src: "images/no_select.jpg"});
	$(this).attr({ src: "images/selected.jpg"});nowmoving = true;$("div#"+comments).find("div").fadeOut(300);
	$(this).delay(300,function(){$("div#"+comments).find("div").eq(2).fadeIn(400,function(){nowmoving = false;});
	$(this).delay(370,function(){$("div#"+comments).find("div").eq(2).stop();nowmoving = false;});});}}})
	
	$("div#"+sw).find("img").eq(3).click(function(ev){if($(this).attr("src")!="images/selected.jpg"){
	if(nowmoving==false){$("div#"+sw).find("img").attr({ src: "images/no_select.jpg"});
	$(this).attr({ src: "images/selected.jpg"});nowmoving = true;$("div#"+comments).find("div").fadeOut(300);
	$(this).delay(300,function(){$("div#"+comments).find("div").eq(3).fadeIn(400,function(){nowmoving = false;});
	$(this).delay(370,function(){$("div#"+comments).find("div").eq(3).stop();nowmoving = false;});});}}})
	
	$("div#"+sw).find("img").eq(4).click(function(ev){if($(this).attr("src")!="images/selected.jpg"){
	if(nowmoving==false){$("div#"+sw).find("img").attr({ src: "images/no_select.jpg"});
	$(this).attr({ src: "images/selected.jpg"});nowmoving = true;$("div#"+comments).find("div").fadeOut(300);
	$(this).delay(300,function(){$("div#"+comments).find("div").eq(4).fadeIn(400,function(){nowmoving = false;});
	$(this).delay(370,function(){$("div#"+comments).find("div").eq(4).stop();nowmoving = false;});});}}})
}

/*
you can use this lists.and you can add this list.
*/
var nowmoving1 = true;sp_products(nowmoving1,"sw1","comments1");
var nowmoving2 = true;sp_products(nowmoving2,"sw2","comments2");
var nowmoving3 = true;sp_products(nowmoving3,"sw3","comments3");
var nowmoving4 = true;sp_products(nowmoving4,"sw4","comments4");
var nowmoving5 = true;sp_products(nowmoving5,"sw5","comments5");
var nowmoving6 = true;sp_products(nowmoving6,"sw6","comments6");
var nowmoving7 = true;sp_products(nowmoving7,"sw7","comments7");
var nowmoving8 = true;sp_products(nowmoving8,"sw8","comments8");
var nowmoving9 = true;sp_products(nowmoving9,"sw9","comments9");
var nowmoving10 = true;sp_products(nowmoving10,"sw10","comments10");
var nowmoving11 = true;sp_products(nowmoving11,"sw11","comments11");
var nowmoving12 = true;sp_products(nowmoving12,"sw12","comments12");
var nowmoving13 = true;sp_products(nowmoving13,"sw13","comments13");
var nowmoving14 = true;sp_products(nowmoving14,"sw14","comments14");
var nowmoving15 = true;sp_products(nowmoving15,"sw15","comments15");
var nowmoving16 = true;sp_products(nowmoving16,"sw16","comments16");
var nowmoving17 = true;sp_products(nowmoving17,"sw17","comments17");
var nowmoving18 = true;sp_products(nowmoving18,"sw18","comments18");
var nowmoving19 = true;sp_products(nowmoving19,"sw19","comments19");
var nowmoving20 = true;sp_products(nowmoving20,"sw20","comments20");
var nowmoving21 = true;sp_products(nowmoving21,"sw21","comments21");



function bg_change(color,len,com){
	if(len ==5){
		$(com).find("p").eq(0).css("background-image","url(images/"+color+"_up_"+1+".gif)");
		$(com).find("p").eq(1).css("background-image","url(images/"+color+"_up_"+2+".gif)");
		$(com).find("p").eq(2).css("background-image","url(images/"+color+"_up_"+3+".gif)");
		$(com).find("p").eq(3).css("background-image","url(images/"+color+"_up_"+4+".gif)");
		$(com).find("p").eq(4).css("background-image","url(images/"+color+"_up_"+5+".gif)");
	}else if(len==4){
		$(com).find("p").eq(0).css("background-image","url(images/"+color+"_up2_"+1+".gif)");
		$(com).find("p").eq(1).css("background-image","url(images/"+color+"_up2_"+2+".gif)");
		$(com).find("p").eq(2).css("background-image","url(images/"+color+"_up2_"+4+".gif)");
		$(com).find("p").eq(3).css("background-image","url(images/"+color+"_up2_"+5+".gif)");
	}else if(len==3){
		$(com).find("p").eq(0).css("background-image","url(images/"+color+"_up_"+2+".gif)");
		$(com).find("p").eq(1).css("background-image","url(images/"+color+"_up_"+3+".gif)");
		$(com).find("p").eq(2).css("background-image","url(images/"+color+"_up_"+4+".gif)");
	}else if(len==2){
		$(com).find("p").eq(0).css("background-image","url(images/"+color+"_up2_"+2+".gif)");
		$(com).find("p").eq(1).css("background-image","url(images/"+color+"_up2_"+4+".gif)");
	}else{
		$(com).find("p").eq(0).css("background-image","url(images/"+color+"_up_"+3+".gif)");
	}
	$(com).find("div").css("background-image","url(images/"+color+"_under.jpg)")
}

var randnum = Math.floor( Math.random() *5);
if(randnum==0){
	bg_change("blue",$("div#sw1 img").length,"#comments1");
	bg_change("pink",$("div#sw2 img").length,"#comments2");
	bg_change("yellow",$("div#sw3 img").length,"#comments3");
	bg_change("green",$("div#sw4 img").length,"#comments4");
	bg_change("purple",$("div#sw5 img").length,"#comments5");
	bg_change("blue",$("div#sw6 img").length,"#comments6");
	bg_change("pink",$("div#sw7 img").length,"#comments7");
	bg_change("yellow",$("div#sw8 img").length,"#comments8");
	bg_change("green",$("div#sw9 img").length,"#comments9");
	bg_change("purple",$("div#sw10 img").length,"#comments10");
	bg_change("blue",$("div#sw11 img").length,"#comments11");
	bg_change("pink",$("div#sw12 img").length,"#comments12");
	bg_change("yellow",$("div#sw13 img").length,"#comments13");
	bg_change("green",$("div#sw14 img").length,"#comments14");
	bg_change("purple",$("div#sw15 img").length,"#comments15");
	bg_change("blue",$("div#sw16 img").length,"#comments16");
	bg_change("pink",$("div#sw17 img").length,"#comments17");
	bg_change("yellow",$("div#sw18 img").length,"#comments18");
	bg_change("green",$("div#sw19 img").length,"#comments19");
	bg_change("purple",$("div#sw20 img").length,"#comments20");
	bg_change("blue",$("div#sw21 img").length,"#comments21");
}else if(randnum==1){
	bg_change("purple",$("div#sw1 img").length,"#comments1");
	bg_change("blue",$("div#sw2 img").length,"#comments2");
	bg_change("pink",$("div#sw3 img").length,"#comments3");
	bg_change("yellow",$("div#sw4 img").length,"#comments4");
	bg_change("green",$("div#sw5 img").length,"#comments5");
	bg_change("purple",$("div#sw6 img").length,"#comments6");
	bg_change("blue",$("div#sw7 img").length,"#comments7");
	bg_change("pink",$("div#sw8 img").length,"#comments8");
	bg_change("yellow",$("div#sw9 img").length,"#comments9");
	bg_change("green",$("div#sw10 img").length,"#comments10");
	bg_change("purple",$("div#sw11 img").length,"#comments11");
	bg_change("blue",$("div#sw12 img").length,"#comments12");
	bg_change("yellow",$("div#sw13 img").length,"#comments13");
	bg_change("green",$("div#sw14 img").length,"#comments14");
	bg_change("green",$("div#sw15 img").length,"#comments15");
	bg_change("purple",$("div#sw16 img").length,"#comments16");
	bg_change("blue",$("div#sw17 img").length,"#comments17");
	bg_change("yellow",$("div#sw18 img").length,"#comments18");
	bg_change("green",$("div#sw19 img").length,"#comments19");
	bg_change("green",$("div#sw20 img").length,"#comments20");
	bg_change("purple",$("div#sw21 img").length,"#comments21");
}else if(randnum==2){
	bg_change("green",$("div#sw1 img").length,"#comments1");
	bg_change("purple",$("div#sw2 img").length,"#comments2");
	bg_change("blue",$("div#sw3 img").length,"#comments3");
	bg_change("pink",$("div#sw4 img").length,"#comments4");
	bg_change("yellow",$("div#sw5 img").length,"#comments5");
	bg_change("green",$("div#sw6 img").length,"#comments6");
	bg_change("purple",$("div#sw7 img").length,"#comments7");
	bg_change("blue",$("div#sw8 img").length,"#comments8");
	bg_change("pink",$("div#sw9 img").length,"#comments9");
	bg_change("yellow",$("div#sw10 img").length,"#comments10");
	bg_change("green",$("div#sw11 img").length,"#comments11");
	bg_change("purple",$("div#sw12 img").length,"#comments12");
	bg_change("blue",$("div#sw13 img").length,"#comments13");
	bg_change("pink",$("div#sw14 img").length,"#comments14");
	bg_change("yellow",$("div#sw15 img").length,"#comments15");
	bg_change("green",$("div#sw16 img").length,"#comments16");
	bg_change("purple",$("div#sw17 img").length,"#comments17");
	bg_change("blue",$("div#sw18 img").length,"#comments18");
	bg_change("pink",$("div#sw19 img").length,"#comments19");
	bg_change("yellow",$("div#sw20 img").length,"#comments20");
	bg_change("green",$("div#sw21 img").length,"#comments21");
}else if(randnum==3){
	bg_change("yellow",$("div#sw1 img").length,"#comments1");
	bg_change("green",$("div#sw2 img").length,"#comments2");
	bg_change("purple",$("div#sw3 img").length,"#comments3");
	bg_change("blue",$("div#sw4 img").length,"#comments4");
	bg_change("pink",$("div#sw5 img").length,"#comments5");
	bg_change("yellow",$("div#sw6 img").length,"#comments6");
	bg_change("green",$("div#sw7 img").length,"#comments7");
	bg_change("purple",$("div#sw8 img").length,"#comments8");
	bg_change("blue",$("div#sw9 img").length,"#comments9");
	bg_change("pink",$("div#sw10 img").length,"#comments10");
	bg_change("yellow",$("div#sw11 img").length,"#comments11");
	bg_change("green",$("div#sw12 img").length,"#comments12");
	bg_change("purple",$("div#sw13 img").length,"#comments13");
	bg_change("blue",$("div#sw14 img").length,"#comments14");
	bg_change("pink",$("div#sw15 img").length,"#comments15");
	bg_change("yellow",$("div#sw16 img").length,"#comments16");
	bg_change("green",$("div#sw17 img").length,"#comments17");
	bg_change("purple",$("div#sw18 img").length,"#comments18");
	bg_change("blue",$("div#sw19 img").length,"#comments19");
	bg_change("pink",$("div#sw20 img").length,"#comments20");
	bg_change("yellow",$("div#sw21 img").length,"#comments21");
}else{
	bg_change("pink",$("div#sw1 img").length,"#comments1");
	bg_change("yellow",$("div#sw2 img").length,"#comments2");
	bg_change("green",$("div#sw3 img").length,"#comments3");
	bg_change("purple",$("div#sw4 img").length,"#comments4");
	bg_change("blue",$("div#sw5 img").length,"#comments5");
	bg_change("pink",$("div#sw6 img").length,"#comments6");
	bg_change("yellow",$("div#sw7 img").length,"#comments7");
	bg_change("green",$("div#sw8 img").length,"#comments8");
	bg_change("purple",$("div#sw9 img").length,"#comments9");
	bg_change("blue",$("div#sw10 img").length,"#comments10");
	bg_change("pink",$("div#sw11 img").length,"#comments11");
	bg_change("yellow",$("div#sw12 img").length,"#comments12");
	bg_change("green",$("div#sw13 img").length,"#comments13");
	bg_change("purple",$("div#sw14 img").length,"#comments14");
	bg_change("blue",$("div#sw15 img").length,"#comments15");
	bg_change("pink",$("div#sw16 img").length,"#comments16");
	bg_change("yellow",$("div#sw17 img").length,"#comments17");
	bg_change("green",$("div#sw18 img").length,"#comments18");
	bg_change("purple",$("div#sw19 img").length,"#comments19");
	bg_change("blue",$("div#sw20 img").length,"#comments20");
	bg_change("pink",$("div#sw21 img").length,"#comments21");
}



});










