function CargoSaleList() {
    location.href = "/plaza/cargo/cargo_sale_list.php";
}

function CargoSaleSList() {
    location.href = "/plaza/cargo/cargo_sale_list.php?pkind=S";
}

function CargoSaleBList() {
    location.href = "/plaza/cargo/cargo_sale_list.php?pkind=B";
}

function NumberSaleList() {
    location.href = "/plaza/cargo/number_sale_list.php";
}

function NumberSaleSList() {
    location.href = "/plaza/cargo/number_sale_list.php?pkind=S";
}

function NumberSaleBList() {
    location.href = "/plaza/cargo/number_sale_list.php?pkind=B";
}

function LicenseSaleList() {
    location.href = "/plaza/cargo/license_sale_list.php";
}

function LicenseSaleSList() {
    location.href = "/plaza/cargo/license_sale_list.php?pkind=S";
}

function LicenseSaleBList() {
    location.href = "/plaza/cargo/license_sale_list.php?pkind=B";
}

// 지입/분양
function JiibSaleList() {
    location.href = "/plaza/jiib/jiib_sale_list.php";
}

// 지입매매
function JiibJobSList() {
    location.href = "/plaza/jiib/jiib_sale_list.php?pkind=S";
}

// 지입구인
function JiibJobOList() {
    location.href = "/plaza/jiib/jiib_sale_list.php?pkind=O";
}

// 지입구직
function JiibJobHList() {
    location.href = "/plaza/jiib/jiib_sale_list.php?pkind=H";
}

// 건설기계 매매
function MachSaleList() {
    location.href = "/plaza/build/mach_sale_list.php";
}

function MachSaleSList() {
    location.href = "/plaza/build/mach_sale_list.php?pkind=S";
}

function MachSaleBList() {
    location.href = "/plaza/build/mach_sale_list.php?pkind=B";
}

// 건설기계 임대
function MachRentList() {
    location.href = "/plaza/build/mach_rent_list.php";
}

// 일감 구해요
function MachRentSList() {
    location.href = "/plaza/build/mach_rent_list.php?pkind=S";
}

// 장비 구해요
function MachRentBList() {
    location.href = "/plaza/build/mach_rent_list.php?pkind=B";
}

// 부속/부품 A: 화물자동차-부속/부품, M: 화물자동차-기타, N: 건설기계-부속/부품, O: 건설기계-어테치먼트, Z: 건설기계-기타
function PartSaleList() {
    location.href = "/plaza/part/part_sale_list.php?pkind=A";
}

// 화물자동차-부속/부품
function PartSaleAList() {
    location.href = "/plaza/part/part_sale_list.php?pkind=A";
}

// 화물자동차-기타
function PartSaleMList() {
    location.href = "/plaza/part/part_sale_list.php?pkind=M";
}

// 건설기계-부속/부품
function PartSaleNList() {
    location.href = "/plaza/part/part_sale_list.php?pkind=N";
}

// 건설기계-어테치먼트
function PartSaleOList() {
    location.href = "/plaza/part/part_sale_list.php?pkind=O";
}

// 건설기계-기타
function PartSaleZList() {
    location.href = "/plaza/part/part_sale_list.php?pkind=Z";
}

// 구인구직
// OC:화물자동차-구인, OB:건설기계-구인
// HC:화물자동차-구직, HB:건설기계-구직
function JobList() {
    location.href = "/plaza/job/job_offer_list.php?pkind=OC";
}

// OC:화물자동차-구인
function JobOfferCList() {
    location.href = "/plaza/job/job_offer_list.php?pkind=OC";
}

// HC:화물자동차-구직
function JobHuntCList() {
    location.href = "/plaza/job/job_hunt_list.php?pkind=HC";
}

// OB:건설기계-구인
function JobOfferBList() {
    location.href = "/plaza/job/job_offer_list.php?pkind=OB";
}

// HB:건설기계-구직
function JobHuntBList() {
    location.href = "/plaza/job/job_hunt_list.php?pkind=HB";
}

function ShowWindowByMask(popup_name){
    //화면의 높이와 너비를 구한다.
    var maskHeight = $(document).height();  
    var maskWidth = window.document.body.clientWidth;

    var mask = "<div id='id_loading_mask' style='position:absolute; z-index:20; background-color:#000000; display:none; left:0; top:0;'></div>";

    //화면에 레이어 추가 
    $('body').append(mask);

    //마스크의 높이와 너비를 화면 것으로 만들어 전체 화면을 채운다.
    $('#id_loading_mask').css({
            'width' : maskWidth
            , 'height': maskHeight
            , 'opacity' : '0.5'
    });  

    // 마스크 표시
    $('#id_loading_mask').show();    

	// 팝업메뉴를 띄운다.
	if( popup_name ){
		$('#'+popup_name).show();
	}

	/*
	//화면의 높이와 너비를 구한다.
	var maskHeight = $(document).height();  
	var maskWidth = $(window).width();  
      
	//마스크의 높이와 너비를 화면 것으로 만들어 전체 화면을 채운다.
	$('#popup_mask').css({'width':maskWidth,'height':maskHeight});  
	  
	//애니메이션 효과 - 일단 0초동안 까맣게 됐다가 60% 불투명도로 간다.
	$('#popup_mask').fadeIn(0);      
	$('#popup_mask').fadeTo("slow",0.4);    

	//윈도우 같은 거 띄운다.
	if( popup_name ){
		$('#'+popup_name).show();
	}*/
} 

