
document.title = "Mythos";

function ResizeImage(id) {
	var img = document.getElementById("UserImage" + id);
	
	if (img.width > 500) {
		img.width = 500;
	} else if (img.width == 0) {
		setTimeout("ResizeImage('" + id + "')", 200);
	}
}


function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function imgError(obj)
{
    //obj.src="/images/common/gallery_default.jpg";
}



function setInnerTextProperty() {
 if(typeof HTMLElement != "undefined" && typeof HTMLElement.prototype.__defineGetter__ != "undefined") {
  HTMLElement.prototype.__defineGetter__("innerText",
  function() {
   if(this.textContent) {
    return(this.textContent)
   } else {
    var r = this.ownerDocument.createRange();
    r.selectNodeContents(this);
    return r.toString();
   }
  });

  HTMLElement.prototype.__defineSetter__("innerText",
  function(sText) {
   this.innerHTML = sText
  });
 }
}


function SetValidationMsg(title)
{
	switch (title)
	{
		case "Month" :
			alert("Please select a valid month of birth.");
			break;
		case "Day" :
			alert("Please select a valid day of birth.");
			break;
		case "Year" :
			alert("Please enter a valid year of birth.");
			break;
		case "ID" :
			alert("Please enter a valid User ID.");
			break;
		case "PW" :
			alert("Please enter a password.");
			break;			
		case "PWLength" :
			alert("Password length cannot be less than 6 characters.");
			break;			
		case "PWConfirm" :
			alert("Your password entries did not match. Please re-enter passswords and make sure they are identical.");
			break;			
		case "PWError" :
			alert("Invalid password format. Please enter a valid password.");
			break;			
		case "CheckID" :
			alert("Please check the User ID availability.");
			break;
		case "IDLength" :
			alert("User ID must be at least 4 characters long.");
			break;			
		case "MailError" :
			alert("Invalid e-mail format. Please enter a valid e-mail address.");
			break;		
		case "CheckMail" :
			alert("Please check the E-mail availability.");
			break;						
		case "Name" :
			alert("Please enter your name.");
			break;					
		case "Gender" :
			alert("Please speccify your gender.");
			break;							
		case "Quest" :
			alert("Please choose the question.");
			break;				
		case "Answer" :
			alert("Please enter the answer.");
			break;				
		case "Captcha" :
			alert("Please enter the verification code.");
			break;							
		case "CaptchaMatch" :
			alert("Incorrect code entered. Please try again.");
			break;										
		case "Service" :
			alert("You must agree to the Terms of Use in order to complete the sign up process.");
			break;
		case "LoginID" :
			alert("Enter your ID.");
			break;			
		case "LoginPW" :
			alert("Enter your password.");
			break;		
		case "MailConfirm" :
			alert("Your E-mail entries did not match.");
			break;			
		case "MemberInfo" :
			alert("The information you have entered does not match.\r\nPlease enter the correct information");
			break;
		case "NotCorrectPW" :
			alert("Password is not correct.");
			break;
		case "NotCorrectAnswer" :
			alert("Please enter a valid answer to Secret Question.");
			break;
		case "BadID" :
			alert("ID is not correct.");
			break;			
		case "BadPW" :
			alert("Password is not correct.");
			break;
		case "LoginFail" :
			alert("An error has been occurred during log-in process. Please try again.");
			break;				
		case "Loging" :
			alert("Log-in...Please wait.");
			break;					
		case "Empty" :
			alert("");
			break;	
	}
}




function SetValidationMsgWithID(id, title, place)
{	
	switch (title)
	{
		case "Success" :
			document.getElementById(place).innerText = id + " is available.";
			break;
		case "Fail" :
			document.getElementById(place).innerText = id + " is unavailable.";
			break;
	}
}

function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}


function layerOn (id) {
	var el = document.getElementById(id);
	el.style.display = (el.style.display == 'none') ? 'block' : 'none';
	return false;
}

try { document.execCommand("BackgroundImageCache",false,true) } catch (e) {};



