/*
    Page Name : Sub Validate Script
    Language : Javascript
    First Update :
    Last Update : 2008. 05. 05(by ynmoon)
*/

// Show Flash Player
function showFlash(obj,o_width,o_height)
{
    document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="'+o_width+'" HEIGHT="'+o_height+'" id="left_bn" ALIGN="">');
    document.write('<PARAM NAME="allowScriptAccess" VALUE="always">');
    document.write('<PARAM NAME="movie" VALUE="'+obj+'">');
    document.write('<PARAM NAME="quality" VALUE="high">');
    document.write('<PARAM NAME="bgcolor" VALUE="#FFFFFF">');
    document.write('<PARAM NAME="wmode" VALUE="transparent">');
    document.write('<PARAM NAME="menu" VALUE="yes">');
    document.write('<EMBED src="'+obj+'" quality="high" bgcolor="#FFFFFF"  WIDTH="'+o_width+'" HEIGHT="'+o_height+'" NAME="banner_rw" WMODE="transparent" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>');
    document.write('</OBJECT>');
}

// input Living Area
function inputArea(obj1,obj2,obj3,param)
{
    var live=document.getElementsByName(obj3);
        
    if (param=="in") {
        live[0].checked=true;
        live[1].checked=false;
        document.getElementById("MBFOCountry").style.display="none";
    } else {
        live[0].checked=false;
        live[1].checked=true;
        document.getElementById("MBFOCountry").style.display="block";
    }
    
    changeLayer(obj1,obj2);
}

// Change Select Layer
function changeLayer(obj1,obj2,obj3,img)
{
    var showLayer=document.getElementById(obj1);
    var hideLayer=document.getElementById(obj2);
    var srcLayer=document.getElementById(obj3);
    
    hideLayer.style.display="none";
    showLayer.style.display="block";
    srcLayer.style.background="url('"+img+"') no-repeat"; 
}

// Input Hidden Value
function inputHidden(obj,param)
{
    var hd_form=document.getElementById(obj);
    hd_form.value=param;
}

// Cange Border Color
function chageBorder(obj,clr)
{
	document.getElementById(obj).style.border="1px solid "+clr;
	document.getElementById(obj).style.color=clr;
}

// Job Type Validate
function jobtypeCheck(obj,param)
{
    var theForm=obj;
    
    if (!param) {
        return;
    }
    
    theForm.submit();
}

// Job Search Validate
function jobsearchCheck(obj)
{
    var theForm=obj;
    
    if (!theForm.jobsearch.value) {
        alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä");
        theForm.jobsearch.focus();
        return false;
    }
    
    return true;
}

// Close Window Function
function closeWindow()
{
    top.window.opener=top;
    top.window.open('','_parent', '');
    top.window.close();   
}

// Window Resize
function resizeWindow(w,h)
{
    var agent=navigator.userAgent.toLowerCase();
    var isIE=((agent.indexOf("msie")!=-1) && (agent.indexOf("opera")==-1));
    var isOP=((agent.indexOf("msie")==-1) && (agent.indexOf("opera")!=-1));
    var isIE7=agent.match(/msie 7/);
    var isIE8=agent.match(/msie 8/);
    var isFF3=agent.indexOf("firefox/3")>0;
    var isXP=agent.indexOf("nt 5.1")>0;
    var isVISTA=agent.indexOf("nt 6.")>0;
    var isChrome=agent.indexOf("chrome")>0;
    
    if (isIE8 || isFF3) {
        if (isVISTA) {      
            var _width=parseInt(parseInt(w)+10);
            var _height=parseInt(parseInt(h)+65);
        } else {
            var _width=parseInt(parseInt(w)+10);
            var _height=parseInt(parseInt(h)+80);
        }
    } else if (isIE7 || isChrome) {
        if (isVISTA) {      
            var _width=parseInt(parseInt(w)+10);
            var _height=parseInt(parseInt(h)+55);
        } else {
            var _width=parseInt(parseInt(w)+10);
            var _height=parseInt(parseInt(h)+70);
        }
    } else if (isIE) {
        var _width=parseInt(parseInt(w)+10);
        if (isXP) {
            var _height=parseInt(parseInt(h)+58);
        } else {        
            var _height=parseInt(parseInt(h)+49);
        }
    } else if (isOP) {
        var _width=parseInt(parseInt(w)+10);
        var _height=parseInt(parseInt(h)+43);
    } else {
        var _width=parseInt(parseInt(w)+10);
        var _height=parseInt(parseInt(h)+50);
    }
    
    window.resizeTo(_width,_height);
}

// Add Cart
function addCart(param1,param2)
{
	opener.location.href="/union/cart_add.html?no="+param1+"&kind="+param2;
	closeWindow();
}

