// JavaScript Document
/***************************************************************
Content List
- default module
- string Function
- Form check Function
***************************************************************/

function setCookie(name,value,expires,domain) {
document.cookie=name + "=" + escape(value) + ((expires == null)? "" : (" ; expires=" + expires.toGMTString())) + "; domain=" + (domain ? domain : "www.naver.com") + ";" ;
}
function openWindow(url, name, width, height) {
window.open( url, name, 'toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=no,scrollbars=no,width='+width+',height='+height+',top=30,left=230');
}

function pop_turnoff(url,message){
	if(message) alert(message);
	
	if(url)		opener.document.location = url;
	w			= opener.window;
	w.focus();
	window.close();
}

/**************************************************************************
Form Check Function
**************************************************************************/
function FormUserIDCheck(str){
		var strcheck = /^[_0-9a-zA-Z]+$/;
		if(str.length < 4)			return false;
		if(str.length > 20)			return false;
		if(!strcheck.test(str))		return false;
		else						return true;
}

function FormEmailCheck(str){
		var strcheck = /^[_0-9a-zA-Z-]+(.[_0-9a-zA-Z-]+)*@[0-9a-zA-Z-]+(.[0-9a-zA-Z-]+)*$/;
		if(!strcheck.test(str))		return false;
		else						return true;
}

function FormWebsiteCheck(str){
		var strcheck = /^[a-zA-Z]+\:\/\/([^\/:]+(:(d+))?)(\/.*)?$/;
		if(!strcheck.test(str))		return false;
		else						return true;
}
function FormPhoneCheck(str){
		var strcheck = /^[0-9\-\+]+$/;
		if(!strcheck.test(str))		return false;
		else						return true;

}

function str_numBigger(str,num){
		if(str.length > num)	return true;
		else					return false;	
}



	function FormCheck(oForm,form_arr,form_name){
		var checkele;
		for(var i=0;i < form_arr.length ;i++){
			checkele		= parseInt(form_arr[i]);
			if(oForm.elements[checkele].value == "" ||
				oForm.elements[checkele].value == null){
				alert("Please Enter your " + form_name[i] );
				oForm.elements[checkele].focus();
				return false;
			}
		}
		return true;
	}

	function FormCheck1(oForm,form_arr,form_name){
		var checkele;
		for(var i=0;i < form_arr.length ;i++){
			checkele		= form_arr[i];
			if(oForm.elements[checkele].value == "" ||
				oForm.elements[checkele].value == null){
				alert("Please Enter your " + form_name[i] );
				oForm.elements[checkele].focus();
				return false;
			}
		}
		return true;
	}

	/* can use insertAdjacentElement function in fire fox */
if(typeof HTMLElement!="undefined" && !
HTMLElement.prototype.insertAdjacentElement){	
	HTMLElement.prototype.insertAdjacentElement = function(where,parsedNode){
			switch (where){
				case 'beforeBegin':
					this.parentNode.insertBefore(parsedNode,this)
					break;
				case 'afterBegin':
					this.insertBefore(parsedNode,this.firstChild);
					break;
				case 'beforeEnd':
					this.appendChild(parsedNode);
					break;
				case 'afterEnd':
					if (this.nextSibling) this.parentNode.insertBefore(parsedNode,this.nextSibling);
					else this.parentNode.appendChild(parsedNode);
					break;
			}
		}
	
		HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr) {
			var r = this.ownerDocument.createRange();
			r.setStartBefore(this);
			var parsedHTML = r.createContextualFragment(htmlStr);
			this.insertAdjacentElement(where,parsedHTML);
		}    
	
	
		HTMLElement.prototype.insertAdjacentText = function(where,txtStr){
			var parsedText = document.createTextNode(txtStr);
			this.insertAdjacentElement(where,parsedText);
		}
}

function GA_deliverActiveX(content){
	document.write(content);	
}

function loadingFLASH(w,h,s){
	var strFLASH =  ' <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"  ';
		strFLASH += ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0 "';
		strFLASH += ' width="'+w+'" height="'+h+'" id="MyFlash" align="top">';
		strFLASH += '<param name="allowScriptAccess" value="sameDomain" />';
		strFLASH += '<param name="movie" value="'+s+'" /><param name="quality" value="high" />';
		strFLASH += '<param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" />';
		strFLASH += '<embed src="'+s+'" quality="high" wmode="transparent" bgcolor="#ffffff" width="'+w+'" height="'+h+'" name="MyFlash" align="top" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		strFLASH += '</object>';
	document.write(strFLASH);
}

function resultFLASH(w,h,s){
	var strFLASH =  ' <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"  ';
		strFLASH += ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0 "';
		strFLASH += ' width="'+w+'" height="'+h+'" id="MyFlash" align="top">';
		strFLASH += '<param name="allowScriptAccess" value="sameDomain" />';
		strFLASH += '<param name="movie" value="'+s+'" /><param name="quality" value="high" />';
		strFLASH += '<param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" />';
		strFLASH += '<embed src="'+s+'" quality="high" wmode="transparent" bgcolor="#ffffff" width="'+w+'" height="'+h+'" name="MyFlash" align="top" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		strFLASH += '</object>';
		
		return strFLASH;
}




