/*********************************************************************
 * google analytics script 
 * 2011.02.23 박호석 
**********************************************************************/
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-21603709-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

/**************************************************************************************************************/
var CCode		= "";
var MetaStr = "";

MetaStr += "<META name='Keywords' content='patent search,industrial property,";
MetaStr += " intellectual property, patent, PM,PM-manager,patent analysis,trademark,industrial design,invention, WIPS,BM, PM, patent map,";
MetaStr += " Dal,Brandvision.com,dbplaza.com,patent cooperation treaty,PCT,IPC,trade secret,wips.co.kr,patent application,patent information,";
MetaStr += " business intelligence,patent search database,patolis,sdi'>";
document.write(MetaStr);

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_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

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 na_open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';
  window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}

function getCookie( name ){
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length )
	{
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ) {
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
			endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}

		x = document.cookie.indexOf( " ", x ) + 1;

		if ( x == 0 ) break;
	}
			return "";
}

function setCookie( name, value, expiredays ) {
        var todayDate = new Date();
        todayDate.setDate( todayDate.getDate() + expiredays );
        document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function CookieOpenWin(cookies,theURL,winName,features) {
	//쿠키네임을 받아 해당쿠키가 done이 아니면 팝업띄움
	if (getCookie(cookies) != "done") {
		window.open(theURL,winName,features);
	}
}

function NoSingleQuot(string){
	// single quotation mark  false
	valid = "'";
	for(var i = 0; i< string.length ; i++){
		//alert(valid.indexOf(string.charAt(i)))
		if(valid.indexOf(string.charAt(i)) > -1){
			return false;
		}
	}
	return true;
}

function check_space(str) {
	//공백을 제거하고 입력 여부 체크
	if (str.search(/\S/)<0) {
		return false;
	}
	var temp=str.replace(' ','');
	if (temp.length == 0) {
		return false;
	}
	return true;
}

function AlpaNumber(string) {
	//알파벳이나 숫자가 아닌 문자가 포함되어 있으면 false 리턴
	valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	for (var i=0; i< string.length; i++) {
		if (valid.indexOf(string.charAt(i)) == -1) {
		return false;
		}
	}
	return true;
}

function NoNumber(string) {
	if (!f_chkNoNum(string)) {
		alert("숫자는 포함될 수 없습니다.");
		return false;
	}
	return true;
}

function f_chkNoNum(string) {
	//숫자가 포함되어 있으면 false 리턴
	valid = "0123456789";
	for (var i=0; i< string.length; i++) {
		if (valid.indexOf(string.charAt(i)) != -1) {
			return false;
		}
	}
	return true;
}

function OnlyNumber(string) {
	if (!f_chkOnlyNum(string)) {
		return false;
	}
	return true;
}

function f_chkOnlyNum(string) {
	//숫자 외의 문자가 포함되어 있으면 false 리턴
	valid = "0123456789";
	for (var i=0; i< string.length; i++) {
		if (valid.indexOf(string.charAt(i)) == -1) {
			return false;
		}
	}
	return true;
}

function f_chkSpecialChar(string) {
	// 특수문자 ' 가 포함되어 있으면 false 리턴
	valid = "'/:*<>|";
	for (var i=0; i< string.length; i++) {
		if (valid.indexOf(string.charAt(i)) != -1) {
			return false;
		}
	}
	return true;
}

function Calbyte(aquery) {
	//바이트 수 계산
	//aquery - 계산할 스트링
	var tmpStr;
	var temp=0;
	var onechar;
	var tcount;
	tcount = 0;

	tmpStr = new String(aquery);
	temp = tmpStr.length;

	for (k=0;k<temp;k++) {
		onechar = tmpStr.charAt(k);
		onechar_1 = escape(onechar); // ISO -> ASCII
		if ( onechar_1.charAt(0) == "%" ) {
			onechar_1 = onechar_1.substring(1,2);
			switch ( onechar_1 ) {
			case "0":
			case "1":
			case "2":
			case "3":
			case "4":
			case "5":
			case "6":
			case "7":
				tcount++;
				break;
			default:
				tcount += 2;
				break;
			}
		}
		else if (onechar!='\r') { //Enter외
			tcount++;
		}
	}
	return tcount;
}

function f_TogShowHide(LayerName) {
	//레이어 show, hide
	var DisplayVal = document.getElementById(LayerName).style.display;
	if(DisplayVal=='none') {
		document.getElementById(LayerName).style.display = 'block';
	} else {
		document.getElementById(LayerName).style.display = 'none';
	}
}

function f_TogShow(LayerName) {
	//레이어 show
	document.getElementById(LayerName).style.display = 'block';
}

function f_TogHide(LayerName) {
	//레이어 hide
	document.getElementById(LayerName).style.display = 'none';
}

function Move_Cur(arg,nextname,len) {
  if (arg.value.length==len) {
      nextname.focus() ;
      return;
   }
}

function Move_URL(URL, SubCC){
	var S1 = document.frmSearch.SrchQuery.value;

	/* 2007-10-05 임시 추가 (AUX 서버 교체) */
	var time = new Date();
	var year = time.getYear();
	var month = time.getMonth() + 1;
	var day = time.getDate();
	var hours = time.getHours();
	var minute = time.getMinutes();

	month = ((month<10) ? "0" : "") + month;
	day = ((day<10) ? "0" : "") + day;
	hours = ((hours<10) ? "0" : "") + hours;
	minute = ((minute<10) ? "0" : "") + minute;

	temp = year +""+ month +""+ day +""+ hours +""+ minute;

	if (temp >= "200710052100" && temp <= "200710062359") {
		if (URL.search("_KR") > 0 || URL.search("USP") > 0 || URL.search("JP") > 0) {
				parent.location.href = URL+'&S1='+S1+'&SubCC='+SubCC;
		} else {
			alert(" Sorry for the inconvenience     \n\n Service suspension from October, 5 (21:00) - October, 6 (24:00) ");
			return;
		}
	} else {
		parent.location.href = URL+'&S1='+S1+'&SubCC='+SubCC;
	}
	/* 2007-10-05 임시 추가 (AUX 서버 교체) */

	//parent.location.href = URL+'&S1='+S1+'&SubCC='+SubCC;
}

//출력항목 전체선택-선택해제
function all_CLcheck(frmName){

	if (eval(frmName+".CL_ALL.checked == true")){
		eval(frmName+".CL_CC.checked = true");
		eval(frmName+".CL_AD.checked = true");
		eval(frmName+".CL_XD.checked = true");
		eval(frmName+".CL_IPC.checked = true");
		eval(frmName+".CL_AP.checked = true");
		eval(frmName+".CL_TI.checked = true");
		eval(frmName+".CL_AN.checked = true");

		eval(frmName+".CL_CC.disabled = true");
		eval(frmName+".CL_AD.disabled = true");
		eval(frmName+".CL_XD.disabled = true");
		eval(frmName+".CL_IPC.disabled = true");
		eval(frmName+".CL_AP.disabled = true");
		eval(frmName+".CL_TI.disabled = true");
		eval(frmName+".CL_TI.disabled = true");
		eval(frmName+".CL_AN.disabled = true");
		return;
	}
	else{
		eval(frmName+".CL_CC.checked = false");
		eval(frmName+".CL_AD.checked = false");
		eval(frmName+".CL_XD.checked = false");
		eval(frmName+".CL_IPC.checked = false");
		eval(frmName+".CL_AP.checked = false");
		eval(frmName+".CL_TI.checked = false");
		eval(frmName+".CL_AN.checked = false");

		eval(frmName+".CL_CC.disabled = false");
		eval(frmName+".CL_AD.disabled = false");
		eval(frmName+".CL_XD.disabled = false");
		eval(frmName+".CL_IPC.disabled = false");
		eval(frmName+".CL_AP.disabled = false");
		eval(frmName+".CL_TI.disabled = false");
		eval(frmName+".CL_AN.disabled = false");
	}

}


function NewWinLinkURL(vURL){
	parent.parent.top.location.href = vURL;
}

// 하단 footer Family Site 이동
function goFamilyStie(url) {
	if (url != "blank") {
			var pop = window.open(url,'','');
			pop.focus();
	}	
}


// 원문링크
function GoImageFile(userid, cc, wkey) {
	//location.href="/Wips_IMG/Wipsimg.asp?UserID=wips_master&DBN="+cc+"&WKEY="+wkey ;
	//na_open_window('WipsImg', "/Wips_IMG/Wipsimg_ActiveX.asp?UserID="+userid+"&DBN="+cc+"&WKEY="+wkey, 50, 80, 440, 470, 0, 0, 0, 0, 1);
	// 2010-12-08 김도경 Server Side 방식으로 변경
	na_open_window('WipsImg', "/wips_gl_DN/dwnld/dwnld_pdf.aspx?WKEY="+wkey+"@"+cc, 50, 80, 540, 280, 0, 0, 0, 0, 1);
}


// 검색식 괄호 갯수 체크
function checkQuery(query) {
	var i; 
	var	sum1 = 0;
	var sum2 = 0;

	for (i=0; i < query.length; i++) {
		if (query.charAt(i) == "(")	{
			sum1 += 1;
		}	else if (query.charAt(i) == ")") {
			sum2 += 1;
		}
	}

	if (sum1 != sum2) {
		alert("The Number of Parentheses () is Not Correct.      ");
		return false;
	} else {
		return true;
	}
}

// IE 7.0에 맞도록 사이즈 변경
function popReSize(width, height) {
	var userAgent = window.navigator.userAgent;

	if (userAgent.indexOf("MSIE 7.0") != -1) {													// IE가 7.0 이상인 경우
		var xpTitleBarHeight = 29;																				// XP 타이틀 바 = 29px
		var border = 2;																										// 가장 자리 = 2px
		var ifXPSP2_statusBarHeight = 25;																	// XPSP2 이하의 상태 표시줄 = 25px
		var ifW2k = 22;																										// Win2k의 경우 부가적으로 축소되는 크기 = 22px
		
		height = height - xpTitleBarHeight- border;  
		if (userAgent.indexOf("Windows NT 5.1") != -1) {									// Windows XP
			height += ifXPSP2_statusBarHeight + xpTitleBarHeight + ifW2k;
		} else if (userAgent.indexOf("Windows NT 6.0") != -1) {						// Windows Vista
			height += ifXPSP2_statusBarHeight + xpTitleBarHeight + ifW2k;
		}
	}
	window.resizeTo(width, height);
}


function f_chkSpecialChange(string) {
	// 특수문자 ', ;가 포함되어 있으면 ', :으로 변환
	var tmpStr;
	var tmpStr = string.replace(/'/g, "`");
	var tmpStr = tmpStr.replace(/;/g, ":");
	return tmpStr;
}