// Direct Select
function selDirect(param1,param2,param3)
{
	opener.location.href="/union/cart_add.html?no="+param1+"&kind="+param2+"&DP="+param3;
	closeWindow();
}

// Move Login
function moveLogin(where)
{
	opener.location.href="/member/?where="+where;
	closeWindow();
}

// View Layer
function displayLayer(obj,disp)
{
    document.getElementById(obj).style.display=disp;
}

var intro_img_cnt=0;
var intro_img_dir="/data/rf/cp/rf_mysample";
var job_no_img="/images/web_standard/job/job_view_no_img.gif";

// Intro Preview Image
function introViewimg(page,cno,param)
{
    if (page<4) {
        return;
    }
    
    var zerofill=1000;
    
    var i,j,k,l;
    
    var mpage=Math.ceil(page/4)-1;
    
    if (param=="P") {
        if (intro_img_cnt==0) {
            intro_img_cnt=mpage;
        } else {
            intro_img_cnt--;
        }
    } else {
        if (intro_img_cnt==mpage) {
            intro_img_cnt=0;
        } else {
            intro_img_cnt++;
        }
    }
    
    for (i=((4*intro_img_cnt)+1),j=1;i<=((4*intro_img_cnt)+4);i++,j++) {
        var znum=(zerofill+i).toString();
        var fnum=znum.substring(1,4);
        
        k=j.toString();        
        var showImg=document.getElementById("preview"+k);
        
        if (i>page) {
            for (l=(i%4);l<=4;l++) {
                j=l;
                k=j.toString();
                
                document.getElementById("preview"+k).src=job_no_img;
            }
            break;
        }
        
        showImg.src=intro_img_dir+"/intro_"+cno+"_"+fnum+".gif";
        showImg.style.display="block";
    }
}

var report_sf_dir="/data/rf/document";
var report_cp_dir="/data/rf/cp/reportworld";
var report_no_img="/images/web_standard/report/rep_view_no_img.gif";
var report_img_cnt=0;

// Report Preview Image
function reportViewimg(page,cno,param1,param2,yy,mm)
{
    if (page<4) {
        return;
    }
    
    var zerofill=1000;
    
    var i,j,k,l;
    
    var mpage=Math.ceil(page/4)-1;
    
    if (param1=="P") {
        if (report_img_cnt==0) {
            report_img_cnt=mpage;
        } else {
            report_img_cnt--;
        }
    } else {
        if (report_img_cnt==mpage) {
            report_img_cnt=0;
        } else {
            report_img_cnt++;
        }
    }
    
    for (i=((4*report_img_cnt)+1),j=1;i<=((4*report_img_cnt)+4);i++,j++) {
        var znum=(zerofill+i).toString();
        var fnum=znum.substring(1,4);
        
        k=j.toString();        
        var showImg=document.getElementById("preview"+k);
        var numImg=document.getElementById("num"+k);
        
        if (i>page) {
            for (l=(i-(4*report_img_cnt));l<=4;l++) {
                j=l;
                k=j.toString();
                
                document.getElementById("preview"+k).src=report_no_img;
                document.getElementById("num"+k).style.display="none";
            }
            break;
        }
        
        if (param2=="RW") {
            showImg.src=report_cp_dir+"/"+yy+"/"+"/"+mm+"/data"+cno+"_"+fnum+".gif";
        } else {
            showImg.src=report_sf_dir+"/"+yy+"/"+"/"+mm+"/data"+cno+"_"+fnum+".gif";
        }
        
        showImg.style.display="block";
        numImg.style.display="block";
        numImg.innerHTML=i;
    }
}

var report_iso_dir="/data/rf/cp/isoplaza";
var report_no_img="/images/web_standard/report/rep_view_no_img.gif";
var report_img_cnt=0;

// Report Preview Image
function isoViewimg(page,cno,param1,s_dir)
{
    if (page<4) {
        return;
    }
    
    var zerofill=1000;
    
    var i,j,k,l;
    
    var mpage=Math.ceil(page/4)-1;
    
    if (param1=="P") {
        if (report_img_cnt==0) {
            report_img_cnt=mpage;
        } else {
            report_img_cnt--;
        }
    } else {
        if (report_img_cnt==mpage) {
            report_img_cnt=0;
        } else {
            report_img_cnt++;
        }
    }
    
    for (i=((4*report_img_cnt)+1),j=1;i<=((4*report_img_cnt)+4);i++,j++) {
        var znum=(zerofill+i).toString();
        var fnum=znum.substring(1,4);
        
        k=j.toString();        
        var showImg=document.getElementById("preview"+k);
        var numImg=document.getElementById("num"+k);
        
        if (i>page) {
            for (l=(i-(4*report_img_cnt));l<=4;l++) {
                j=l;
                k=j.toString();
                
                document.getElementById("preview"+k).src=report_no_img;
                document.getElementById("num"+k).style.display="none";
            }
            break;
        }
        
       showImg.src=report_iso_dir+"/"+s_dir+"/iso"+cno+"_"+fnum+".gif";
        
        showImg.style.display="block";
        numImg.style.display="block";
        numImg.innerHTML=i;
    }
}