function layerOn (id) {
	var el = document.getElementById(id);
	el.style.display = (el.style.display == 'none') ? 'block' : 'none';
	return false;
}

function cghName (id) {
	var target = document.getElementById(id);
	if (target.className.indexOf('setQuery_sm') > -1 ) target.className="setQuery";
	else target.className="setQuery setQuery_sm";
}


// IE6 ÇÃ¸®Ä¿¹ö±× ÆÐÄ¡
try { document.execCommand("BackgroundImageCache",false,true) } catch (e) {};


// ÀÌ¹ÌÁö ÆË¾÷
function popview(url) {	
	openWindow("/Popup/ViewImage.aspx?url=" + encodeURI(url), "view", "width=100,height=100,status=no,scrollbars=yes");
}

// windowsopen
function openWindow(loc, name, opt) {
	var win = window.open(loc, name, opt);
	if (win == null) {
		alert("close popup");
	}
	else {
	    win.focus();
	}
}

// add get variable
function AddGetVariable(url, name, value) {
	url = url + "";

	var index0 = url.indexOf("?" + name + "=");

	if (index0 == -1) {
		var index1 = url.indexOf("&" + name + "=");

		if (index1 == -1) {
			if (url.indexOf("?") == -1) {
				url = url + "?" + name + "=" + value;
			} else {
				url = url + "&" + name + "=" + value;
			}
		} else {
			var index2 = url.substr(index1 + 1).indexOf("&");
			if (index2 == -1) {
				url = url.substr(0, index1) + "&" + name + "=" + value;
			} else {
				url = url.substr(0, index1) + url.substr(index1 + index2 + 1, url.length) + "&" + name + "=" + value;
			}
		}
	} else {
		var index3 = url.substr(index0 + 1).indexOf("&");
		if (index3 == -1) {
			url = url.substr(0, index0) + "?" + name + "=" + value;
		} else {
			url = url.substr(0, index0) + "?" + name + "=" + value + url.substr(index0 + index3 + 1, url.length);
		}
	}	

	return url;
}

function GetGetVariable(url, name) {
	url = url + "";

	var index0 = url.indexOf("?" + name + "=");

	if (index0 == -1) {
		var index1 = url.indexOf("&" + name + "=");

		if (index1 == -1) {
			return "";
		} else {
			var index2 = url.substr(index1 + name.length + 2).indexOf("&");
			if (index2 == -1) {
				return url.substr(index1 + name.length + 2);
			} else {
				return url.substr(index1 + name.length + 2, index2);
			}
		}
	} else {
		var index3 = url.substr(index0 + name.length + 2).indexOf("&");
		if (index3 == -1) {
			return url.substr(index0 + name.length + 2);
		} else {
			return url.substr(index0 + name.length + 2, index3);
		}
	}
}

function DeleteGetVariable(url, name) {
	url = url + "";

	var index0 = url.indexOf("?" + name + "=");

	if (index0 == -1) {
		var index1 = url.indexOf("&" + name + "=");

		if (index1 != -1) {
			var index2 = url.substr(index1 + 1).indexOf("&");
			if (index2 == -1) {
				url = url.substr(0, index1);
			} else {
				url = url.substr(0, index1) + url.substr(index1 + index2 + 1, url.length);
			}
		}
	} else {
		var index3 = url.substr(index0 + 1).indexOf("&");
		if (index3 == -1) {
			url = url.substr(0, index0);
		} else {
			url = url.substr(0, index0) + "?" + url.substr(index0 + index3 + 2, url.length);
		}
	}	

	return url;
}

function GoCBT()
{
    window.open("/Event/100811/Event01.aspx", "event", "location=no, directories=no,resizable=no,status=no,toolbar=no,menubar=no,left=0, top=0, width=350, height=500, scrollbars=no");
}

