﻿/* SSL 자동링크 변경 */
var array = ["hyundai-rotem.co.kr", "www.rotem.co.kr", "rotem.co.kr", "www.hyundai-rotem.com", "hyundai-rotem.com"];
	
if(location.href.indexOf("www.hyundai-rotem.co.kr")==-1)
{
	for (i = 0; i < array.length; i++) {
   	if(location.href.indexOf(array[i])!=-1){
			location.href = location.href.replace(array[i],"www.hyundai-rotem.co.kr").replace(location.protocol,"https:");
			break;
		}
 	}
}
else{
	if(location.protocol=="http:"){
		location.href = location.href.replace(location.protocol,"https:");
	}
}


  function chkSpace(strValue) {
    var flag= true;
    if (strValue != "") {
      for (var i=0; i < strValue.length; i++) {
	    if (strValue.charAt(i) != " ") {
	      flag = false;
	      break;
	    }
      }
    }
    return flag;
  }

  function chkValue(strValue, flag) {
    if (flag == "id") {
      var StandardStr = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    }
    else if (flag == "num") {
      var StandardStr = "0123456789";
    }
    else if (flag == "date") {
      var StandardStr = "0123456789-";
    }
    else if (flag == "email") {
      var StandardStr = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.@-_";
    }

    var strValueArray = new Array(strValue.length);
    for (i = 0; i < strValue.length; i++){
      strValueArray[i] = strValue.substring(i, i + 1);
    }

    for(j = 0; j < strValue.length; j++){
      if (StandardStr.indexOf(strValueArray[j]) < 0) {
        return true;
      }
    }
    return false;
  }

  function isemail(strValue) {
		pat=/^\s*[\w\~\-\.]+\@[\w\~\-]+(\.[\w\~\-]+)+\s*$/g
		return pat.test(strValue)
	}


  function isdate(strValue) {
		pat=/[0-9]{4}[\-][0-9]{2}[\-][0-9]{2}$/; 
		return pat.test(strValue.replace(" ",""))
	}

	function EnterCheck(e)
	{
		code = e.keyCode?e.keyCode:e.charCode; 
		if(code==13){goAction();}
	}
  
	
	function func_frameResize()
	{
		  //self.resizeTo(document.body.scrollWidth, document.body.scrollHeight);		  
		  //parent.document.all.frmid.height = document.body.scrollHeight;
		  //parent.document.getElementById("frmid").style.height = document.body.scrollHeight;
		  //parent.document.getElementById("frmid").setAttribute("height", document.body.scrollHeight);
		  //parent.document.getElementById("frmid").scrollHeight = document.body.scrollHeight;
		  //alert(parent.document.getElementById("frmid").style.height);
			//parent.parentResize();
	}
	
 	/************************************************************************
	*	Ajax Browser Check
	************************************************************************/
  function GetXMLHTTP()
  {
    
    if(window.XMLHttpRequest) return new XMLHttpRequest();
    
    
    var versions = [
      "MSXML2.XMLHTTP.5.0",
      "MSXML2.XMLHTTP.4.0",
      "MSXML2.XMLHTTP.3.0",
      "MSXML2.XMLHTTP",
      "Microsoft.XMLHTTP"
    ];
    
    for(var i=0;i<versions.length; i++)
    {
      try
      {
        var oXMLHTTP = new ActiveXObject(versions[i]);
        return oXMLHTTP;
      }
      catch(e){}
      
      //throw new Error("No XMLHTTP");
    }
  }
	
	function isNumericWithDash(input) {
	    var chars = "-0123456789";
	    return containsCharsOnly(input, chars);
	}
  

	function isValidFormat(input, format) {
	    if (input.value.search(format) != -1) {
	        return true;
	    }
	    return false;
	}
  

	function containsCharsOnly(input,chars) {
	    for (var i = 0; i < input.value.length; i++) {
	       if (chars.indexOf(input.value.charAt(i)) == -1) {
	           return false;
		   }
	    }
	    return true;
	}
	

	function ImgView(obj, vflg, w)
	{
		var image = obj.src;
		var pwidth = obj.width;
		var pheight = obj.height;
		var width = w;
		var height = pheight*width/pwidth;
		//var height = obj.height;
		var newWidth = 0;
		var newHeight = 0;
		var scroollbars = "NO";

		var scWidth = screen.width - 30;
		var scHeight = screen.height - 80;
		var scLeft = parseInt(screen.width / 2) - parseInt(width / 2);
		var scTop = parseInt(screen.height / 2) - parseInt(height / 2);

		if(scTop <= 0) scTop = "0";
		if(scLeft <= 0) scLeft = "0";

		if(width >= scWidth)
		{
			newWidth = scWidth;
			scLeft = 10;
			scroollbars = "YES";
		}
		else
		{
			newWidth = width;
			scroollbars = "NO";
		}

		if(height >= scHeight)
		{
			newHeight = scHeight;
			scTop = 10;

			if(scroollbars == "NO")
			{
				newWidth += 16;
				scLeft -= 8;
			}
			scroollbars = "YES";
		}
		else
		{
			newHeight = height;

			if(scroollbars == "YES")
			{
				newHeight += 16;
				scTop -= 8;
			}
			scroollbars = "NO";
		}
		
		if (vflg == "p")
		{
			var popUp = window.open("", "", "width="+newWidth+",height="+newHeight+ ",top=" + scTop + ",left=" + scLeft + "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scroollbars+",resizable=no");
			popUp.document.open();  
			popUp.document.writeln("<html>")
			popUp.document.writeln("<head><title>View Image</title></head>")
			popUp.document.writeln("<body topmargin='0' leftmargin='0'>");
			popUp.document.writeln("<a onclick=\"window.close();\" style=\"cursor:Hand;\" title=\"\"><img src='" + image + "' height='" + height + "' width='" + width + "' border='0'></a>");
			popUp.document.writeln("</body></html>");
			popUp.document.close();
		}
		else
		{
			var layer = document.createElement('DIV'); 
			layer.setAttribute("id", "layer");          
			layer.style.position = "absolute";
			Layer.style.top = scTop;
			Layer.style.left = scLeft;
			layer.innerHTML="<table><tr><td bgcolor=#ffffff><img src='"+obj.src+"' alt='' style=\"cursor:Hand;\" onclick=\"this.parentNode.style.display='none'\"></td></tr></table>";
			document.body.appendChild(layer);
		}
	}
 	
 	
 	function resizeImg(Obj, maxw) 
	{
	  var oldWidth = Obj.width;
	  var oldHeight = Obj.height;
	   if (oldWidth > maxw) {
	      var newWidth = maxw;
	      var newHeight = Math.round(oldHeight * newWidth / oldWidth);
	      Obj.wdith = newWidth;
	      Obj.height = newHeight;
	  }
	}

	function assert_msglen(message, maximum)
	{
	    var inc = 0;
	    var nbytes = 0;
	    var msg = "";
	    var msglen = message.length;
	    for (i=0; i<msglen; i++) {
	        var ch = message.charAt(i);
	        if (escape(ch).length > 4) {
	            inc = 2;
	        } else if (ch != '\r') {
	            inc = 1;
	        }
	        if ((nbytes + inc) > maximum) {
	            break;
	        }
	        nbytes += inc;
	        msg += ch;
	    }
	    return msg;
	}
	function calculate_msglen(message)
	{
	    var nbytes = 0;
	    for (i=0; i<message.length; i++) {
	        var ch = message.charAt(i);
	        if (escape(ch).length > 4) {
	            nbytes += 2;
	        } else if (ch != '\r') {
	            nbytes++;
	        }
	    }
	    return nbytes;
	}

	function f_resize(){
		var imgObj = document.getElementsByTagName("img");
		var width = imgObj.mainImg.width;
		var height = imgObj.mainImg.height;

	  var swidth = screen.width - 200;
	  var sheight = screen.height - 200;
	
	  if (height >= sheight){
	     height = height - (height - sheight);
	  }
	  if (width >= swidth){
	     width = width - (width - swidth);
	  }
	  window.resizeTo(width+27, height+30);
	}
