document.domain = "uforia.com";

document.writeln("<" + "script language=\"javascript\" src=\"/Common/javascriptConfig.aspx\"></" + "script>");


function printSWF(id, flashUri, vWidth, vHeight, winMode, bgColor, param) {
    var _obj_ = "";
    _obj_ = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="' + vWidth + '" height="' + vHeight + '" id="' + id + '" align="middle">';
    _obj_ += '<param name="allowScriptAccess" value="always" />';
    _obj_ += '<param name="allowFullScreen" value="true" />';
    _obj_ += '<param name="movie" value="' + flashUri + '" />';
    _obj_ += '<param name="quality" value="high" />';
    _obj_ += '<param name="menu" value="false" />';
    _obj_ += '<param name="wmode" value="' + winMode + '" />';
    _obj_ += '<param name="bgcolor" value="' + bgColor + '" />';
    _obj_ += '<param name="flashvars" value="' + param + '"/>';
    _obj_ += '<embed src="' + flashUri + '?' + param + '" quality="high" wmode="' + winMode + '" bgcolor="' + bgColor + '" width="' + vWidth + '" height="' + vHeight + '" id="' + id + '" align="middle" allowScriptAccess="always" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" /></embed>    ';
    _obj_ += '</object>';
    document.writeln(_obj_);

    eval("window." + id + " = document.getElementById('" + id + "');");
}

function CheckStr(strOriginal, strFind, strChange) {
    var position, strOri_Length;
    position = strOriginal.indexOf(strFind);

    while (position != -1) {
        strOriginal = strOriginal.replace(strFind, strChange);
        position = strOriginal.indexOf(strFind);
    }

    strOri_Length = strOriginal.length;
    return strOri_Length;
}

function UpInputTxt(strInput)
{
	var strPath = self.location.toString();
	
	var intPathLimit = strPath.indexOf('/', 8);
	
	strPath = strPath.substring(0, intPathLimit);
	
	strUrl = "http://image.uforia.com/upfrm.aspx?txt=" + strInput + "&returnurl=" + strPath + "/Common/upend.html";
	
	WindowOpenCenter(strUrl, 440, 200, "WinUp", "no");
}

function UserUpInputTxt(strInput, ssel) 
{
    var strPath = self.location.toString();

    var intPathLimit = strPath.indexOf('/', 8);

    strPath = strPath.substring(0, intPathLimit);

    var strPage = "upfrm.aspx";
    
    if(ssel == 1)
    {
        strPage = "upfrm3king.aspx";
        strUrl = "http://image.uforia.com/" + strPage + "?txt=" + strInput + "&returnurl=" + strPath + "/Common/upend.html";

        WindowOpenCenter(strUrl, 400, 200, "WinUp", "no");
    }
}

function WindowOpenCenter(strUrl, intWidth, intHeight, winName, strScrollbar)
{
	if(strScrollbar == null)
	{
		strScrollbar = "no";
	}
	
	var winW = intWidth;
	var winH = intHeight;
	
	var winL = (screen.width - winW) / 2;
	var winT = (screen.height - winH) / 2;
		
	var win = window.open(strUrl, winName, "width=" + winW + ",height=" + winH + ",scrollbars=" + strScrollbar + ",resizable=no,top=" + winT + ", left=" + winL);
	
	return win;
}

function OpenTerms()
{
    WindowOpenCenter(this.GLOBAL_UFORIA_URL + "/Etc/terms_of_service.html", 720, 500, "WinTerms", "yes");
}

function OpenPolicy()
{
    WindowOpenCenter(this.GLOBAL_UFORIA_URL + "/Etc/privacy_policy.html", 720, 500, "WinPolicy", "yes");
}

function IPopt(obj) {
    var src_str = obj.src.toLowerCase();
    if (src_str.indexOf("ipon") > -1) {
        obj.src = src_str.replace("ipon", "ipoff");
        SetCookie("IPopt", "OFF", 1, "", "uforia.com");
		alert("If you are using a Dynamic IP or are having problems logging into\nyour Uforia account to purchase UFOs,please unselect the IP Security option.\nPlease note that unselecting this option may mean vulnerbality to other common security measures.");
    } else {
        obj.src = src_str.replace("ipoff", "ipon");
        SetCookie("IPopt", "", 0, "", "uforia.com");
    }
}

/*** Cookie 생성 ***/
function SetCookie(name, value, expires, path, domain) {
    var today = new Date();

    today.setDate(today.getDate() + expires);
    document.cookie = name + "=" + escape(value) + ((expires) ? "; expires=" + today.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "");
}


var xmlHttp;

function createXMLHttpRequest() {
    if(window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } else if(window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}

function doCheckID(arg) {
	createXMLHttpRequest();
	var queryString = "/Member/CheckIDNAME.aspx?type=A&val="+arg;
    xmlHttp.onreadystatechange = resultCheckVal;
    xmlHttp.open("POST", encodeURI(queryString), true);
    xmlHttp.send(null);
}

function resultCheckVal() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
			var responseText = xmlHttp.responseText;
			var validateObj = document.getElementById("ctl00_ContentPlaceHolder1_CustomValidator1");
			if (responseText == "1")
			{
				validateObj.style.display = "";
			} else {
				validateObj.style.display = "none";
			}
        }
	}
}

function doCheckNAME(arg) {
	createXMLHttpRequest();
	var queryString = "/Member/CheckIDNAME.aspx?type=B&val="+arg;
    xmlHttp.onreadystatechange = resultCheckVal2;
    xmlHttp.open("POST", encodeURI(queryString), true);
    xmlHttp.send(null);
}

function resultCheckVal2() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
			var responseText = xmlHttp.responseText;
			var validateObj = document.getElementById("ctl00_ContentPlaceHolder1_CustomValidator2");
			if (responseText == "1")
			{
				validateObj.style.display = "";
			} else {
				validateObj.style.display = "none";
			}
        }
	}
}