 var n_before_height, n_select_height;
 var time_id, move_stat, select_id;
 var before_id;
 var select_index

 var main_center_tid;
 var main_center_stat;
 var main_center_index = new Array();
 var main_center_cell_id;

 move_stat = 0;

 main_center_stat = 0;
 main_center_index[0] = 0;main_center_index[1] = 0;main_center_index[2] = 0;main_center_index[3] = 0;

 function onclick_tab(nID) {
    var stat, i;

	stat = document.getElementById("people_list_"+nID).style.display;

	if(stat == "" || move_stat == 1) {
	   return;
	}

    before_id = 0;
    for(i=1;i<=2;i++) {
	    stat = document.getElementById("people_list_"+i).style.display;
		if(stat == "") {
		   before_id = i;
		   break;
		}
	}

	move_stat = 1;
	n_before_height = 110;
	n_select_height = 0;
	select_id = nID;
	
	MoveTab();
 }

 function MoveTab() {
	var src_url;

	if(n_before_height > 15) {
	   n_before_height = parseInt(n_before_height/2);
	   n_select_height = (98-n_before_height);

	   if(before_id != 0) {
          document.getElementById("people_list_"+before_id).style.height = n_before_height +"px";
	   }

       document.getElementById("people_list_"+select_id).style.height = n_select_height +"px";
	   document.getElementById("people_list_"+select_id).style.display = "";
	   time_id = setTimeout(MoveTab,70);
    } else {
	   if(before_id != 0) {
	      document.getElementById("people_list_"+before_id).style.display = "none";
          document.getElementById("people_list_"+before_id).style.height = "0px";
	   }

       document.getElementById("people_list_"+select_id).style.height = "110px";

	   if(before_id != 0) {
		  if(before_id==1) {
		     src_url = "/images/main/tit_model_off.gif";
		  } else {
		     src_url = "/images/main/tit_designer_off.gif";
		  }
	      document.getElementById("people_head_"+before_id).src = src_url;
	   }

       if(select_id==1) {
	      src_url = "/images/main/tit_model_on.gif";
	   } else {
		  src_url = "/images/main/tit_designer_on.gif";
	   }

	   document.getElementById("people_head_"+select_id).src = src_url;
	   clearTimeout(time_id);
	   move_stat = 0;
	}
	
 }

 function GoEvent(n,select_index,n_index) {
    var i, src_url;

    for(i=1;i<=n;i++) {
		if(i==n_index) {
           document.getElementById("event_area_" + i).style.display = "";
		} else {
           document.getElementById("event_area_" + i).style.display = "none";
		}
	}

	for(i=1;i<=n;i++) {
		if(i==n_index) {
		   src_url = "http://img3.doosanmagazine.gscdn.com/style/images/main/event_no" + i
		   src_url = src_url + "_on.gif";
		} else {
		   src_url = "http://img3.doosanmagazine.gscdn.com/style/images/main/event_no" + i
		   src_url = src_url + "_off.gif";
		}

		document.getElementById("event_" + n_index + "_img_" + i).src = src_url;
	}
 }

 function MoveDList(n_index) {
    var get_url;

    get_url = "/main/collection_module.asp?n_index=" + n_index;
	GetAjaxInfoA(true,get_url,"MoveDList_result");
 }

 function MoveDList2(n_index) {
    var get_url;

    get_url = "/main/collection_area.asp?n_index=" + n_index;
	GetAjaxInfoA(true,get_url,"MoveDList_result");
 }

 function MoveDList_result(msg) {
    if(msg.indexOf("-1[sp]") != -1) {
	   return;
	}

	document.getElementById("designer_list_area").innerHTML = msg;
 }

 function GoCollection(d_code) {
    SearchDesignerForm.d_code.value = d_code;
	SearchDesignerForm.submit();
 }

 function GoMGN(n_index) {
    var get_url;

    get_url = "/main/inmgn_module.asp?n_index=" + n_index;
	GetAjaxInfoA(true,get_url,"GoMGN_result");
 }

 function GoMGN_result(msg) {
    if(msg.indexOf("-1[sp]") != -1) {
	   return;
	}

	document.getElementById("inmgn_area").innerHTML = msg;
 }

 function onover_blogger(nID,c_idx) {
	var i, obj, get_url;

	for(i=0;i<4;i++) {
        obj = document.getElementById("blogger_"+i); 
		if(i==nID) {
	       obj.className = "blog_txt2";
	    } else {
		   obj.className = "blog_txt";
		}
	}

    get_url = "/main/blogger_thum_area.asp?c_idx=" + c_idx;
	GetAjaxInfoA(true,get_url,"onover_blogger_result");
 }

 function onover_blogger_result(msg) {
    if(msg.indexOf("-1[sp]") != -1) {
	   return;
	}

	document.getElementById("main_blogger_thumb").innerHTML = msg;
 }

 function onover_shopping_tab(n_index) {
	var get_url, obj

    if(n_index==0) {
	   obj = document.getElementById("shopping_tab_0");
	   obj.src = "/images/main/tit_fitem_on.gif"
	   obj.style.cursor = "";
	   obj = document.getElementById("shopping_tab_1");
	   obj.src = "/images/main/tit_bitem_off.gif"
	   obj.style.cursor = "pointer";
	   obj.onmouseover = function() {onover_shopping_tab(1)};
	} else {
	   obj = document.getElementById("shopping_tab_0");
	   obj.src = "/images/main/tit_fitem_off.gif"
	   obj.style.cursor = "pointer";
	   obj.onmouseover = function() {onover_shopping_tab(0)};
	   obj = document.getElementById("shopping_tab_1");
	   obj.src = "/images/main/tit_bitem_on.gif"
	   obj.style.cursor = "";
	}

    get_url = "/main/shopping_area.asp?n_index=" + n_index;
	GetAjaxInfoA(true,get_url,"onover_shopping_tab_result");
 }

 function onover_shopping_tab_result(msg) {
    if(msg.indexOf("-1[sp]") != -1) {
	   return;
	}

	document.getElementById("main_shopping_area").innerHTML = msg;
 }

 function main_index_add(n) {
	if(main_center_index[n] >= 2) {
	   main_center_index[n] = 0;
	} else {
	   main_center_index[n] = main_center_index[n] + 1;
	}
 }

 function main_index_minus(n) {
	var i;

	if(main_center_index[n] <= 0) {
	   main_center_index[n] = 2;
	} else {
	   main_center_index[n] = main_center_index[n] - 1;
	}
 }

 function PreMoveCell(id) {
	var mode, get_url;

    main_index_minus(id-1)

    for(i=1;i<=3;i++) {
		if(i == (main_center_index[id-1]+1)) {
			var img_1 = $("#IMG_URL_" + id + "_" + ((i-1)*2) ).attr('value');
			var img_2 = $("#IMG_URL_" + id + "_" + (((i-1)*2)+1) ).attr('value');
			if( typeof(img_1) != "undefined" ) {
				$("#MainImageLink_"+id+"_"+((i-1)*2)).html('<img src="'+img_1+'" border="0">');
			}
			if( typeof(img_2) != "undefined" )
				$("#MainImageLink_"+id+"_"+(((i-1)*2)+1)).html('<img src="'+img_2+'" border="0">');
	       document.getElementById("main_cell_" + id + "_"+i).style.display = "";
		} else {
	       document.getElementById("main_cell_" + id + "_"+i).style.display = "none";
		}
	}
 }

 function NextMoveCell(id) {
	var mode, get_url;

    main_index_add(id-1)

    for(i=1;i<=3;i++) {
		if(i == (main_center_index[id-1]+1)) {
			var img_1 = $("#IMG_URL_" + id + "_" + ((i-1)*2) ).attr('value');
			var img_2 = $("#IMG_URL_" + id + "_" + (((i-1)*2)+1) ).attr('value');
			if( typeof(img_1) != "undefined" ) {
				$("#MainImageLink_"+id+"_"+((i-1)*2)).html('<img src="'+img_1+'" border="0">');
			}
			if( typeof(img_2) != "undefined" )
				$("#MainImageLink_"+id+"_"+(((i-1)*2)+1)).html('<img src="'+img_2+'" border="0">');
	       document.getElementById("main_cell_" + id + "_"+i).style.display = "";
		} else {
	       document.getElementById("main_cell_" + id + "_"+i).style.display = "none";
		}
	}
 }

 function onclick_starstyle() {
    if(document.getElementById("main_starstyle_1").style.display == "") {
	   document.getElementById("main_starstyle_1").style.display = "none";
	   document.getElementById("main_starstyle_2").style.display = "";
	} else {
	   document.getElementById("main_starstyle_1").style.display = "";
	   document.getElementById("main_starstyle_2").style.display = "none";
	}
 }

 $(document).ready(function() {
     $(".shop_next").show();
	 $(".shop_next li:first").addClass("shop_next_on");
	 
	 var contentHeight = 80;
	 var contentSum = $(".shopping_content img").size();
	 var contentTotalHeight = contentHeight * contentSum;
     var n_index = 1;var pre_index = 0;

     // starstyle
	 var star_tid

	 $(".shopping_content").css({'height' : contentTotalHeight});
     $(".shopping_content").css({'top' : -80*(contentSum-1)});

//	 $(".paging").show();
	 
	 var contentWidth2 = 311;
	 var contentSum2 = $(".image_reel script").size();
	 var contentTotalWidth2 = contentWidth2 * contentSum2;

	 $(".image_reel").css({'width' : contentTotalWidth2});

	 rotate = function() {
		 var triggerID = $active.attr("rel") - 1;
		 var contentPosition = -80*(contentSum-1) + (triggerID * contentHeight);
		 
		 $(".shop_next li").removeClass('shop_next_on');
		 $active.addClass('shop_next_on');

         if(contentPosition != -80*(contentSum-1)) {
		    $(".shopping_content").animate({
			    top: contentPosition
		    }, 500);
		 } else {
		    $(".shopping_content").css({'top' : -80*(contentSum-1)});
		 }

	 };

	 rotate2 = function() {
		 var triggerID = $active2.attr("rel") - 1;
		 var contentPosition = -(triggerID * contentWidth2);
	 
         $pre_active2.removeClass('paging_'+pre_index+'_on');
		 $pre_active2.addClass('paging_'+pre_index);
         $active2.removeClass('paging_'+(triggerID+1));
		 $active2.addClass('paging_'+(triggerID+1)+'_on');

		 $(".image_reel").animate({
			    left: contentPosition
		 }, 500);
	 };

	 rotateStart = function () {
		 play = setInterval(function() {
			 $active = $('.shop_next li.shop_next_on').next();
			 if($active.length == 0) {
			    $active = $('.shop_next li:first');
			 }
			 rotate();
		 },2000);
	 };

	 rotateStart2 = function () {
		 play2 = setInterval(function() {
			 pre_index = n_index;
			 $pre_active2 = $('.paging li.paging_'+n_index+'_on');
			 $active2 = $('.paging li.paging_'+n_index+'_on').next();
			 if($active2.length == 0) {
			    $active2 = $('.paging li:first');
				n_index = 1;
			 } else {
				n_index++;
			 }
			 rotate2();
		 },5000);
	 };

     rotateStarStyle = function() {
	     star_tid = setInterval(function() {
             onclick_starstyle();
         },3000);
	 };

	 rotateStart();
	 rotateStart2();
     rotateStarStyle();

	 $(".shopping_content div").hover(function() {
		 clearInterval(play);
	 }, function() {
		 
	 });

	 $(".shop_next li").hover(function() {
		 $active = $(this);
		 rotate();
		 clearInterval(play);
		 return false;
	 }, function() {

	 });

	 $(".shopping_content").hover(function() {
	 }, function() {
		 e = $(this);
         var t = e ? e.relatedTarget : event.toElement;
	     while(t){
		  if(t == e) return;
		  t = t.parentNode;
	     }
	     rotateStart();
	 });

	 $(".shop_next").hover(function() {
	 }, function() {
		 e = $(this);
         var t = e ? e.relatedTarget : event.toElement;
	     while(t){
		  if(t == e) return;
		  t = t.parentNode;
	     }
	     rotateStart();
	 });

	 $(".image_reel").hover(function() {
		 clearInterval(play2);
	 }, function() {
		 
	 });

	 $(".paging li").hover(function() {
		 pre_index = n_index;
		 $pre_active2 = $('.paging li.paging_'+n_index+'_on');
		 $active2 = $(this);
		 n_index = parseInt($active2.attr("rel"));
		 rotate2();
		 clearInterval(play2);
		 return false;
	 }, function() {

	 });

	 $(".image_reel").hover(function() {
	 }, function() {
		 e = $(this);
         var t = e ? e.relatedTarget : event.toElement;
	     while(t){
		  if(t == e) return;
		  t = t.parentNode;
	     }
	     rotateStart2();
	 });

     // starstyle ÄÁÅÙÃ÷¿µ¿ª ¸¶¿ì½º mouseover, mouseover
	 $(".star_list").hover(function() {
		 clearInterval(star_tid);
	 }, function() {
		 e = $(this);
         var t = e ? e.relatedTarget : event.toElement;
	     while(t){
		  if(t == e) return;
		  t = t.parentNode;
	     }
	     rotateStarStyle();
	 });

     // starstyle ¹öÆ° ¸¶¿ì½º mouseover, mouseover
	 $(".star_btn").hover(function() {
		 clearInterval(star_tid);
	 }, function() {
	     rotateStarStyle();
	 });
 });
