function removeAllItem(){
	document.getElementById('photoArray').length = 0;
	//전체 삭제시 이미지 배열을 초기화
	document.getElementById('photoWidthArray').value = "";
	document.getElementById('photoHeightArray').value = "";
}
function removeItem(){
	var widthObj = document.getElementById('photoWidthArray');
	var heightObj = document.getElementById('photoHeightArray');
	
	var widthObjTemp = "";
	var heightObjTemp = "";

	var widthObjTempResult = "";
	var heightObjTempResult = "";

	var Obj = document.getElementById('photoArray');

	//선택된 항목이 있을때만 실행
	if(Obj.selectedIndex != -1){
		
		//현재 이미지사이즈를 분해한다.
		widthObjTemp = widthObj.value.split("|:|");
		heightObjTemp = heightObj.value.split("|:|");

		//삭제 선택된 인덱스의 이미지 사이즈를 제외하고 다시 만든다.
		for (var k=0 ; k < widthObjTemp.length ; k++){
			if (Obj.selectedIndex != k){
				if (widthObjTempResult == "")	widthObjTempResult = widthObjTemp[k];
				else							widthObjTempResult += "|:|" + widthObjTemp[k];

				if (heightObjTempResult == "")	heightObjTempResult = heightObjTemp[k];
				else							heightObjTempResult += "|:|" + heightObjTemp[k];
			}
		}
		//삭제 이미지 셀렉트 값 삭제
		Obj[Obj.selectedIndex] = null;		
		
		//현재 이미지 사이즈 값에 다시 셋팅
		widthObj.value = widthObjTempResult;
		heightObj.value = heightObjTempResult;
	}
}

function setCurrent(val)
{
	current = val;
}

function Thum_Click_Photo(val) {
	if (val == prevNum)
	{
		document.getElementById("list" + val).style.background = "url('" + domain_webimg + "/contest/bg_thumb_contest_on.gif') no-repeat left top";
		document.getElementById("list" + val).style.padding = "3px 4px 4px 4px";
		document.getElementById("list" + val).style.margin = "0px";
		document.getElementById("thumb_img" + val).style.opacity = 1;
		document.getElementById("thumb_img" + val).style.MozOpacity = 1;
		document.getElementById("thumb_img" + val).style.filter = "alpha(opacity=100); opacity:1;";
		document.getElementById("big_img").src = domain_img + "/contest/" + udate + "/" + me_idx + "/" + val + ".jpg";
	}
	else
	{		
		if (prevNum < 6)
		{
			document.getElementById("list" + prevNum).style.backgroundImage = "none";
			document.getElementById("list" + prevNum).style.background = "#000";
			document.getElementById("list" + prevNum).style.margin = "3px 4px 4px 4px";
			document.getElementById("list" + prevNum).style.padding = "0px";
		//	document.getElementById("thumb_img" + prevNum).style.opacity = 0.5;
		//	document.getElementById("thumb_img" + prevNum).style.MozOpacity = 0.5;
		//	document.getElementById("thumb_img" + prevNum).style.filter = "alpha(opacity=50); opacity:0.5;";
		}

		document.getElementById("list" + val).style.background = "url('" + domain_webimg + "/contest/bg_thumb_contest_on.gif') no-repeat left top";
		document.getElementById("list" + val).style.padding = "3px 4px 4px 4px";
		document.getElementById("list" + val).style.margin = "0px";
		document.getElementById("thumb_img" + val).style.opacity = 1;
		document.getElementById("thumb_img" + val).style.MozOpacity = 1;
		document.getElementById("thumb_img" + val).style.filter = "alpha(opacity=100); opacity:1;";
		document.getElementById("big_img").src = domain_img + "/contest/" + udate + "/" + me_idx + "/" + val + ".jpg";
	}

	prevNum = val;
	current = prevNum;
}

function imgOver_Photo(val) {
	if(prevNum != current) {
		document.getElementById("thumb_img" + prevNum).style.opacity = 0.5;
		document.getElementById("thumb_img" + prevNum).style.MozOpacity = 0.5;
		document.getElementById("thumb_img" + prevNum).style.filter = "alpha(opacity=50); opacity:0.5;";
	}

	if (val != current)
	{
		document.getElementById("thumb_img" + val).style.opacity = 1;
		document.getElementById("thumb_img" + val).style.MozOpacity = 1;
		document.getElementById("thumb_img" + val).style.filter = "alpha(opacity=100); opacity:1;";
	}
	
	prevNum = current;
}