// Share Data Check All
function checkAll(obj)
{
    var theForm=document.getElementById(obj);
    
    var i,sel;
    
    if (theForm.chk_all.value=="N") {
		for (i=0;i<theForm.elements.length;i++) {
			sel=theForm.elements[i];
			if (sel.name.indexOf("no[")!=-1) {
    			sel.checked=1;
			}
		}
		theForm.chk_all.value="Y";
	} else {
		for (i=0;i<theForm.elements.length;i++) {
			sel=theForm.elements[i];
			if (sel.name.indexOf("no[")!=-1) {
    			sel.checked=0;
			}
		}
		theForm.chk_all.value="N";
	}
}

// Get Share Data
function getShare(obj)
{
    var theForm=document.getElementById(obj);
    
    theForm.action="/share/list_date_post.html";
    
    theForm.submit();
}

// Delete Share Data
function deleteShare(obj)
{
    var theForm=document.getElementById(obj);
    
    var i,sel,j=0;
    
    for (i=0;i<theForm.elements.length;i++) {
		sel=theForm.elements[i];
		if (sel.name.indexOf("no[")!=-1) {
    		if (sel.checked) {
       			j++;
   			}
		}
	}
    
	if (j==0) {
    	alert("»èÁ¦ÇÒ µ¥ÀÌÅÍ¸¦ ¼±ÅÃÇØ ÁÖ¼¼¿ä");
    	return;
	}
	
    theForm.action="/share/list_date_delete.html";
    
    theForm.submit();
}

// Share Data Search Check
function searchCheck(theForm)
{
    if (!theForm.s_key.value) {
        alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä");
        theForm.s_key.focus();
        return false;
    }
    
    return true;
}

// Alert Null Data
function alertNull()
{
    alert("´ÙÀ½ÀÚ·á°¡ ¾ø½À´Ï´Ù");
    return;
}

// Return Banner Info
function bannerInfo(obj)
{
    var bForm=document.getElementById(obj);
    
    var i;
    var count=bForm.elements.length;
        
    for (i=1;i<count;i++) {
        var sel=bForm.elements[i];
                
        if (sel.name.indexOf("pr_banner")!=-1) {
            if (sel.checked==true) {
                if (sel.value!="no") {
                    var ar_text=sel.value.split("|");
                    
                    return ar_text; 
                }
            }
        }
    }
    
    return false;
}

// Copy To Clipboard
function copyToClipboard(flag,param)
{    
    var _clip=document.getElementById(param);
    
    if (window.clipboardData) {        
        var _range=document.body.createControlRange(); 
        _range.addElement(_clip); 
        _range.execCommand("copy");
        
        _text=window.clipboardData.getData("Text");      
        
        if (flag=="data") {
            _range.select();
        } else {
            alert('¼±ÅÃÇÏ½Å ³»¿ëÀÌ Å¬¸³º¸µå¿¡ º¹»çµÇ¾ú½À´Ï´Ù. \n\n'+'º¹»çÇÏ½Ç °÷¿¡¼­ Ctrl + v ¶Ç´Â ¸¶¿ì½º ¿À¸¥ÂÊ ¹öÆ°À» ´­·¯ ºÙ¿©³Ö±â ÇÏ½Ã¸é µË´Ï´Ù.\n\n');
        }
     }/* else {
        netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
        
        var clip=Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        if (!clip) {
            return;
        }
        
        var trans=Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        if (!trans) {
            return;
        }
        
        trans.addDataFlavor('text/unicode');
        
        var str=new Object();
        var len=new Object();
        
        var str=Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
        
        var copytext=_clip;
        
        str.data=copytext;
        
        trans.setTransferData("text/unicode",str,copytext.length*2);
        
        var clipid=Components.interfaces.nsIClipboard;
        
        if (!clip) {
            return false;
        }
        
        clip.setData(trans,null,clipid.kGlobalClipboard);
        
        return;
    }*/
    
    return;
}

