﻿var adUrl="http://www.mpiaad.co.kr/uhak/";
var url="";
var _JQSC;
var _JDN=document.location.hostname;
var leftTime=30;
var mcode;
function jmaster(){
		var _JEx ="return_mpia";
		var _JL = document.location.search.substr(1); 
		var _JQS = {}; // query array 
		_JL.replace(/([^=]+)=([^&]*)(&|$)/g, function(){ 
			_JQS[arguments[1]] = arguments[2]; 
			return arguments[0]; 
		});
		_JQSC=_JQS[_JEx];
		if(_JQSC!=undefined){
			_Scookie('mpiaAd',encodeURIComponent(_JQSC),leftTime);
		}else {
			if(_Gcookie('mpiaAd')!=undefined){
				_JQSC=decodeURI(decodeURIComponent(_Gcookie('mpiaAd')));
			}else{

			}
		}
		return _JQSC;
}

function _Scookie( name, value, expiredays ){    
	var todayDate = new Date();    
	todayDate.setDate( todayDate.getDate() + expiredays );    
	document.cookie = name + "=" + escape( value ) + "; path=/;    expires="   +   todayDate.toGMTString() + "; domain="+_JDN+";" ;
}

function _Gcookie(name){    
	var idx_s = document.cookie.indexOf(name + "=");    
	var idx_e = 0;    
	if (idx_s != -1){ idx_s += name.length + 1; 
		idx_e = document.cookie.indexOf(";",idx_s); 
		if (idx_e == -1){     idx_e = document.cookie.length; }    
	}
	else{ return "";    }

	return document.cookie.substring(idx_s,idx_e);
}

function ImportScript(file) 
{ 

    var head = document.getElementsByTagName("head")[0]; 
    var script = document.createElement("script"); 
    script.type = "text/javascript"; 
	script.charset= 'utf-8';
    script.src = file; 
    head.appendChild(script); 
} 
function trim(txt){
	return txt.replace(/(^\s+)|(\s+$)/g, ''); 
}
function require(jsFile, alwaysReload) {
    var url = "http://" + location.host + jsFile;
    var xhr = null;
    var jsSource = "";
 
    if (window.XMLHttpRequest) {
        xhr = new XMLHttpRequest();
    } else {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if( xhr ){
        xhr.open('get', jsFile, false);
        xhr.send(null);
        
        jsSource = xhr.responseText;
    }
 
 return jsSource;
}
function adCatch(_JQSC,mcode){
	var im=new Image();
	im.src=adUrl+'keyword.php?return_mpia='+_JQSC+"!!"+mcode;
	im.onload=function() { return; }
}
var _JQSC=jmaster();
if(mcode!=undefined){
	adCatch(_JQSC,mcode);
}