function openMainBanner(pP_ID) 
{
	var TrgURL ="" ;
	if(pP_ID=="410")
		TrgURL ="experience/experience01.asp" ;
	if(pP_ID=="440")
		TrgURL ="experience/experience04.asp" ;
	if(pP_ID=="430")
		TrgURL ="experience/experience03.asp" ;
	if(pP_ID=="420")
		TrgURL ="experience/experience02.asp" ;
	if(pP_ID=="730")
		TrgURL =  "inquiries/inquiries03.asp" ;
	if(pP_ID=="210")
		TrgURL =    "discover/discover01.asp" ;
	if(pP_ID=="220")
		TrgURL =    "discover/discover02.asp" ;
	if(pP_ID=="330")
		TrgURL =    "learn/learn03.asp" ;

	mkAutoFormPost(TrgURL, "pRefer", "100") ;
}

function openSubBanner(pURL,pRefer) 
{
	mkAutoFormPost(pURL, "pRefer", pRefer) ;
}

function submitSearch() 
{
	if(document.getElementById("tpSearchq").value.length<3)
	{
		alert("Please enter 2 more characters") ;
		return ;
	}
	else
	{
		document.getElementById("tpSearch").action = LOCAL_URL+"search/" ;
		document.getElementById("tpSearch").submit() ;
	}
}


function mkAutoFormPost(pURL, pParamNM, pParamValue)
{
		document.location.href =pURL ;

	// var oForm = document.createElement("<form name='AutoForm'></form>");
  // oForm.method = "post";
  // oForm.action = pURL;
  //
  // var oInputHidden = document.createElement("<input type=hidden name='"+pParamNM+"'>");
  // oInputHidden.value = pParamValue;
  // oForm.appendChild(oInputHidden);
  // document.body.appendChild(oForm);
  // oForm.submit();

}

function LogOut(){
	if (confirm(MSG_LOGIN_OUT_YN))
	{
		getAjaxData(SITE_URL+LOCAL_URL+'common/src/control/login_out.asp', "", goHome);
	}
}
function LogOut1(){
	if (confirm(MSG_LOGIN_OUT_YN))
	{
		getAjaxData(SITE_URL+LOCAL_URL+'common/src/control/login_out.asp', "", goHome1);
	}
}
function pageTrackin(pPageID){
		var param = $H({'T_TYPE' :'GENERAL','T_LOCATION' :'','T_FILE' :'','T_ADDR' :pPageID});
		getAjaxData(SITE_URL+LOCAL_URL+'common/src/control/trackin.asp', param, processBlank);
}
function processBlank(pValue)
{
	//alert(pValue);
}

function goHome()
{
	document.location.href = SITE_URL+LOCAL_URL;
}
function goHome1()
{
	document.location.href = SITE_URL+LOCAL_URL+'admin-cms/';
}
function hiddenSendTo(trgObj,FileId,pointCode){     
	var LayerSendTo = document.getElementById("divSendTo") ;
		LayerSendTo.style.display = "none" ;
}

function openSendToFlash(trgObj,FileId,pointCode,bTop,bLeft,bWidth,bHeight){     
	alert("test");
}