// Copy Data Update
copyUpdate=function(objName)
{
	this.objName=objName;		// »ý¼ºµÈ °´Ã¼ ¸í(this)
	this.httpRequest = null;	// httpRequest°´Ã¼
	this.dno;       // UpdateµÉ ¼öÀÍ¹èºÐ ÀÚ·á ¹× ¹è³ÊÀÚ·á ¹øÈ£
	this.flag;       // ±¸ºÐÀÚ(data : ÀÚ·á¼öÀÍ¹èºÐ, banner : ¹è³Ê¼öÀÍ¹èºÐ)
	this.copyObject;      // CopyµÉ °´Á¦
	
	// httpRequest °´Ã¼ »ý¼º ÇÔ¼ö
	copyUpdate.prototype.getXMLHttpRequest=function()
	{
		if (window.ActiveXObject) {
			try {
				return new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				try {
					return new ActiveXObject("Microsoft.XMLHTTP");
				} catch(e1) { return null; }
			}
		} else if (window.XMLHttpRequest) {
			return new XMLHttpRequest();
		} else {
			return null;
		}
	}	//	end getXMLHttpRequest function
	
	// httpRequest send ÇÔ¼ö
	copyUpdate.prototype.sendRequest=function(url,params,callback,method)
	{
		this.callback=callback;

		this.httpRequest=this.getXMLHttpRequest();
		var httpMethod=method ? method : 'GET';
		if (httpMethod!='GET' && httpMethod!='POST') {
			httpMethod='GET';
		}
		var httpParams=(params==null || params=='')?null:params;
		var httpUrl=url;
		if (httpMethod=='GET' && httpParams!=null) {
			httpUrl=httpUrl+"?"+httpParams;
		}
		this.httpRequest.open(httpMethod,httpUrl,true);
		this.httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		
		var request = this;
		this.httpRequest.onreadystatechange=function()
		{
			request.onStateChange.call(request);
		}
		this.httpRequest.send(httpMethod=='POST'?httpParams:null);	
	}	// end sendRequest function

	// httpRequest return ÇÔ¼ö
	copyUpdate.prototype.onStateChange=function()
	{
		this.callback(this.httpRequest);
	}	// end onStateChange end

	// Copy Data Update
	copyUpdate.prototype.updateCopyData=function(dno,flag,copyObj)
	{
    	this.dno=dno;
    	this.flag=flag;
    	this.copyObject=copyObj;
    	
    	var bno=0;
    	
    	if (this.flag=="data") {    	
        	var ar_text=bannerInfo("id_bannerform");  
        	
            if (ar_text) {
                bno=ar_text[0];
            }
        }
    	
		params="dno="+encodeURIComponent(this.dno)+"&flag="+encodeURIComponent(this.flag)+"&bno="+encodeURIComponent(bno);
		this.sendRequest("/union/ajax/sharecopy.html",params,this.updateCopyResponse,"POST");
	}	// end updateCopyData function
	
	// Copy Data °á°ú
	copyUpdate.prototype.updateCopyResponse=function()
	{
		if (this.httpRequest.readyState==4) {
			if (this.httpRequest.status==200) {
				var docXML_FD=this.httpRequest.responseXML;
				var code=docXML_FD.getElementsByTagName("code").item(0).firstChild.nodeValue;		// Update ¼º°ø¿©ºÎ

				//if (code=='true') {
    				copyToClipboard(this.flag,this.copyObject);
    				/*
				} else {
    				alert('ÀÚ·áº¹»çÁß ¿¡·¯°¡ ¹ß»ýÇß½À´Ï´Ù. \n\n'+'°ü¸®ÀÚ¿¡°Ô ¹®ÀÇÇØ ÁÖ¼¼¿ä\n\n');
    				return;
				}
				*/
			}
		}
	}	// end updateCopyResponse function
}	//	end copyUpdate Class

// Set Search Date
function setSearch(obj,param)
{
	var e_time=new Date();
    var e_year=e_time.getFullYear();
    var e_month=e_time.getMonth()+1;
    var e_day=e_time.getDate();
	
	var theForm=document.getElementById(obj);
	
	theForm.e_year.value=e_year;
	theForm.e_month.value=e_month;
	theForm.e_day.value=e_day;
	
	var m_time=e_time.getTime();
	
	var s_time = new Date(m_time-param*86400*1000);
	var s_year=s_time.getYear();
	var s_month=s_time.getMonth()+1;
	var s_day=s_time.getDate();
	
	theForm.s_year.value=s_year;
	theForm.s_month.value=s_month;
	theForm.s_day.value=s_day;
}

// Knou Search Validate
function knousearchCheck(obj)
{
    var theForm=obj;
    
    if (!theForm.knousearch.value) {
        alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä");
        theForm.knousearch.focus();
        return false;
    }
    
    return true;
}

// Banner Cookie Check
function bannerCheck(param)
{
    js_setcookie("BCheck",param,0,"/");
    
    var ar_text=bannerInfo("id_bannerform");  
            
    if (ar_text) {
        document.getElementById("banner_area").innerHTML="<br /><br /><a href=\""+ar_text[1]+"\" target=\"_blank\"><img src=\""+ar_text[2]+"\" border=\"0\" /></a>";
    }
}