function imgOut_Photo(val) {
	if(val != current) {
		document.getElementById("thumb_img" + val).style.opacity = 0.5;
		document.getElementById("thumb_img" + val).style.MozOpacity = 0.5;
		document.getElementById("thumb_img" + val).style.filter = "alpha(opacity=50); opacity:0.5;";
	}

	prevNum = current;
}

// Navigation 처리 부분
function Change_Btn_Photo(type, pcnt)
{
	var val;

	if (type == 2)
	{
		val = prevNum + 1;

		if (val > pcnt)
			val = 1;
	}
	else
	{
		val = prevNum - 1;

		if (val == 0)
			val = pcnt;
	}

	starPhotoDetailRequest(il_idx, val);
	prevNum = val;
}

function Go_Contest_Delete(kind)
{
	UpdateRequest("/contest/profile_delete_proc.html", "kind=" + kind);
}

function Go_Contest_RDelete(il_idx, ir_idx, rpg, rtc, ir_nickname)
{
	fn_winopen_center("/contest/pop_del_cmt.html?ir_idx=" + ir_idx + "&il_idx=" + il_idx + "&rpg=" + rpg + "&rtc=" + rtc + "&ir_nickname=" + escape(ir_nickname),"popup_delete",350,218,"no");
}

function profile_delete(kind)
{
	fn_winopen_center("/contest/pop_del_profile.html?kind=" + kind,"popup_pdelete",350,218,"no");
	//Popup_Window("url", "/contest/pop_del_profile.html?kind="+kind, 350, 218, null, null);
}

function Contest_Rec(kind, il_idx, pg, tc, searchstr)
{
	UpdateRequest("/contest/recommand_proc.html", "kind=" + kind + "&il_idx=" + il_idx + "&pg=" + pg + "&tc=" + tc + "&searchstr=" + escape(searchstr));
}
//추천하기 정보 요청
function RecommandRequest(kind, il_idx, pg, tc, searchstr) {
	var url = "/contest/recommand_proc.html"; 
	var params = "kind=" + kind + "&il_idx=" + il_idx + "&pg=" + pg + "&tc=" + tc + "&searchstr=" + escape(searchstr);
	//alert(params);
	sendRequest4(url, params, RecommandCallBack, "POST", true);
}
//추천하기 정보 콜백
function RecommandCallBack() {
	var result;

	if (httpRequest4.readyState == 4) {//alert(httpRequest4.status);
		if (httpRequest4.status == 200){
			result = httpRequest4.responseText.split("#");

			if (result[1] == "0000")
			{
				fn_winopen_center("/popup/pop_chk_error.html?ret_msg=" + escape(result[2]),"popup_ok",350,218,"no");
			}
			else
				fn_winopen_center("/popup/pop_chk_error.html?RCode=" + result[1],"popup_fail",350,218,"no");
		}
		else if (httpRequest4.status == 204)	{alert('페이지 에러입니다.다시한번 시도해주세요.');	}//데이터가 존재하지 않을 경우
	}
}

function ContestImg_View(idx, udate, num)
{
	window.open("/contest/photo_view.html?idx=" + idx + "&udate=" + udate + "&pnum=" + num, "Detail_Image", "width=100,height=100,toolbar=no,menubar=no,scrollbars=no");
}

function Layer_Pop()
{
	if(getCookie("Contest") != "done"){
		ContestLayer(430, 484);
	}
}

function ContestLayer(pwidth, pheight) {
	var target1 = document.getElementById("CloseLayer");

	target1.style.left = ((document.documentElement.clientWidth/2) - (pwidth/2)) + "px";
	target1.style.top = ((document.documentElement.clientHeight/2) - (pheight/2)) + "px";

	if(target1.style.display == "none")	{
		target1.style.display = "block";
	}
	else {
		target1.innerHTML = '';
		target1.style.display = "none";
	}
}

function setCookie(name, value, expires) {
	var todayDate = new Date(); 
	todayDate.setDate(todayDate.getDate() + expires);

	document.cookie = name + "=" + escape (value) + "; path=/; domain="+document.domain+"; expires=" + todayDate.toGMTString();
}

function getCookie(name)
{
	var nameOfCookie = name + "=";
	var x = 0;
	while (x <= document.cookie.length)	// 쿠키가 설정되어 있다면
	{
		var y = (x+nameOfCookie.length);
		if (document.cookie.substring(x, y) == nameOfCookie)
		{
			if ((endOfCookie = document.cookie.indexOf(";", y)) == -1)
				endOfCookie = document.cookie.length;
					
			return unescape(document.cookie.substring(y, endOfCookie));
		}
		
		x = document.cookie.indexOf( " ", x ) + 1;
		
		if (x == 0)
			break;
	}
	return "";
}