function openSendTo(trgObj,FileId,pointCode){     
	if(!chkLoginFirst()) return;
	var LayerSendTo = document.getElementById("divSendTo");
	var SendTotop = 0;
	var SendToLeft= 0;
	var interval = 0;
	
	if(LayerSendTo.style.display !="block" || FileId!=document.getElementById("STDOC_ID").value)
	{
		setSendToMiddle();
		LayerSendTo.style.display = "block" ;
		
		document.getElementById("STDOC_ID").value = FileId;
		document.getElementById("RV_NAME").value = "";
		document.getElementById("RV_MAIL").value = "";
		document.getElementById("RV_MAIL").focus();
		
		var box2 = getLocation(trgObj);
		var LayerSendToObj = getLocation(LayerSendTo);    
		
		if(pointCode=="T")
		{
			SendTotop  =  box2.top-(LayerSendToObj.height+interval);
			SendToLeft =  box2.left-(LayerSendToObj.width-box2.width)/2 ;
		}
		if(pointCode=="B")
		{
			SendTotop  =  box2.top+(box2.height+interval);
			SendToLeft =  box2.left-(LayerSendToObj.width-box2.width)/2 ;
		}
		if(pointCode=="L")
		{
			SendTotop  =  box2.top-(LayerSendToObj.height- box2.height)/2;
			SendToLeft =  box2.left-(LayerSendToObj.width+interval) ;
		}
		if(pointCode=="R")
		{
			SendTotop  =  box2.top-(LayerSendToObj.height- box2.height)/2;
			SendToLeft =  box2.left+(box2.width+interval) ;
		}
		
		LayerSendTo.style.top = SendTotop + "px";
		LayerSendTo.style.left = SendToLeft + "px";
	}
	else
	{
		LayerSendTo.style.display = "none" ;
	}
}

