$(document).ready(function(){
  /*------------------------------
           onLoad Script
  ------------------------------*/
  cur = $("#container").attr("class");
  //  alert(cur);

  switch (cur)
  {
  case "co_main": // if Community Mainpage
    loadCommunityMain();
    break;
  case "co_review_heaven": // if Community > Review Heaven
    loadCommunityReview();
    break;
  case "co_talk_play": // if Community > Talk & Play
    loadCommunityTalkPlay();
    break;
  case "co_life_style": // if Community > Life Style
    loadCommunityLifeStyle();
    break;
  case "co_mania": // if Community > Onliving Mania
    loadCommunityMania();
    break;
  case "co_zoomin": // if Community > Zoomin
    loadCommunityZoomin();
    break;
  case "co_cafe": // if Community > Cafe
    loadCommunityCafe();
    break;
  default:
    break;
  }

  /* Default */
  $("#main_model > img").ifixpng();
  $("#cur_position > ul").after($("#cur_position > span"));
  bestIconAdd();
  bestIconAdd2();
  allCategoryOpen();
  boardHover();
  categoryTabs();
});

function categoryTabs(){
  lis = $(".tabs > ul > li[class*='on']");
  lis.prev().css("background-position","left top");
  lis.next().css("background-position","left top");
}

function uccRankingHover(){
  $(".ucc_ranking > ul > li").hover(
    function(){
      $(this).children("span").children("img").attr("width","76").attr("height","76").css("border","3px solid #79a8b3");
    },
    function(){
      $(this).children("span").children("img").attr("width","82").attr("height","82").css("border","0px");
  });
}

/* Talk & Play Knowledgein Help */
function knowin_help(){

  if($(".pop_help").css("display") == "block"){
    $(".pop_help").hide("slow");
  }else{
    $(".pop_help").show("slow").css("border-left","3px solid #FF8080");
  }
  $(".pop_help > .pop_wrapper > .btn_close").click(function(){
    $(".pop_help").hide("slow");
    return false;
  });
}

/* Table Board Mouse Hover Effect */
function boardHover(){
    $(".bbs_list > table[class != 'bo_03'] > tbody > tr").hover(
    function(){
      $(this).css("background-color","#f1f1f1");
    },
    function(){
      $(this).css("background-color","#fff");
    }
  );
}

/* Reply Write/List Open/Close */
function replyOpen(obj){
  xxx = $(obj).parents("div:eq(0)");
  if(xxx.next(".reply_write").css("display") == "block"){
    $(obj).css("background-position","left top");
    xxx.siblings().hide();
  }else{
    $(obj).css("background-position","left bottom");
    xxx.siblings().show();
  }
}

/* Community Main Onload Script */
function loadCommunityMain() {
  $("#tab_ucc > ul").tabs();
  $("#tab_wife_blog > ul").tabs();
  $("#rev_house > ul").tabs();
  $("#pr_write > p:last-child").css("background-image","none").css("border-bottom","1px solid #DBDBDB");
  $("#ho_proposal > dl:last-child").css("width","85px");
  $("#tab_ucc_total > dl:last-child").css("margin-right","0");
  $("#tab_ucc_movie > dl:last-child").css("margin-right","0");
  $("#tab_ucc_image > dl:last-child").css("margin-right","0");
}
function loadCommunityReview(){
  /* No Scripting */;
}
function loadCommunityTalkPlay(){
  uccRankingHover();
  /* No Scripting */
}
function loadCommunityLifeStyle(){
  /* No Scripting */
}
function loadCommunityMania(){
  /* No Scripting */
}
function loadCommunityZoomin(){
  /* No Scripting */
}
function loadCommunityCafe(){
  /* No Scripting */
}

/* Best Icon */
function bestIconAdd() {
  $(".pr_review > dl > dd").append($(".ic_best"));
  $(".pr_review > dl > dd > div[class='ic_best']").css("display","block");
  $(".pr_review > dl > dd > div[class='ic_best'] > img").ifixpng();
}

/* Best Icon */
function bestIconAdd2() {
  $("#pro_best > dl > dt").append($(".ico_best"));
  $("#pro_best > dl > dt > div[class='ico_best']").css("display","block");
  $("#pro_best > dl > dt > div[class='ico_best'] > img").ifixpng();
}

/* All Category Open */
function allCategoryOpen() {
  if( ($("#btn_category").hasClass("off")) == true ){  $("#category_list").hide(); $("#category_list2").hide(); }
  $("#btn_category").click(
    function(){
      $("#category_list").slideToggle("slow");$("#category_list2").slideToggle("slow");
    }
  );
}

/* Tab Change */
function tabChange(obj){
  id = obj.href.split("#");
  $("#rev_house > ul > li").css("background-position","left bottom");
  $("."+id[1]).css("background-position","left top");
};

