﻿// JScript 파일
function DeleteFileConfirm(nfilename)
{
  if (!confirm("Are you sure to remove \'" + nfilename + "\'"))
  {
    return;
  }
  else
  {  
    location.href='webFTPdelete.aspx?code=' + URLEncode(nfilename);
  }  
}
function clearField(nfield)
{
  getObject(nfield).value = '';
}
function fileselected(nfield, nname)
{
  opener.getObject(nfield).value = nname;
  window.close();
}
function openPolicy(type)
{
  var winurl;
  
  if (type == "return")
    winurl = "/return2.htm";
  else
    winurl = "/termcondition2.htm";
    
	newwins = window.open(winurl,"policy","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=500");
	newwins.focus();
}
function searchSubmit()
{
  if (getObject("boxSearch").value == "" || getObject("boxSearch").value == "Product Search") {
    alert("Enter Search Value");
    return;
  }
  
  getObject("svalue").value = getObject("boxSearch").value;
  getObject("ctseq").value = getObject("boxCategory").value;
  
  getObject("searchForm").submit();  
    
}
function newWindow(winurl, winname)
{
	newwins = window.open(winurl,winname,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=50,height=50");
	newwins.focus();
}	
function getObject(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4. 
  // 
  if(document.getElementById && document.getElementById(objectId)) { 
    return document.getElementById(objectId); 
  } 
  else if (document.all && document.all(objectId)) { 
    return document.all(objectId); 
  } 
  else if (document.layers && document.layers[objectId]) { 
    return document.layers[objectId]; 
  }
  else {
    return false; 
  } 
}

function changeMenuImg(nid, nimg)
{
  getObject(nid).src = nimg;
}

function changeMenuOther(nid)
{
  if (nid == 1)
  {
    getObject("menuTraining").src = "/images/menu_t_training2.gif";
    getObject("menuConsumer").src = "/images/menu_t_consumer.gif";
    getObject("menuPlastic").src = "/images/menu_t_medical.gif";
    getObject("menuSterilization").src = "/images/menu_t_sterilization.gif";
  }
  else if (nid == 2)
  {
    getObject("menuTraining").src = "/images/menu_t_training.gif";
    getObject("menuConsumer").src = "/images/menu_t_consumer2.gif";
    getObject("menuPlastic").src = "/images/menu_t_medical.gif";
    getObject("menuSterilization").src = "/images/menu_t_sterilization.gif";
  }
  else if (nid == 3)
  {
    getObject("menuTraining").src = "/images/menu_t_training.gif";
    getObject("menuConsumer").src = "/images/menu_t_consumer.gif";
    getObject("menuPlastic").src = "/images/menu_t_medical2.gif";
    getObject("menuSterilization").src = "/images/menu_t_sterilization.gif";
  }
  else if (nid == 4)
  {
    getObject("menuTraining").src = "/images/menu_t_training.gif";
    getObject("menuConsumer").src = "/images/menu_t_consumer.gif";
    getObject("menuPlastic").src = "/images/menu_t_medical.gif";
    getObject("menuSterilization").src = "/images/menu_t_sterilization2.gif";
  }
}

function showLayer(nid)
{
  if (nid == 1)
  {
    getObject("subMenu1").style.display = "";
    getObject("subMenu2").style.display = "none";
    getObject("subMenu3").style.display = "none";
    getObject("subMenu4").style.display = "none";
  }
  else if (nid == 2)
  {
    getObject("subMenu1").style.display = "none";
    getObject("subMenu2").style.display = "";
    getObject("subMenu3").style.display = "none";
    getObject("subMenu4").style.display = "none";
  }
  else if (nid == 3)
  {
    getObject("subMenu1").style.display = "none";
    getObject("subMenu2").style.display = "none";
    getObject("subMenu3").style.display = "";
    getObject("subMenu4").style.display = "none";
  }
  else if (nid == 4)
  {
    getObject("subMenu1").style.display = "none";
    getObject("subMenu2").style.display = "none";
    getObject("subMenu3").style.display = "none";
    getObject("subMenu4").style.display = "";
  }
}

//onmouseover="changeMenuImg('menuTraining', '/images/menu_t_training2.gif'); showLayer('smenuTraining')
function load() {
		if (GBrowserIsCompatible()) {        
			var map = new GMap2(document.getElementById("map"));
			map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
			var geocoder = new GClientGeocoder();
			var pcode = 'L4W 5A1';
			var address = '5155 Spectrum Way, # 24<br />Mississauga, ON';
			
			//if there is poing
			var tmppoint1 = '';
			var tmppoint2 = '';
			
			if (tmppoint1 != '' && tmppoint2 != '')
			{
				var point2 = new GLatLng(tmppoint1, tmppoint2);
				
				map.setCenter(point2, 15);          
				var marker = new GMarker(point2);
						
				//add marker
				map.addOverlay(marker);
				
				
				//when click market detail window show
				GEvent.addListener(
					marker, 
					"click", 
					function() { 
						marker.openInfoWindowHtml("<div style='font-family:verdana; font-size:13px; color:#666666; padding:7px; padding-left:16px;'>" + address + "</div>");  
					}
				 );
			}
			else
			{        
				geocoder.getLatLng(
					pcode,
					function(point) {
					if (!point) {
						alert(address + " not found");
					} else {
						map.setCenter(point, 13);
						var marker = new GMarker(point);
						
						//add marker
						map.addOverlay(marker);
						
						
						//when click market detail window show
						GEvent.addListener(
							marker, 
							"click", 
							function() { 
								marker.openInfoWindowHtml("<div style='font-family:verdana; font-size:13px; color:#666666; padding-top:10px; padding-left:20px; text-align:left;'>" + address + "</div>");  
							}
						 );
						
						//marker.openInfoWindowHtml("<div style='font-family:verdana; font-size:13px; color:#666666; padding-top:10px; padding-left:20px;'>" + address + "</div>");
					}
				});
			 }
		}
	}
function OnClickImage(target_img)
{
	var newImg;
	var newOnclickImgSrc;
	var maxWidth = 500;

	newImg = new Image();
	newImg.src = target_img.src;
	imgw = newImg.width;

	newOnclickImgSrc = newImg.src;
	window.open(newOnclickImgSrc,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=400');
	
}
function resizes(target_img, ntype)
{
  var newX, newY;
  var newHeight, newWidth;
  var newImg, newStyle;
  
  var maxWidth, maxHeight;
  if (ntype == 1)
  {
    maxWidth = 120;
    maxHeight = 120;
  }
  else
  {
    maxWidth = 100;
    maxHeight = 100;
  }

  newImg = new Image();
  newImg.src = target_img.src;
  imgw = newImg.width;
  imgh = newImg.height;

  if (imgw > maxWidth) {
    newWidth = maxWidth;
    newHeight = Math.round((imgh*newWidth)/imgw);
  } else {
    newWidth = imgw;
    newHeight = imgh;
  }
	
  if (newHeight > maxHeight) {
    newHeight = maxHeight;
    newWidth = Math.round((newWidth*newHeight)/newHeight);
  } else {
    newWidth = newWidth
    newHeight = newHeight
  }
  
  if (newHeight > 0 && newWidth > 0)
  {
    target_img.onload = null;
    target_img.src = newImg.src;
    target_img.width = newWidth;
    target_img.height = newHeight;
  }
}

function resize(target_img)
{
  var newX, newY;
  var newHeight, newWidth;
  var newImg, newStyle;
  var maxWidth = 460;

  newImg = new Image();
  newImg.src = target_img.src;
  imgw = newImg.width;
  imgh = newImg.height;

  if (imgw > maxWidth) {
    newWidth = maxWidth;
    newHeight = Math.round((imgh*newWidth)/imgw);
  } else {
    newWidth = imgw;
    newHeight = imgh;
  }

  target_img.onload = null;
  target_img.src = newImg.src;
  target_img.width = newWidth;
  target_img.height = newHeight;
}

function OnClickImage(target_img)
{
  var newImg;
  var newOnclickImgSrc;
  var maxWidth = 500;

  newImg = new Image();
  newImg.src = target_img.src;
  imgw = newImg.width;

  newOnclickImgSrc = newImg.src;
  window.open(newOnclickImgSrc,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=800');
	
}
function URLEncode(str)
  {
	  // The Javascript escape and unescape functions do not correspond
	  // with what browsers actually do...
	  var SAFECHARS = "0123456789" +					// Numeric
					  "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					  "abcdefghijklmnopqrstuvwxyz" +
					  "-_.!~*'()";					// RFC2396 Mark characters
	  var HEX = "0123456789ABCDEF";

	  var plaintext = str;
	  var encoded = "";
	  for (var i = 0; i < plaintext.length; i++ ) {
		  var ch = plaintext.charAt(i);
	      if (ch == " ") {
		      encoded += "+";				// x-www-urlencoded, rather than %20
		  } else if (SAFECHARS.indexOf(ch) != -1) {
		      encoded += ch;
		  } else {
		      var charCode = ch.charCodeAt(0);
			  if (charCode > 255) {
			      alert( "Unicode Character '" 
                          + ch 
                          + "' cannot be encoded using standard URL encoding.\n" +
				            "(URL encoding only supports 8-bit characters.)\n" +
						    "A space (+) will be substituted." );
				  encoded += "+";
			  } else {
				  encoded += "%";
				  encoded += HEX.charAt((charCode >> 4) & 0xF);
				  encoded += HEX.charAt(charCode & 0xF);
			  }
		  }
	  } // for

	  return encoded;
  }
  function clearImage(fieldid)
  {
    document.getElementById(fieldid).value = '';
  }
  
  function openWebFTP(viewtype, targetfield)
  {    
    newwins = window.open("/admin/selectFile.aspx?type=" + viewtype + "&f1=" + targetfield, "webFTP","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=760,height=600");
    newwins.focus();  
  }