// title
document.title=" :: KUMHO TIRES ::";

var ns = (document.layers)? true:false;
var ie = (document.all)? true:false;
var doc = (ie)? document.all : document;

//	DESC : Javascript Utility
function DeleteConfirm(StrURL) {
	var bRet;
	bRet = confirm("The data which it eliminates it will not be able to rehabilitated.\nTruth it eliminates?");
	if(bRet) {							
		window.location = StrURL;
	}
}

function callCalendar(datetime,field){
		dateField = field;
		__showCalendarPanel(datetime,'::');
} 

function __showCalendarPanel(type, param, title, x, y)
{
		if(param == null){
			alert("Javascript:__showCalendarPanel: You must specify the parameter");
			return;
		}
		var separator = ":";
		var pa = param.split(separator);
		
		if(pa.length != 3)	//<= 1 || (pa[0].length <= 0 && pa[1].length <= 0)) 
		{
			alert("Javascript:__showCalendarPanel: You must specify INPUT objects name to be set to local datetime or GMT one");
			return;
		}

		var left = 100;
		var top = 200;
		if(x != null) left = x;
		if(y != null) top = y;
		
		var url = "/common/calendar.jsp?type=" + type + "&objLocalDate=" + pa[0] + "&objGMTDate=" + pa[1] + "&initDateTime=" + pa[2] + ( title != null ? "&title=" + title : "");
		var width  = (ie) ? "230":"240";
		if( type == "date" )
			var height = (ie) ? "288":"293";
		else
			var height = (ie) ? "318":"323";
		var ws  = "left=" + left + ",top=" + top + ",menubar = no,width=" + width + ",height=" + height + ",resizable=no,scrollbars=no";
		window.open(url, "__newWin", ws);
}

function setDateTime(local, gmt, type){
	if(type=='date'){
		dateField.value = local.substring(0, 4)
						+ "-" + local.substring(4, 6)
						+ "-" + local.substring(6, 8);
	}
	else{
		dateField.value = local.substring(0, 4)
						+ "-" + local.substring(4, 6)
						+ "-" + local.substring(6, 8)
						+ " " + local.substring(8, 10)
						+ ":" + local.substring(10, 12);
	}

}

function OpenWin(URL,WinName,x,y,Menu,cSize,scroll) {				
	
	var features;
	
	var nTop = (screen.height - y) / 2 - 30;
	var nLeft = (screen.width - x) / 2;
	
	if (Menu == 0 )
		features = "toolbar=no,width=" + x + ",height=" + y + ",top=" + nTop + ",left=" + nLeft + ",status=no,menubar=no";
	else
		features = "toolbar=no,width=" + (x + 18) + ",height=" + y + ",top=" + nTop + ",left=" + nLeft + ",status=no,menubar=yes";
	
	if (cSize == 0)
		features = features + ",resizable=no";
	else
		features = features + ",resizable=yes";
	
	if (scroll == 0 )
		features = features + ",scrollbars=no";
	else
		features = features + ",scrollbars=yes";
	
	//alert(features);
	
	TheWindow = window.open(URL, WinName, features);
}

function OpenWinHide(URL,WinName){
	TheWindow = window.open(URL,WinName,'top=100,left=100,width=100,height=100,status=no,menubar=no,resizable=no,scrollbars=no');
}

function OpenZipCode(frmNm,zipNm,adrNm){
	OpenWin('/common/zipcode_popup.jsp?frmNm='+frmNm+'&zipNm='+zipNm+'&adrNm='+adrNm,'zipcd',367,275,0,0,1);
}

// POPUP-PAGE AUTO RESIZE //
function resize_pop_600_scroll() {
	var obj = navigator.appVersion;
	var hei = 29;
	if (navigator.appVersion.indexOf("NT") != -1) {
		os = obj.substr(obj.indexOf("NT"),6);
		if (os > "NT 5.0") {
			hei = 35;
		}
	}
	wid = document.body.scrollWidth+10;
	hei = document.body.scrollHeight+hei;
	if(hei>600) hei=600;
	self.resizeTo(wid+16,hei);
	this.focus();
}