function tabChange2(fig){
	var li	= document.getElementById("rank").getElementsByTagName("LI");
	if(fig){
		li[0].style.backgroundPosition = "bottom";
		li[1].style.backgroundPosition = "top";
		document.getElementById("tab_rank_0").className = "d_none";
		document.getElementById("tab_rank_1").className = "d_on";
	}else{
		li[0].style.backgroundPosition = "top";
		li[1].style.backgroundPosition = "bottom";
		document.getElementById("tab_rank_0").className = "d_on";
		document.getElementById("tab_rank_1").className = "d_none";
	}
};

/* Popup Window */
function openWin(obj, id, w, h) {
	window.open(obj.href ,id,'toobar=no,scrollbars=no,menubar=no,status=no,directories=no, resizable=no,width='+w+',height='+h);
}

// flashWrite
function flashWrite(url,w,h,vars,bg,win){

	var id=url.split("/")[url.split("/").length-1].split(".")[0]; //id´Â ÆÄÀÏ¸íÀ¸·Î ¼³Á¤
	if(vars==null) vars='';
	if(bg==null) bg='#FFFFFF';
	if(win==null) win='transparent';

	function BrowserCheck() {
	appname = navigator.appName;
	useragent = navigator.userAgent;
	 if(appname == "Microsoft Internet Explorer") appname = "IE";
	 IE55 = (useragent.indexOf('MSIE 5.5')>0);  //5.5 ¹öÀü
	 IE6 = (useragent.indexOf('MSIE 6')>0);     //6.0 ¹öÀü

	 if(appname=="IE" && IE55 || IE6) vars = 'ieVer=6'; //ÀÍ½ºÇÃ·Î·¯ÀÌ¸é¼­ 5.5 or 6.0 ¹öÀüÀÌ¸é...
	 else vars= 'ieVer=7';
	}
  //	onload=BrowserCheck;

	// ÇÃ·¡½Ã ÄÚµå Á¤ÀÇ
	var flashStr= "	<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'";
		flashStr+="			codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0'";
		flashStr+="			width='"+w+"'";
		flashStr+="			height='"+h+"'";
		flashStr+="			id='"+id+"'";
		flashStr+="			align='middle'>";

		flashStr+="		<param name='allowScriptAccess' value='always' />";
		flashStr+="		<param name='movie' value='"+url+"' />";
		flashStr+="		<param name='FlashVars' value='"+vars+"' />";
		flashStr+="		<param name='wmode' value='"+win+"' />";
		flashStr+="		<param name='menu' value='false' />";
		flashStr+="		<param name='quality' value='high' />";
		flashStr+="		<param name='bgcolor' value='"+bg+"' />";
    flashStr+="		<param name='base' value='.' />";


		flashStr+="		<embed base ='.' src='"+url+"'";
		flashStr+="		       flashVars='"+vars+"'";
		flashStr+="		       wmode='"+win+"'";
		flashStr+="		       menu='false'";
		flashStr+="		       quality='high'";
		flashStr+="		       bgcolor='"+bg+"'";
		flashStr+="		       width='"+w+"'";
		flashStr+="		       height='"+h+"'";
		flashStr+="		       name='"+id+"'";
		flashStr+="		       align='middle'";
		flashStr+="		       allowScriptAccess='always'";
		flashStr+="		       type='application/x-shockwave-flash'";
		flashStr+="		       pluginspage='http://www.macromedia.com/go/getflashplayer' />";
		flashStr+=" </object>";

	// ÇÃ·¡½Ã ÄÚµå Ãâ·Â
	document.write(flashStr);
}
/**************************************************************************
*
*               showlayer & hidelayer
*
**************************************************************************/
function showlayer(lay) {
  		document.getElementById(lay).style.display = document.getElementById(lay).style.display == "none" ? "" : "none";
};

/* Function **************************************************************/

/**************************************************************************
*
*				type Name
*
**************************************************************************/
	function typeName(type_){
		var type = typeof type_;
		if(type == "object"){
			if(type_.constructor == Array)
				return	"array";
			else if(/[A-Z]/.test(type_.tagName))
				return	"element";
		}
		return type;
	};

/**************************************************************************
*
*				elements
*
**************************************************************************/
	function el(){
		var owner, i = 0;
		if(typeName(arguments[i]) == "element")
			owner	= arguments[i ++];
		if(!arguments[i])
			return	owner || document;
		if(arguments.length > i + 1){
			var array	= [];
			for(var len = arguments.length; i < len; i ++)
				array.push(owner ? el(owner, arguments[i]) : el(arguments[i]));
			return array;
		}

		return	/[^A-Z]/.test(arguments[i]) ?
				document.getElementById(arguments[i]) :
				(owner || document).getElementsByTagName(arguments[i]);
	};	