/**
 *	브라우저 정보
 */
var isMSIE = false;

try{
	var platform = navigator.platform.toLowerCase();	// Win32, Win64
	var app_name = navigator.appName.toLowerCase();		// Microsoft Internet Explorer, Netscape, ..

	// Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; GWX:DOWNLOADED; rv:11.0) like Gecko
	// Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3; .NET CLR 1.1.4322)
	// Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36
	var user_agent = navigator.userAgent.toLowerCase();	// 

	if( app_name == "microsoft internet explorer" || (user_agent.indexOf("msie") != -1 && user_agent.indexOf("trident") != -1) || (user_agent.indexOf(".net") != -1 && user_agent.indexOf("trident") != -1) ){
	    isMSIE = true;
	}

}catch(e){
}

function HideWindowByMask(popup_name) {
	if( popup_name ){
		$('#'+popup_name).hide();
	}
	$('#id_loading_mask').hide();
	$('#id_loading_mask').remove();   
}


function ShowLoadingMask(){
    //화면의 높이와 너비를 구한다.
    var maskHeight = $(document).height();  
    var maskWidth = window.document.body.clientWidth;

    var mask = "<div id='id_loading_mask' style='position:absolute; z-index:20; background-color:#000000; display:none; left:0; top:0;'></div>";

	var pos_left	= Math.round($(window).width()/2) - 8;
	var pos_top		= Math.round($(window).height()/2) - 8;

    var loading_img = '';
    loading_img += "<div id='loading_img' style='position:fixed; left:"+pos_left+"px; top:"+pos_top+"px; display:none; z-index:10;'>";
    loading_img += " <img src='/bc/images/common/loading.gif'/>"; 
    loading_img += "</div>";   

    // 화면에 레이어 추가 
    $('body').append(mask).append(loading_img);

    // 마스크의 높이와 너비를 화면 것으로 만들어 전체 화면을 채운다.
    $('#id_loading_mask').css({
            'width' : maskWidth
            , 'height': maskHeight
            , 'opacity' : '0.5'
    });  

    // 마스크 표시
    $('#id_loading_mask').show();    

    // 로딩중 이미지 표시
    $('#loading_img').show();
	$(window).resize(resizeLoadingMask);
}

function resizeLoadingMask() {
    var maskHeight = $(document).height();  
    var maskWidth = window.document.body.clientWidth;

    $('#id_loading_mask').css({
            'width' : maskWidth+'px'
            , 'height': maskHeight+'px'
    });
	
	var pos_left	= Math.round($(window).width()/2) - 8;
	var pos_top		= Math.round($(window).height()/2) - 8;

    $('#loading_img').css({
            'left' : pos_left+'px'
            , 'top': pos_top+'px'
    });
}

function HideLoadingMask() {
	$('#id_loading_mask, #loading_img').hide();
	$('#id_loading_mask, #loading_img').remove();   
}


// 파일업로드
var upload_callback = null;

function ShowFileUploadFrame(file_type, c_callback, max_width, max_height)
{
	HideFileUploadFrame();

	var url = '/plaza/com/caus_upload.php?file_type='+file_type;

	if( max_width ){
		url += "&max_width="+max_width;
	}

	if( max_height ){
		url += "&max_height="+max_height;
	}

	url += "&t="+(new Date());
	upload_callback = c_callback;

	var w = 480;
	var h = 250;

	var html = "				<div class='modal-dialog' style='width:"+w+"px'>";
	html = html + "					<div class='modal-content'>";
	html = html + "						<div class='modal-header'>";
	html = html + "							이미지 첨부";
	html = html + "							<button data-dismiss='modal' class='close'></button>";
	html = html + "						</div>";
	//html = html + "						<div class='modal-body alert'>";
	html = html + "						  <iframe name='fileUploadFrame' id='fileUploadFrame' style='margin:0px;padding:0px;width:"+w+"px;height:"+h+"px; border:1px solid #767676;  background:#fff; z-index:9000' frameborder=0 scrolling=no topmargin=0 leftmargin=0></iframe>";
	//html = html + "						</div>";
	html = html + "					</div>";
	html = html + "				</div>";

	$("<div id='fileUploadModal' class='modal'>"+html+"</div>").appendTo("body");
	
	if( !isMSIE ){
	    $('#fileUploadModal').modal({show:true});
	}
	
	$("#fileUploadFrame").attr("src",url); 
}

function HideFileUploadFrame(){
	$('#fileUploadModal').modal({show:false})
	$('#fileUploadModal').remove();
}

function setFileUploadResult(orig_name, file_value, file_ksize) {
	HideFileUploadFrame();

	// 콜백함수 호출
	if( upload_callback && orig_name && file_value ){
		if( typeof upload_callback == "function" ){
			upload_callback(orig_name, file_value, file_ksize);
		}
	}
	upload_callback = null;
}