//E-mail type prosecuting attorney
function isEmail(elm) {

    var at = elm.indexOf("@");
    var length = elm.length;
    
    if((at == -1) || (length-1) == at) {
            return false;
    }
    else {
            for(var i=0; i < length; i++) {
                    var ch = elm.charAt(i);
                    if(i == at) {
                            continue;
                    }
                    else if(elm.indexOf(".", at) == -1) {
                            return false;
                    }
                    else if((ch >= 'A' && ch <= 'z')  || (ch >= '0' && ch <= '9') || ch == '.' || ch == '_' || ch == '-') {
                            continue;
                    }
                    else {
                            return false;
                    }
            }
            return true;
    }
}

//Checking which probably is all number
function isDigit(number) {
	for(var i=0;i < number.length;i++){
		if (!(number.charAt(i) >= "0" && number.charAt(i) <= "9")){
			return false;
		}
	}
	return true;
}

//Checking which probably is all number
//(The object it passes over and when it receives and is not the number and it leaves space a message with automatic movement.)
// Ex) <input type='text' name='sample' onKeyUp='chkNumeric(this);'>
function chkNumeric(obj){
	var str = "";
	var sChk = 0;
	var src = obj.value;
	for(var i=0; i< src.length; i++){
		if(isNaN(src.charAt(i))||src.charAt(i) == " ")	sChk += 1; 
		else 	str += src.charAt(i);
	}
	if(sChk!=0){ alert("[Input error]: Only number input."); obj.value = str; return false; }
	return true;
}

//ID and passwd checking(Checking which is composed of only a number or an alphabet.)
function isDigitEng(val) {
	for(var i=0;i < val.length;i++) {
		if (!(((val.charAt(i) >= "0") && (val.charAt(i) <= "9")) || ((val.charAt(i) >= "A") && (val.charAt(i) <= "Z")) || ((val.charAt(i) >= "a") && (val.charAt(i) <= "z"))) == true)
			return false;
		}
		return true;
}

//ID and passwd checking (It does not return a price not to be, message it leaves space with automatic movement and the blank to put in.)
// Ex) <input type='text' name='sample' onKeyUp='chkNumEng(this);'>
function chkNumEng(obj) {
	var str = "";
	var sChk = 0;
	var src = obj.value;
	for(var i=0;i < src.length;i++) {
		if (!(((src.charAt(i) >= "0") && (src.charAt(i) <= "9")) || ((src.charAt(i) >= "A") && (src.charAt(i) <= "Z")) || ((src.charAt(i) >= "a") && (src.charAt(i) <= "z"))) == true)
			sChk += 1;
		else	str += src.charAt(i);
	}
	if(sChk!=0){ alert("[Input Error]: Only English or number input."); obj.value = str; return false; }
	return true;
}

/*
 * 2byte With it recognizes the Korean alphabet and well it buys the length which becomes
 */
function getByteLength(s){
  var len = 0;
  if ( s == null ) return 0;
  for(var i=0;i<s.length;i++){
     var c = escape(s.charAt(i));
     if ( c.length == 1 ) len ++;
     else if ( c.indexOf("%u") != -1 ) len += 2;
     else if ( c.indexOf("%") != -1 ) len += c.length/3;
  }
  return len;
}
function isNull(value) {
   if (value == null || value == "") {
       return true;
   }
   return false;
}
function isEmpty(value) {
   if (value == null || value.replace(/ /gi,"") == "") {
       return true;
   }
   return false;
}

/*
 * Cookie functions
 */
var cookiePath = '/';

function getCookieVal( offset )
{
    var endstr = document.cookie.indexOf ( ";", offset );

    if(endstr == -1){
        endstr = document.cookie.length;
    } 
    return unescape(document.cookie.substring( offset, endstr ));
}

function getCookie( name )
{
    var arg = escape(name) + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;

    while (i < clen){
        var j = i + alen;

        if(document.cookie.substring(i, j) == arg){
            return getCookieVal ( j );
        }
        i = document.cookie.indexOf( " ", i ) + 1;

        if(i == 0){
            break;
        }
    } 
    return null;
}

function setCookieOneDay(name, value)
{
    var expDate = new Date();

    //valid one minute
    expDate.setTime(expDate.getTime() + (24 * 60 * 60 * 1000));
    setCookie(name,value,expDate,'/');
}

