	function SelectAll ( )
	{
		with ( document.InquiryForm )
		{
			for (i=1; i <= CheckBoxLength; ++i)
			{
				try{ eval("inquiry"+i); } catch ( e) { continue; }
				eval("inquiry"+i).checked = true;
			}
		}
	}

	function ClearAll ( )
	{
		with ( document.InquiryForm )
		{
			for (i=1; i <= CheckBoxLength; ++i)
			{
				try{ eval("inquiry"+i); } catch ( e) { continue; }
				eval("inquiry"+i).checked =  false;
			}
		}
	}

/*
	function intoTheBasket ( job, inquiry )
	{
		alert(inquiry);
		inquiry = inquiry +"~" + ( (getCookie(job)==null || getCookie(job) == "null") ? "" : getCookie(job) );
		alert(inquiry);
		setCookie ( job, inquiry );
		location.reload();
	}
*/
	function intoTheBasket ( job )
	{
		var inquiry = "";
		var argc = intoTheBasket.arguments.length;
		var argv = intoTheBasket.arguments;

		// ´ÜÀÏ Cookie( ¾÷Ã¼ È¨ÆäÀÌÁö)
		if (argc > 1)
		{
 		    var checkCount = getSelectCount();    // ÇöÀçÀÇ TotalCount			

			if(checkCount > 40 )
		    {
			alert("Sorry! You cannot send more than 40 inquiries at once.");
			return;
			}
			else{
				inquiry = argv[1] +"~" + ( (getCookie(job)==null || getCookie(job) == "null") ? "" : getCookie(job) );
				if (ExistInBasket ( job, argv[1] ) == true)
				{
					alert ('You have already selected this item.');
					return;
				}
			}
		}
		// ´ÙÁß Cookie (Search, New-Page)
		else
		{
			inquiry = gatherCheckBox ();
			if (inquiry){
			inquiry = inquiry + ( (getCookie(job)==null || getCookie(job) == "null") ? "" : getCookie(job) );
			}else{
				return;
			}
		}

		setCookie ( job, inquiry );
		location.reload();
	}


	function sendInquiry ( job )
	{
		var URL = "http://etrade.daegu.go.kr/app/servlet/RequestProcessor?event=SendInquiry.Click";
		var Param = "";
		var Mulit = "";
		var SelectedInquiry = gatherCheckBox ( ) ;
		if ( SelectedInquiry == null || SelectedInquiry == "")
		{
			alert('Please select an item(s).');
			return;
		}

//		Param = "fromwhere="+job+"&inq_data="+ SelectedInquiry;
	   if(SelectedInquiry.substring(0,SelectedInquiry.length-1).indexOf("~") > 0 ){
			Multi = "&multi=Y";
		}else{
			Multi = "";
		}
		Param = "&inq_data="+ SelectedInquiry.substring(0,SelectedInquiry.length-1);
		URL = URL + Multi +Param ;
//alert( URL);
		open_win ( URL, 300, 400 );
	}

	function gatherCheckBox (  )
	{
		var checkCount = getSelectCount();    // ÇöÀçÀÇ TotalCount
		var Inquiries = "";
		with ( document.InquiryForm )
		{
			for (i=1; i <= CheckBoxLength; ++i)
			{
				try{ eval("inquiry"+i); } catch ( e) { continue; }
				if(eval("inquiry"+i).checked == true)
					{
					Inquiries += eval("inquiry"+i).value +"~";
					checkCount ++;
				    }
			}
		}
		// basket¿¡ ´ãÀ» ¼ö ÀÖ´Â °¹¼ö : Max 40
		if(checkCount > 40)
		{
			alert("Sorry! You cannot send more than 40 inquiries at once.");
			return;
		} else {
    	    return Inquiries;
		}
	}

	function getSelectCount ( )
	{
		var TotalCount = 0;
		var inquiries = "";
		inquiries = getCookie ( "ProductInquiry" );
		collect = parseString ( inquiries, "~" );
		TotalCount += collect.length;

		inquiries = getCookie ( "TradeInquiry" );
		collect = parseString ( inquiries, "~" );
		TotalCount += collect.length;

		inquiries = getCookie ( "CompanyInquiry" );
		collect = parseString ( inquiries, "~" );
		TotalCount += collect.length;
		return TotalCount;
	}

	function ExistInBasket ( job, inquiry )
	{
		inquiries = getCookie ( job );
		collect = parseString ( inquiries, "~" );
		for (var i=0; i < collect.length; ++i)
		{
			if (collect[i] == inquiry)
			{
				return true;
			}
		}
		return false;
	}

	function deleteInquiryInBasket ( job, inquiry )
	{
		var NewInquiry = "";
		var key = inquiry.substring(0,inquiry.indexOf("~"));
//alert(key);
		inquiries = getCookie ( job );
		collect = parseString ( inquiries, "~" );
		for (var i=0; i < collect.length; ++i)
		{
			
			if (collect[i] == key)
			{
				collect[i] = "";
			}
			NewInquiry += ( collect[i] == "" ) ? "" : collect[i]+"~";
		}
//alert(NewInquiry);	
		setCookie ( job, NewInquiry );
//		location.reload();
	}

	function getInquiryCountinBasket ( job )
	{
		inquiries = getCookie ( job );
		collect = parseString ( inquiries, "~" );
		return collect.length;
	}

	function getTotalInquiryCountinBasket (  )
	{
		var totalcount = 0;
		totalcount = getInquiryCountinBasket ( 'ProductInquiry' );
		totalcount += getInquiryCountinBasket ( 'TradeInquiry' );
		totalcount += getInquiryCountinBasket ( 'CompanyInquiry' );
		return totalcount;
	}

	function clearBasket ( job )
	{
		setCookie(job, "");
		location.reload();
	}

	function viewBasket ( job )
	{
		alert(getCookie ( job ));
	}
	
	function isLoginUser ( )
	{
		var user_id = getCookie ( "user" );
		if ( user_id == null || user_id == "" || user_id == "null" )
			return false;
		else
			return true;
	}

	function isChargedUser ( )
	{
		var role = getCookie ( "ec_role" );
		if ( role == null || role == "" || role == "null" )
			return false;
		else
			return true;
	}
