﻿var subHelp;

function OpenHelp(context, topic) {

	var str;
	if((context=='')&&(topic==''))
		str = '';
	else
		str = '?context='+context+'&topic='+topic;

	if((subHelp == undefined)||(subHelp.closed))
		subHelp = window.open('../Help/Main/index.html'+str, 'helps', 'width=800,height=600, status=no, scrollbars=yes, resizable=yes');
	else
		subHelp.location.href = '../Help/Main/index.html'+str;
}

function openHelpWindow(language,index,winName,features) {
	var theURL = "";
	var path= "../Help/wizard/";

	if (index=="01"){
		switch(language){
			case "en":
				theURL = "h_setupWiz1-Intro_EN.html";
				break;
			case "zh-tw":
				theURL = "h_setupWiz1-Intro_TC.html";
				break;
			case "fr":
				theURL = "h_setupWiz1-Intro_FR.html";
				break;
			case "de":
				theURL = "h_setupWiz1-Intro_DE.html";
				break;
			case "it":
				theURL = "h_setupWiz1-Intro_IT.html";
				break;
		}
	}
	else if(index == "02"){
		switch(language){
			case "en":
				theURL = "h_setupWiz2-ExistingVolumes_EN.html";
				break;
			case "zh-tw":
				theURL = "h_setupWiz2-ExistingVolumes_TC.html";
				break;
			case "fr":
				theURL = "h_setupWiz2-ExistingVolumes_FR.html";
				break;
			case "de":
				theURL = "h_setupWiz2-ExistingVolumes_DE.html";
				break;
			case "it":
				theURL = "h_setupWiz2-ExistingVolumes_IT.html";
				break;
		}
	}
	else if(index == "03"){
		switch(language){
			case "en":
				theURL = "h_setupWiz3-ConfigDiskWiz_EN.html";
				break;
			case "zh-tw":
				theURL = "h_setupWiz3-ConfigDiskWiz_TC.html";
				break;
			case "fr":
				theURL = "h_setupWiz3-ConfigDiskWiz_FR.html";
				break;
			case "de":
				theURL = "h_setupWiz3-ConfigDiskWiz_DE.html";
				break;
			case "it":
				theURL = "h_setupWiz3-ConfigDiskWiz_IT.html";
				break;
		}
	}
	else if(index == "04"){
		switch(language){
			case "en":
				theURL = "h_setupWiz4-SelectDisks_EN.html";
				break;
			case "zh-tw":
				theURL = "h_setupWiz4-SelectDisks_TC.html";
				break;
			case "fr":
				theURL = "h_setupWiz4-SelectDisks_FR.html";
				break;
			case "de":
				theURL = "h_setupWiz4-SelectDisks_DE.html";
				break;
			case "it":
				theURL = "h_setupWiz4-SelectDisks_IT.html";
				break;
		}
	}
	else if(index == "05"){
		switch(language){
			case "en":
				theURL = "h_setupWiz5-RAIDconfig_EN.html";
				break;
			case "zh-tw":
				theURL = "h_setupWiz5-RAIDconfig_TC.html";
				break;
			case "fr":
				theURL = "h_setupWiz5-RAIDconfig_FR.html";
				break;
			case "de":
				theURL = "h_setupWiz5-RAIDconfig_DE.html";
				break;
			case "it":
				theURL = "h_setupWiz5-RAIDconfig_IT.html";
				break;
		}
	}
	else if(index == "06"){
		switch(language){
			case "en":
				theURL = "h_setupWiz6-CreateVol_EN.html";
				break;
			case "zh-tw":
				theURL = "h_setupWiz6-CreateVol_TC.html";
				break;
			case "fr":
				theURL = "h_setupWiz6-CreateVol_FR.html";
				break;
			case "de":
				theURL = "h_setupWiz6-CreateVol_DE.html";
				break;
			case "it":
				theURL = "h_setupWiz6-CreateVol_IT.html";
				break;
		}
	}
	else if(index == "07"){
		switch(language){
			case "en":
				theURL = "h_setupWiz7-Confirm_EN.html";
				break;
			case "zh-tw":
				theURL = "h_setupWiz7-Confirm_TC.html";
				break;
			case "fr":
				theURL = "h_setupWiz7-Confirm_FR.html";
				break;
			case "de":
				theURL = "h_setupWiz7-Confirm_DE.html";
				break;
			case "it":
				theURL = "h_setupWiz7-Confirm_IT.html";
				break;
		}
	}
	else if(index == "08"){
		switch(language){
			case "en":
				theURL = "h_setupWiz8-Execute_EN.html";
				break;
			case "zh-tw":
				theURL = "h_setupWiz8-Execute_TC.html";
				break;
			case "fr":
				theURL = "h_setupWiz8-Execute_FR.html";
				break;
			case "de":
				theURL = "h_setupWiz8-Execute_DE.html";
				break;
			case "it":
				theURL = "h_setupWiz8-Execute_IT.html";
				break;
		}
	}
	else if(index == "09"){
		switch(language){
			case "en":
				theURL = "h_setupWiz9-FTP_EN.html";
				break;
			case "zh-tw":
				theURL = "h_setupWiz9-FTP_TC.html";
				break;
			case "fr":
				theURL = "h_setupWiz9-FTP_FR.html";
				break;
			case "de":
				theURL = "h_setupWiz9-FTP_DE.html";
				break;
			case "it":
				theURL = "h_setupWiz9-FTP_IT.html";
				break;
		}
	}
	else if(index == "10"){
		switch(language){
			case "en":
				theURL = "h_setupWiz10-LogReport_EN.html";
				break;
			case "zh-tw":
				theURL = "h_setupWiz10-LogReport_TC.html";
				break;
			case "fr":
				theURL = "h_setupWiz10-LogReport_FR.html";
				break;
			case "de":
				theURL = "h_setupWiz10-LogReport_DE.html";
				break;
			case "it":
				theURL = "h_setupWiz10-LogReport_IT.html";
				break;
		}
	}
	else if(index == "11"){
		switch(language){
			case "en":
				theURL = "h_setupWiz11-PopulateUsers_EN.html";
				break;
			case "zh-tw":
				theURL = "h_setupWiz11-PopulateUsers_TC.html";
				break;
			case "fr":
				theURL = "h_setupWiz11-PopulateUsers_FR.html";
				break;
			case "de":
				theURL = "h_setupWiz11-PopulateUsers_DE.html";
				break;
			case "it":
				theURL = "h_setupWiz11-PopulateUsers_IT.html";
				break;
		}
	}
	else if(index == "12"){
		switch(language){
			case "en":
				theURL = "h_setupWiz12-LocalUsers_EN.html";
				break;
			case "zh-tw":
				theURL = "h_setupWiz12-LocalUsers_TC.html";
				break;
			case "fr":
				theURL = "h_setupWiz12-LocalUsers_FR.html";
				break;
			case "de":
				theURL = "h_setupWiz12-LocalUsers_DE.html";
				break;
			case "it":
				theURL = "h_setupWiz12-LocalUsers_IT.html";
				break;
		}
	}
	else if(index == "13"){
		switch(language){
			case "en":
				theURL = "h_setupWiz13-DomainUsers_EN.html";
				break;
			case "zh-tw":
				theURL = "h_setupWiz13-DomainUsers_TC.html";
				break;
			case "fr":
				theURL = "h_setupWiz13-DomainUsers_FR.html";
				break;
			case "de":
				theURL = "h_setupWiz13-DomainUsers_DE.html";
				break;
			case "it":
				theURL = "h_setupWiz13-DomainUsers_IT.html";
				break;
		}
	}
	else if(index == "14"){
		switch(language){
			case "en":
				theURL = "h_setupWiz14-DateTime_EN.html";
				break;
			case "zh-tw":
				theURL = "h_setupWiz14-DateTime_TC.html";
				break;
			case "fr":
				theURL = "h_setupWiz14-DateTime_FR.html";
				break;
			case "de":
				theURL = "h_setupWiz14-DateTime_DE.html";
				break;
			case "it":
				theURL = "h_setupWiz14-DateTime_IT.html";
				break;
		}
	}
	else if(index == "15"){
		switch(language){
			case "en":
				theURL = "h_setupWiz15-CopyButton_EN.html";
				break;
			case "zh-tw":
				theURL = "h_setupWiz15-CopyButton_TC.html";
				break;
			case "fr":
				theURL = "h_setupWiz15-CopyButton_FR.html";
				break;
			case "de":
				theURL = "h_setupWiz15-CopyButton_DE.html";
				break;
			case "it":
				theURL = "h_setupWiz15-CopyButton_IT.html";
				break;
		}
	}
	else if(index == "16"){
		switch(language){
			case "en":
				theURL = "h_setupWiz16-Network_EN.html";
				break;
			case "zh-tw":
				theURL = "h_setupWiz16-Network_TC.html";
				break;
			case "fr":
				theURL = "h_setupWiz16-Network_FR.html";
				break;
			case "de":
				theURL = "h_setupWiz16-Network_DE.html";
				break;
			case "it":
				theURL = "h_setupWiz16-Network_IT.html";
				break;
		}
	}
	else if(index == "17"){
		switch(language){
			case "en":
				theURL = "h_setupWiz17-Finish_EN.html";
				break;
			case "zh-tw":
				theURL = "h_setupWiz17-Finish_TC.html";
				break;
			case "fr":
				theURL = "h_setupWiz17-Finish_FR.html";
				break;
			case "de":
				theURL = "h_setupWiz17-Finish_DE.html";
				break;
			case "it":
				theURL = "h_setupWiz17-Finish_IT.html";
				break;
		}
	}

	window.open(path+theURL,winName,features);
}

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_showHideLayers() { //v6.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; }
}

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();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function MM_goToURL() { //v3.0
	var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
	for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function convertKB( size ){
	return convertBytes( size, 'KB' );
}

function convertBytes( size, unit, toUnit ) {
  var precision = 2;
  var byteTable = {
        "Byte": 1,
        "Bytes": 1,
        "KB": 1024,
        "MB": 1024 * 1024,
        "GB": 1024 * 1024 * 1024,
        "TB": 1024 * 1024 * 1024 * 1024,
        "PB": 1024 * 1024 * 1024 * 1024 * 1024,
        "EB": 1024 * 1024 * 1024 * 1024 * 1024 * 1024 ,
        "ZB": 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 ,
        "YB": 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024
  };
  	//convert unit to bytes, if undefined, assume size is bytes
  if( typeof unit != "undefined" ) {
			 //convert existing unit to bytes
			 size = size * byteTable[unit];
	}

	if (typeof toUnit == "undefined") {
		//convert to human readable format (number between 0 and 1024 with appropriate unit)
		for ( byteUnit in byteTable ) {
				cnvUnitSize = size / byteTable[byteUnit];
				if(  cnvUnitSize <= 1024 ) {
					return cnvUnitSize.toFixed( precision ) + ' '+ byteUnit;
				}
			}
			//unable to convert in using the table
			return null;
		}

	else if( typeof byteTable[toUnit] != "undefined" && typeof byteTable[unit] != "undefined"){
		var cnvUnitSize = size / byteTable[toUnit];
		return cnvUnitSize.toFixed( precision ) + ' '+ toUnit;
	}
	else{
		//unable to find units in the byteTable, did you use uppercase?
		return null;
	}
}
function getLargestUnit(units/*Array*/){
	var byteTable = {
        "Byte": 1,
        "Bytes": 1,
        "KB": 1024,
        "MB": 1024 * 1024,
        "GB": 1024 * 1024 * 1024,
        "TB": 1024 * 1024 * 1024 * 1024,
        "PB": 1024 * 1024 * 1024 * 1024 * 1024,
        "EB": 1024 * 1024 * 1024 * 1024 * 1024 * 1024 ,
        "ZB": 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 ,
        "YB": 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024
  };
  if(units.length  > 0){
	  var largestUnit = units[0];
	  var largestInBytes = byteTable[units[0]];
	  for(var i in units){
	  	if( byteTable[units[i]] > largestInBytes){
	  		largestUnit = units[i];
	  		largestInBytes = byteTable[units[i]];
	  	}
	  }
	  return largestUnit;
	}
	else{
		return null;
	}
}
function unicode_byteleng(string) {
	string = string.replace(/\r\n/g,"\n");
	var utftext = "";

	for (var n = 0; n < string.length; n++) {

		var c = string.charCodeAt(n);

		if (c < 128) {
			utftext += String.fromCharCode(c);
		}
		else if((c > 127) && (c < 2048)) {
			utftext += String.fromCharCode((c >> 6) | 192);
			utftext += String.fromCharCode((c & 63) | 128);
		}
		else {
			utftext += String.fromCharCode((c >> 12) | 224);
			utftext += String.fromCharCode(((c >> 6) & 63) | 128);
			utftext += String.fromCharCode((c & 63) | 128);
		}
	}

	return utftext.length;
}