// ÇöÀç ÀÔ·ÂÇÑ ¹®ÀÚÀÇ byte¸¦ °è»êÇÑ´Ù.
function checkLength(contents)
{
    var str_character;
    var int_char_count;
    var int_contents_length;

    int_char_count = 0;

    int_contents_length = contents.length;


    // ÇÑ±Û°ú ¿µ¹® ¹ÙÀÌÆ®¼ö °è»êÇÏ´Â ºÎºÐ
    // ¾Æ·¡ ºÎÅÍ ¼öÁ¤ ¾Ê¾Æ¼Åµµ µË´Ï´Ù.
    for(k=0; k < int_contents_length; k++)
    {
	    str_character = contents.charAt(k);
	    if(escape(str_character).length > 4)
		    int_char_count += 2;  
	    else
		    int_char_count++;
    }
    // ¿©±â±îÁö´Â ¼öÁ¤ ¾Ê¾Æ¼Åµµ µË´Ï´Ù.

    return int_char_count;
}


function fnResizeByClass(className, width)
{
   
    // width °ªÀÌ º¯ÇÑ Á¤µµ °ªÀ» ÀúÀå ÇÏ´Â º¯¼ö
    var factor      = 0.0;
    // ÅÂ±×³ª ¼Ó¼º°ª¿¡ width³ª height °ªÀÌ ¾øÀ» °æ¿ì width °ª Á¶Àý½Ã ÀÚµ¿À¸·Î height °ªÀ» Á¶Á¤ÇÑ´Ù.
    // ±×·¡¼­, ÀÚµ¿À¸·Î height °ªÀÌ Á¶ÀýÀÌ µÇ¾úÀ» °æ¿ì, width°ªÀÌ º¯È­µÈ Á¤µµ¿¡ µû¶ó height °ªÀ» Á¶Àý ÇÏ´Â °úÁ¤À»
    // °ÅÄ¡Áö ¾Ê±â À§ÇØ¼­ »ç¿ë ÇÑ´Ù.
    var isChange    = false;        
    var height      = 0;
    // ¾ÆÁ÷ ÀÌ¹ÌÁö°¡ ·Îµå µÇ±â ÀÌÀü¿¡ ½ºÅ©¸³Æ®°¡ ½ÇÇàÀÌ µÇ¸é, 
    // ÀÌ¹ÌÁö ¸®»çÀÌÂ¡ÀÌ µÇÁö°¡ ¾Ê¾Æ, À¥Ç¥ÁØ ÄÚµùÀÌ µÇ¾îÀÖ´Â ¿ÀÇÇ¼ÈÀº ¿ìÃø ÄÁÅÙÃ÷°¡ ÇÏ´ÜÀ¸·Î ¶³¾îÁ® ¹ö¸®´Â °æ¿ì°¡ »ý±æ ¼ö ÀÖ´Ù.
    // document.onload ³ª $(document).ready() ÀÌº¥Æ®¿¡¼­ ÇÔ¼ö¸¦ È£Ãâ ÇÏ¸é, ÀÌ¹ÌÁö ¸®»çÀÌÂ¡ÀÌ ¾ÈµÉ ¼ö ÀÖ´Ù.
    // classNameÀÌ Á¸ÀçÇÏ´Â DOM ¹Ù·Î ¹Ø¿¡ µÎ¾î¾ß ÇÑ´Ù.
    //$.each($("." + className + " img,."+className + " embed"), function (name, value) {
    $("." + className + " img,."+className + " embed").bind('load', function () {
        if ($(this).width() > width) {
            height = $(this).height();
            factor = width / $(this).width();
            $(this).css("width", width);
            isChange = height == $(this).height() ? false : true;
        } else if ($(this).width() == 0) {
            $(this).css("width", width);
        }
        
        if ($(this).attr("width") > width) {
            height = $(this).height();
            factor = width / $(this).attr("width");
            $(this).attr("width", width);
            isChange = height == $(this).height() ? false : true;
        } else if ($(this).attr("width") == 0) {
            $(this).attr("width", width);
        }
        
        if (factor != 0.0 && !isChange)
        {
            $(this).css("height", $(this).height() * factor);
            $(this).attr("height", $(this).attr("height") * factor);
            
            factor = 0.0;
        }
    });
}
