
var imgScrapOn  = "http://img.incruit.com/common/icon/icon_scrap_ok.gif";
var imgScrapOff = "http://img.incruit.com/common/icon/icon_scrap_no.gif";

/*------------------------------------------------------------------------------
[public] ³»°¡ ½ºÅ©·¦ÇÑ °ø°í¿¡ Ã¼Å©Ç¥½ÃÇÏ±â
Parameters: type      ½ºÅ©·¦ Å¸ÀÔ (AlbJob, PaperJob...)
			seq_list  ´ë»ó °ø°í¹øÈ£¸®½ºÆ® (±¸ºÐÀÚ(,))
Returns   : href
Example   : callScrapCheck('AlbaJob', '2009050409332,2009050403160,2009050403446')
Date      : 2009-06-17(ÃÖ¼ö¾Æ)
--------------------------------------------------------------------------------*/
function callScrapCheck(type, seq_list, prefix)
{
	var ajaxHelper   = new AJAXHelper()
	var arrParams    = new Array(3)
	    arrParams[0] = new Array("act" , "S");
	    arrParams[1] = new Array("type", type);
	    arrParams[2] = new Array("prefix", prefix);
	    arrParams[3] = new Array("seq_list", seq_list);

	var callback = new callbackScrapCheck();
	ajaxHelper.CallAnotherReturnCustom("/g_common/bizcommon/scrap_ajax.asp", arrParams, callback);
}

function callbackScrapCheck(){}
callbackScrapCheck.prototype.ExecuteAJAXComplete = function(returnedXML) {
	eval(returnedXML);
	return;
}

/*------------------------------------------------------------------------------
[public] ½ºÅ©·¦ Ãß°¡ÇÏ±â
Parameters: type        ½ºÅ©·¦ Å¸ÀÔ (AlbJob, PaperJob...)
			company_no  ±â¾÷¹øÈ£
			mem_no      ±â¾÷ÀÇ È¸¿ø ¹øÈ£
			job_post_no ½ºÅ©·¦ÇÒ °ø°í ¹øÈ£
Returns   : href
Example   : callScrapAdd('AlbaJob', '', '', '')
Date      : 2009-06-17(ÃÖ¼ö¾Æ)
--------------------------------------------------------------------------------*/
function callScrapAdd(type, company_no, mem_no, job_post_no, prefix)
{
	var imgObj = $("icon_scrap_"+prefix+"_"+job_post_no);
	var act    = (imgObj.src == imgScrapOn) ? "D" : "I";

	var ajaxHelper   = new AJAXHelper()
	var arrParams    = new Array(5)
	    arrParams[0] = new Array("act"	  , act);
	    arrParams[1] = new Array("type"	  , type);
	    arrParams[2] = new Array("company", company_no);
	    arrParams[3] = new Array("mem"    , mem_no);
	    arrParams[4] = new Array("job"    , job_post_no);
	    arrParams[5] = new Array("prefix" , prefix);

	var callback = new callbackScrapAdd(type, act, job_post_no, prefix);
	ajaxHelper.CallAnotherReturnCustom("/g_common/bizcommon/scrap_ajax.asp", arrParams, callback);
}

function callbackScrapAdd(type, act, job_post_no, prefix){
	this.type         = type;
	this.act          = act;
	this.job_post_no  = job_post_no;
	this.prefix       = prefix;
}
callbackScrapAdd.prototype.ExecuteAJAXComplete = function(returnedXML) {

	var error_no = 0;
	var imgId    = "icon_scrap_"+this.prefix+"_"+this.job_post_no;
	var count    = 0;

	eval(returnedXML);

	// login ÆäÀÌÁö ÀÌµ¿
	if (error_no == 1000) {
		var url = document.URL;
		location.href = G_HOSTNAME_EDIT + "/login/login.asp?gotoURL=" + escape(url);
		return;
	// ±â¾÷È¸¿ø Ã¼Å©
	} else if (error_no == 2000) {
		alert("°³ÀÎÈ¸¿øÀ¸·Î ·Î±×ÀÎÇØÁÖ¼¼¿ä.");
		return;
	}

	if (returnedXML.indexOf("alert") == 0) return;

	switch(this.act)
	{
		case "I" :
			doScripChecked(imgId);
			count = 1;
			break;

		case "D" :
			callScrapDel(this.type, this.job_post_no, this.prefix);
			doScripUndoChecked(imgId);
			count = -1;
			break;
	}

	// ÇÏ´Ü ·¹ÀÌ¾î Ä«¿îÆ® ¾÷µ¥ÀÌÆ®
	if ( this.type.toLowerCase() == 'albjob' && $("gScrapCount") != null ) {

		if ( typeof $("gScrapCount").outerText != "undefined" )
	        $("gScrapCount").innerHTML = parseInt($("gScrapCount").outerText) + count;
		else
			$("gScrapCount").innerHTML = parseInt($("gScrapCount").text) + count;

	} else if ( this.type.toLowerCase() == 'incjob' && $("IncScrapCount") != null ) {

		if ( typeof $("IncScrapCount").outerText != "undefined" )
	        $("IncScrapCount").innerHTML = parseInt($("IncScrapCount").outerText) + count;
		else
			$("IncScrapCount").innerHTML = parseInt($("IncScrapCount").text) + count;
	}

	// ÇÏ´Ü ·¹ÀÌ¾î ³»¿ë ¾÷µ¥ÀÌÆ®
	if (typeof isQuickLayerOpen != 'undefined') {
		if (isQuickLayerOpen && $("RecentLayerTy")) {
			switch($F("RecentLayerTy")) {
				case "2" : quickLayer_Show('inc', '2'); break;
				case "6" : quickLayer_Show('alb', '6'); break;
				case "7" : quickLayer_Show('alb', '7'); break;
			}
		}
	}
	return;
}