// 레이어팝업
var mypopup_callback = null;

function ShowMyPopupFrame(title, c_url, c_callback, top, left, width, height, scrolling)
{
	HideMyPopupFrame();

    var popup_mask = "<div id='id_popup_mask' style='position:absolute; z-index:20; background-color:#000000; left:0; top:0; width:100%; height:100%; opacity:0.5;'></div>";
    $('body').append(popup_mask); 

    var maskHeight = $(document).height();  
    var maskWidth = window.document.body.clientWidth;

    $('#id_popup_mask').css({
            'width' : maskWidth+'px'
            , 'height': maskHeight+'px'
    });

	var pos_top = event.pageY - 50;
	var pos_left = event.pageX + 10;
	
	var max_width = window.document.body.clientWidth;

	if( top && top > 0 ) pos_top = top;
	if( left && left > 0 ) pos_left = left;

	if( pos_top < 0 ){
	    pos_top = 0;
	}

	if( pos_left < 0 ){
	    pos_left = 0;
	}

	if( pos_left > max_width - 350 ){
	    pos_left = 0;
	}

	var url = c_url;

	if( url.indexOf("?") == -1 ){
	    url += "?t="+(new Date());
	}
	url += "&width="+width;
	url += "&height="+height;
	
	mypopup_callback = c_callback;

	var w = 500;
	var h = 320;

	if( width ) w = width;
	if( height ) h = height;
	
	var scroll = "no";
	if( scrolling ) scroll = scrolling;

	var html = "				<div class='modal-dialog' style='width:"+w+"px'>";
	html = html + "					<div class='modal-content'>";
	html = html + "						<div id='id_modal_header' class='modal-header' style='z-index:9000'>";
	html = html + "							"+title;
	html = html + "							<button onclick='HideMyPopupFrame();' class='close'></button>";
	html = html + "						</div>";
	html = html + "						  <iframe name='myPopupFrame' id='myPopupFrame' style='margin:0px;padding:0px;width:"+w+"px;height:"+h+"px; border:1px solid #767676;  background:#fff; z-index:9000' frameborder=0 scrolling="+scroll+" width='100%' height='100%' topmargin=0 leftmargin=0></iframe>";
	html = html + "					</div>";
	html = html + "				</div>";


	$("<div id='mypopup_modal' class='modal' style='border-radius:5px;border:1px solid #2ca3ff; overflow:hidden; position:fixed; top:"+pos_top+"px; left:"+pos_left+"px; bottom: 0; right: 0; width:"+w+"px; height:"+h+"px;'>"+html+"</div>").appendTo("body");
	
    $('#mypopup_modal').show();
	$("#myPopupFrame").attr("src",url);
	
	$(window).resize(resizePopupMask);
	
	$("#mypopup_modal").draggable();
}

function ShowMyPopupHeader() {
    $('#id_modal_header').show();
}

function HideMyPopupFrame(){
	$(window).unbind("resize",resizePopupMask);
	$("#id_popup_mask").remove();
	$("#mypopup_modal").hide();
	$('#mypopup_modal').remove();
}

function setMyPopupResult(param) {
	HideMyPopupFrame();
	// 콜백함수 호출
	if( mypopup_callback && param ){
		if( typeof mypopup_callback == "function" ){
			mypopup_callback(param);
		}
	}
	mypopup_callback = null;
}

function resizePopupMask() {
    var maskHeight = $(document).height();  
    var maskWidth = window.document.body.clientWidth;

    $('#id_popup_mask').css({
            'width' : maskWidth+'px'
            , 'height': maskHeight+'px'
    });
}


$(document).ready(function () {
	$('body').bind("click", function(event) {
		//HideMyPopupFrame();
	});
});



// SELECT OPTION 제거
function remove_select_option(id, del_start){
	var optionSize = $('#'+id+' option').size();
	for(var i = optionSize-1; i >= del_start; i--) {
		$('#'+id+' option:eq('+i+')').remove();
	}
}

function load_select_option(id, def, optionsDataArray) 
{
	var selectElement = $('#'+id);
	$.each(optionsDataArray,function(idx, optionData)
	{
		if( def == optionData.MINCODE ){
			selectElement.append("<option value='"+optionData.MINCODE+"' selected>"+optionData.MINNAME+"</option>");
		}
		else{
			selectElement.append("<option value='"+optionData.MINCODE+"'>"+optionData.MINNAME+"</option>");
		}
	});
}

// 코드 가져오기
function get_select_code2(id, def, code, mincode, del_start)
{
	remove_select_option(id, del_start);

	if( mincode.length > 0 ){
		$.ajax({ 
			url: "/plaza/com/caus_json_code.php", 
			timeout: "10000",
			type: "POST", 
			async: true, // 비동기
			data : {
				code		: code,
				mincode		: mincode
			},
			dataType:'json', // 결과에 데이터 타입 : auto, text, xml, json 
			success: function(data){ 
				load_select_option(id, def, data);
			}, 
			error: function(){ 
			} 
		});
	}
}