function setCookieDay(name, value, day)
{
    var expDate = new Date();

    //valid one minute
    expDate.setTime(expDate.getTime() + (day * 24 * 60 * 60 * 1000));
    setCookie(name,value,expDate,'/');
}

function setCookie( name, value)
{
    var argv = setCookie.arguments;
    var argc = setCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;

    document.cookie = escape(name) + "=" + escape (value) +
    (( expires == null) ? "" : ( "; expires=" + expires.toGMTString() ) ) +
    (( path == null) ? "" : ( "; path=" + path ) ) +
    (( domain == null) ? "" : ( "; domain=" + domain ) ) +
    (( secure == true) ? "; secure" : "" );
}

function deleteCookie (name)
{
    var exp = new Date();
    exp.setTime ( exp.getTime() - 1 );// This cookie is history
    var cval = getCookie (escape(name));
    document.cookie = escape(name) + "=" + cval + "; expires=" + exp.toGMTString() + "; path=/";
}

/*
 * Image Change
 */
function imagechange(imagename, imageurl)
{
	document.images[imagename].src=imageurl;
}

function over(image)
{
    var image_name = image + '_over.gif';
	document.images[image].src = image_name;
}
function out(image)
{
    var image_name = image + '_out.gif';
	document.images[image].src = image_name;
}
function swapimage(file,imagename,defaultimage)
{
	var imagefile;
	var tmpimage = new Image;
	// default image
	if(file.value==''){
		imagefile = defaultimage;
	}
	else{
		imagefile = "file:///"+file.value;
	}
	// change image
	tmpimage.src=imagefile;
	document[imagename].src = tmpimage.src;
	document[imagename].width = tmpimage.width;
	document[imagename].height = tmpimage.height;
	// form value setting
	return true;
}


// swapImg
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.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 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_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

/*******    이미지 ON & OFF _Start   *******/
function menuOn(imgEl)
{
	imgEl.src = imgEl.src.replace(".gif", "_on.gif");
}

function menuOut(imgEl)
{
	imgEl.src = imgEl.src.replace("_on.gif", ".gif");
}

/*******    이미지 ON & OFF _End   *******/


function login(){
	window.open('/login/login_popup.jsp','loginWin','top=100,left=100,width=100,height=100,status=no,menubar=no,resizable=no,scrollbars=no');
}

/****************************
* Pop up 
*************************************/

function popup(page,name,x,y){
	opt = "toolbar=no,alwaysRaised=no,location=no,status=no,menubar=no,scrollbars=no,width="+x+",height="+y+",resizable=no,hotkey=no,dependent=no,screenX=0,screenY=0, top=0, left=0"
	window.open(page,name,opt)
	}
	

/***********************************************************************
* Scrolling
***********************************************************************/

var verticalpos="frombottom"

function JSFX_FloatTopDiv() {
    var startX = 905;   // X
        startY = 190;  // from bottom
    var ns = (navigator.appName.indexOf("Netscape") != -1);
    var d = document;
    function ml(id) {
        var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
        if(d.layers)el.style=el;
        el.sP=function(x,y){this.style.left=x;this.style.top=y;};
        el.x = startX;
        if (verticalpos=="fromtop")
        el.y = startY;
        else{
        el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
        el.y -= startY;
        }
        return el;
    }
    window.stayTopLeft=function() {
        if (verticalpos=="fromtop"){
        var pY = ns ? pageYOffset : document.body.scrollTop;
        ftlObj.y += (pY + startY - ftlObj.y)/8;
        }
        else{
        var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
        ftlObj.y += (pY - startY - ftlObj.y)/8;
        }
        ftlObj.sP(ftlObj.x, ftlObj.y);
        setTimeout("stayTopLeft()", 10);
    }
    ftlObj = ml("divStayTopLeft");
    stayTopLeft();
}

/***********************************************************************
// ũ ּ  մϴ.- 2008 5 ο Ʈ ߰
***********************************************************************/
function resizeToMinimum(minimumWidth, minimumHeight, targetTable){

	if(document.body.clientWidth<minimumWidth){
		targetTable.style.width = minimumWidth + "px";
	}else{
		targetTable.style.width = "100%";
	}
	
	if(document.body.clientHeight<minimumHeight){
		targetTable.style.height = minimumHeight + "px";
	}else{
		targetTable.style.height = "100%";
	}
	
}