/*------------------------------------------------------------------------------
[public] ½ºÅ©·¦ Ã¼Å© ÀÌ¹ÌÁö ¼ÂÆÃÇÏ±â
Parameters: imgId       Ã¼Å© ÀÌ¹ÌÁö ID
			imgUrl      ÀÌ¹ÌÁö URL
Returns   : href
Example   : icon_scrap_VIP_2010012700002
Date      : 2009-06-17(ÃÖ¼ö¾Æ)
            2010-01-29(¼Õ¼ºÈÆ) - µ¿ÀÏ °ø°í¹øÈ£ ÀÏ°ý Ã¼Å© (strImgPrefix Á¾·ù : "logo", "vip", "top", "")
--------------------------------------------------------------------------------*/

function doScripChecked(imgId)
{
	/*
	var imgObj = $(imgId);

	if(typeof imgObj != "undefined")
	{
		imgObj.src          = imgScrapOn;
		imgObj.title	    = "½ºÅ©·¦¿Ï·á";
		imgObj.alt		    = "½ºÅ©·¦¿Ï·á";
	}
	*/
	var imgObj = $(imgId);
	var arrScrap = new Array();
	var ImgPrefix = new Array("logo", "vip", "top", "");
	var tmpImgId

	arrScrap = imgId.split("_");

	for (var i=0; i < ImgPrefix.length; i++)
	{
		tmpImgId = $(eval("document.getElementById(\""+arrScrap[0]+"_"+arrScrap[1]+"_"+ImgPrefix[i]+"_"+arrScrap[3]+"\");"));

		if(tmpImgId == null) {
			//alert(ImgPrefix[i]);
		} else {

			imgObj = $(eval(arrScrap[0]+"_"+arrScrap[1]+"_"+ImgPrefix[i]+"_"+arrScrap[3]));

			imgObj.src          = imgScrapOn;
			imgObj.title	    = "½ºÅ©·¦¿Ï·á";
			imgObj.alt		    = "½ºÅ©·¦¿Ï·á";
		}
	}
}

function doScripUndoChecked(imgId)
{
	/*
	var imgObj = $(imgId);

	if(typeof imgObj != "undefined")
	{
		imgObj.src          = imgScrapOff;
		imgObj.title	    = "½ºÅ©·¦Àü";
		imgObj.alt		    = "½ºÅ©·¦Àü";
	}
	*/
	var imgObj = $(imgId);
	var arrScrap = new Array();
	var ImgPrefix = new Array("logo", "vip", "top", "");
	var tmpImgId

	arrScrap = imgId.split("_");

	for (var i=0; i < ImgPrefix.length; i++)
	{
		tmpImgId = $(eval("document.getElementById(\""+arrScrap[0]+"_"+arrScrap[1]+"_"+ImgPrefix[i]+"_"+arrScrap[3]+"\");"));

		if(tmpImgId == null) {
		//	alert(ImgPrefix[i]);
		} else {

			imgObj = $(eval(arrScrap[0]+"_"+arrScrap[1]+"_"+ImgPrefix[i]+"_"+arrScrap[3]));

			imgObj.src          = imgScrapOff;
			imgObj.title	    = "½ºÅ©·¦Àü";
			imgObj.alt		    = "½ºÅ©·¦Àü";
		}
	}
}

/*------------------------------------------------------------------------------
[public] ½ºÅ©·¦ »èÁ¦ÇÏ±â
Parameters: type        ½ºÅ©·¦ Å¸ÀÔ (AlbJob, PaperJob...)
			job_post_no ½ºÅ©·¦ÇÒ °ø°í ¹øÈ£
Returns   : href
Example   : callScrapDel('AlbJob', '', '')
Date      : 2009-06-24(ÀÌ¼±¹Ì)
--------------------------------------------------------------------------------*/
function callScrapDel(type, job_post_no, prefix)
{
	var ajaxHelper   = new AJAXHelper()
	var arrParams    = new Array(3)
		arrParams[0] = new Array("act"		, "D");
		arrParams[1] = new Array("type"		, type);
		arrParams[2] = new Array("job"		, job_post_no);
		arrParams[3] = new Array("prefix"   , prefix);
	var callback = new callbackScrapDel();
	ajaxHelper.CallAnotherReturnCustom("/g_common/bizcommon/scrap_ajax.asp", arrParams, callback);
}

function callbackScrapDel(){}
callbackScrapDel.prototype.ExecuteAJAXComplete = function(returnedXML) {

	if (returnedXML == "0") {
		alert('¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù. Àá½ÃÈÄ ´Ù½Ã ½ÃµµÇØÁÖ¼¼¿ä.');
		return;
	}
}