function setSendToMiddle()
{
	var myWidth = 0, myHeight = 0;
	if (typeof( window.innerWidth ) == 'number')
	{
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
	{
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if (document.body && (document.body.clientWidth || document.body.clientHeight))
	{
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	
	document.getElementById("divSendTo").style.top  = ((myHeight - document.getElementById("divSendTo").clientHeight) / 2 + f_scrollTop()) + "px";
	document.getElementById("divSendTo").style.left = (myWidth - document.getElementById("divSendTo").clientWidth) / 2 + "px";
}

function submitMyDashboard(FileId) {
	if(FileId=="")
	{
		alert(ERROR_LOGIN_ENT_IN);
		return ;
	}
	if(!chkLoginFunc()) return ;

	var  PM_CODE       = "101" ;
	var  DOC_ID        = FileId ;
	var  RV_MAIL       = "" ;
	var  RV_NAME       = "" ;

	var param = $H({'PM_CODE' :PM_CODE,'DOC_ID' :DOC_ID,'RV_MAIL' :RV_MAIL,'RV_NAME' :RV_NAME});
	getAjaxData(SITE_URL+LOCAL_URL+'common/src/control/CommonToMyDah.asp', param,resultMyDashboard);
}
function submitView(FileId)
{
	var  PM_CODE       = "103";
	var  DOC_ID        = FileId;

	//var param = $H({'PM_CODE' :PM_CODE,'DOC_ID' :DOC_ID,'RV_MAIL' :RV_MAIL,'RV_NAME' :RV_NAME});
	//alert("tet");
	//document.location.href = LOCAL_URL+"common/src/control/CommonToMyDah.asp?PM_CODE="+PM_CODE+"&DOC_ID="+DOC_ID ;
	window.open(LOCAL_URL+"common/src/control/CommonToMyDah.asp?PM_CODE="+PM_CODE+"&DOC_ID="+DOC_ID,"_blank","");
	//alert("tet");
	//getAjaxData(SITE_URL+LOCAL_URL+'common/src/control/CommonToMyDah.asp', param,resultView);
}
function resultView(pValue)
{
	if (pValue==MSG_OK_CONFIRM)
		alert(MSG_COMMO_SEN_TMD);
	else
		alert(pValue);
}

function submitSendTo() {
	if(chkSendTo())
	{
		var  DOC_ID        = document.getElementById("STDOC_ID").value;
		var  RV_MAIL       = document.getElementById("RV_MAIL").value;
		var  RV_NAME       = document.getElementById("RV_NAME").value;

		submitSendToProcess(DOC_ID,RV_MAIL,RV_NAME) ;
	}
}
function submitSendToProcess(FileId,pMail, pName) {
		if(!chkLoginFunc()) return ;
	
	if(FileId=="" || pMail=="" || pName=="")
	{
		alert(ERROR_LOGIN_ENT_IN);
		return ;
	}else if(!chkEmail(pMail)){
		alert(ERROR_LOGIN_VAL_MAIL);
		return ;
	}else{
		var  PM_CODE        = "102" ;
		var  DOC_ID        = FileId; //document.getElementById("STDOC_ID").value ;
		var  RV_MAIL       = pMail; //document.getElementById("RV_MAIL").value ;
		var  RV_NAME       = pName; //document.getElementById("RV_NAME").value ;
	
		var param = $H({'PM_CODE' :PM_CODE,'DOC_ID' :DOC_ID,'RV_MAIL' :RV_MAIL,'RV_NAME' :RV_NAME});
		getAjaxData(SITE_URL+LOCAL_URL+'common/src/control/CommonToMyDah.asp', param,resultSendTo);
	}
}

function resultMyDashboard(pValue)
{
	if(pValue==MSG_OK_CONFIRM)
		alert(MSG_COMMO_SEN_TMD) ;
	else
		alert(pValue) ;
}
function resultSendTo(pValue)
{
	if(pValue==MSG_OK_CONFIRM)
	{
		alert(MSG_COMMO_SEN_TMF) ;
		document.getElementById("divSendTo").style.display = "none" ;
	}
	else
		alert(pValue) ;
}

function getLocation(tag) 
{ 
    var ret = new Object(); 
    if(document.all) { 
        var rect = tag.getBoundingClientRect(); 
        ret.left = rect.left + (document.documentElement.scrollLeft || document.body.scrollLeft); 
        ret.top = rect.top + (document.documentElement.scrollTop || document.body.scrollTop); 
        ret.width = rect.right - rect.left; 
        ret.height = rect.bottom - rect.top; 
    } else { 
        var box = document.getBoxObjectFor(tag); 
        ret.left = box.x; 
        ret.top = box.y; 
        ret.width = box.width; 
        ret.height = box.height; 
    } 

    return ret; 
} 
function chkSendTo(){
if(!chkandFocus(document.getElementById("RV_MAIL")) 	||
		 !chkandFocus(document.getElementById("RV_NAME"))	
	)
	{
		return false ;
	}
	else if (!chkEmail(document.getElementById("RV_MAIL") .value)) 
	{
		alert(ERROR_LOGIN_VAL_MAIL);
		document.getElementById("RV_MAIL").focus();
		return false ;
	}
	return true ;
}


function chkEmail(str) {
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function chkandFocus(trgObj)
{
	if (trgObj.value=="")
	{
		alert(ERROR_LOGIN_ENT_IN);
		
		trgObj.focus() ;
		return false;
	}	
	return  true;
}
function chkLoginFirst()
{
	if(SESSION_U_SYSID=="")
	{
		//alert(ERROR_LOGIN_NOT_ID)
		document.getElementById("PLOGIN_LINK").value = "";
		PopupLoginShow();
		return false; 
	}
	return true ;
}
function chkLoginFunc()
{
	if(SESSION_U_SYSID=="")
	{
		alert(ERROR_LOGIN_NOT_FUNC)
		document.getElementById("PLOGIN_LINK").value = "!";
		PopupLoginShow();
		return false; 
	}
	return true ;
}
function chkLoginFirstURL(strURL)
{
	if(SESSION_U_SYSID=="")
	{
		alert(ERROR_LOGIN_NOT_ID)
		document.getElementById("PLOGIN_LINK").value = strURL;
		PopupLoginShow();
		return ; 
	}
	location.href = strURL;
}

function AddOption(sel, val, txt) {
   var opt = sel.form.ownerDocument.createElement("option");

   opt.setAttribute("value", val);

   var t = sel.form.ownerDocument.createTextNode(txt);

   opt.appendChild(t);

   sel.appendChild(opt);
}

function f_scrollLeft()
{
	if (window.pageXOffset) return window.pageXOffset;
	else if (document.documentElement) return document.documentElement.scrollLeft;
	else return document.body.scrollLeft;
}

function f_scrollTop()
{
	if (window.pageYOffset) return window.pageYOffset;
	else if (document.documentElement) return document.documentElement.scrollTop;
	else return document.body.scrollTop;
}

function PopupLoginShowNR()
{
	document.getElementById("PLOGIN_LINK").value = "";
	PopupLoginShow();
}
function PopupLoginShow()
{	
	var myWidth = 0, myHeight = 0;
	if (typeof( window.innerWidth ) == 'number')
	{
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
	{
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if (document.body && (document.body.clientWidth || document.body.clientHeight))
	{
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	
	var overlay = document.getElementById("divGreyout");
	
	overlay.style.width = myWidth + "px";
	overlay.style.height = (document.body.offsetHeight + 40) + "px";
	overlay.style.top = "0px";
	overlay.style.left = "0px";
	
	overlay.style.display = "block";
	overlay.style.background = "#000000";  
	overlay.style.filter = "alpha(opacity=70)";
	overlay.style.opacity = "0.7";
	overlay.style.mozOpacity = "0.7";
	
	document.getElementById("divLogin").style.display = "block";
	document.getElementById("divLogin").style.left = (myWidth - document.getElementById("divLogin").clientWidth) / 2 + "px";
	document.getElementById("divLogin").style.top  = ((myHeight - document.getElementById("divLogin").clientHeight) / 2 + f_scrollTop()) + "px";
}
function PopupLoginHide()
{
	document.getElementById("divGreyout").style.display = "none";
	document.getElementById("divLogin").style.display = "none";
}
function PopupRedirectToRegister()
{
	location.href = LOCAL_URL + "login/login02.asp?p=" + document.getElementById("PLOGIN_REF").value;
}
function PopupLoginEnter(pEvent)
{
	if (pEvent.keyCode==13) PopupLoginChk();
}
function PopupLoginChk()
{
	var temp;
	var PLOGIN_ID  = document.getElementById("PLOGIN_ID").value ;
	var PLOGIN_PW = document.getElementById("PLOGIN_PW").value ;
	
	if(PLOGIN_ID=="")
	{
		alert(ERROR_LOGIN_ENT_ID);
		document.getElementById("PLOGIN_ID").focus();
	}
	else if(PLOGIN_PW=="")
	{
		alert(ERROR_LOGIN_ENT_PW);
		document.getElementById("PLOGIN_PW").focus();
	}
	else
	{
		var Rreferrer = document.referrer;
		var param = $H({'U_ID' : PLOGIN_ID, 'U_PW' : PLOGIN_PW, 'Rreferrer' : Rreferrer});
		getAjaxHttp(SITE_URL+LOCAL_URL+'common/src/control/login_chk.asp', param,PopupLoginResult);
	}
}
function PopupLoginResult(pHttp)
{
	var TBLoginData = pHttp.responseXML.getElementsByTagName('casest')[0];
	var pValue = TBLoginData.getAttribute("rtnMsg") ;
	
	if (ERROR_LOGIN_WRO_ID==pValue)
	{
		alert(ERROR_LOGIN_WRO_ID);
		document.getElementById("PLOGIN_ID").focus();
	}
	else if (ERROR_LOGIN_WRO_PW==pValue)
	{
		alert(ERROR_LOGIN_WRO_PW);
		document.getElementById("PLOGIN_PW").focus();
	}
	else if(MSG_OK_CONFIRM==pValue || pValue =="" )
	{
		alert(MSG_LOGIN_USE_OK.replace("$1",document.getElementById("PLOGIN_ID").value));
		
		SESSION_U_SYSID = pHttp.responseXML.getElementsByTagName('casest')[1];
		
		var plink = document.getElementById("PLOGIN_LINK").value;
		
		if (plink == "s")
		{
			resultAsses();
		} else
		if (plink == "!")
		{
			PopupLoginHide();
		}
		else if (plink == "")
		{
			PopupLoginHide();
			location.href = location.href;
		}
		else
		{
			PopupLoginHide();
			location.href = plink;
		}
	}
	else
	{
		alert(pValue);
	}
}