
AzurePlatformFirstPage.prototype._AutomaticAzureName_ = function()
{
	var Table = $("#Main_Center-Content").find(".Body").eq(0).find(".Table").eq(0);
	var Index = 1;
	var object = jQuery.parseJSON(JSON.stringify(Global_AzurePlatform));
	var number = Object.keys(object);
	var Name, NameArray=new Array();
	for(var i=0; i<number.length; i++)
	{
		NameArray.push(object[number[i]]["Name"]);
	}
	while(true)
	{
		Name = "Name"+Index;
		if(NameArray.indexOf(Name) == -1)
		{
			break;
		}
		Index++;
	}
	Table.find(".Row").eq(1).find(".Text").val(Name);
}

AzurePlatformFirstPage.prototype._BuildAzurePlatformObject_ = function(that)
{
	var number = Object.keys(Global_AzurePlatform);
	if(number.length == 0)
	{
		number=1;
	}
	else if(number.length>0)
	{
		number = Math.max.apply(null,number)+1;
	}
	if(typeof(Global_AzurePlatform[number]) == "undefined")
	{
		Global_AzurePlatform[number] = new Object();
		Global_AzurePlatform[number]["Name"] = $(that).closest(".Row").find(".Column").eq(2).find(".Text").val();
		Global_AzurePlatform[number]["SasToken"] = "HostName=;DeviceId=;SharedAccessSignature=";
		Global_AzurePlatform[number]["CaCertFile"] = "";
		Global_AzurePlatform[number]["Keepalive"] = 60;
		Global_AzurePlatform[number]["ScanRate"] = 1000;
		Global_AzurePlatform[number]["DeadBand"] = 0;
		Global_AzurePlatform[number]["CdsEnabled"] = false;
		Global_AzurePlatform[number]["CompanyId"] = 0;
		Global_AzurePlatform[number]["EquipmentId"] = "";
		Global_AzurePlatform[number]["MessageId"] = 0;
	}
}

AzurePlatformFirstPage.prototype._ShowTable_ = function(number, DisplayNumber)
{
	$("#AzureTable").find(".DynamicRow").remove();
	var html = $(".Dynamic").html();
	var PageNumber = $("#Toolbar").find(".Text").val();
	var Start = (PageNumber-1)*DisplayNumber;
	if((number.length-Start)>DisplayNumber){
		var End = Start + DisplayNumber;
	}
	else{
		var End = number.length;
	}
	var index = 0;
	for(var i=Start; i<End && End!=0; i++)
	{
		$("#AzureTable").append(html);
		$("#AzureTable").find(".DynamicRow").eq(index).find(".Column").eq(0).text(number[i]);
		$("#AzureTable").find(".DynamicRow").eq(index).find(".Column").eq(2).text(Global_AzurePlatform[number[i]]["Name"]);
		index++;
	}
}

AzurePlatformFirstPage.prototype._UpdateTableToolbar_ = function(number, DisplayNumber)
{
	var NumberOfPages = Math.ceil(number.length/DisplayNumber);
	var Id = "#Toolbar";
	$(Id).find("label").eq(1).text(NumberOfPages);
	var CurrentlyPage = $(Id).find(".Text").val();
	CurrentlyPage = parseInt(CurrentlyPage);
	if(CurrentlyPage>NumberOfPages)
	{
		$(Id).find(".Text").val(NumberOfPages);
	}
	else if(CurrentlyPage<=0 || isNaN(CurrentlyPage)==true)
	{
		$(Id).find(".Text").val(1);
	}
	else
	{
		$(Id).find(".Text").val(CurrentlyPage);
	}
}

AzurePlatformFirstPage.prototype._RedisplayUi_ = function()
{
	var DisplayNumber = 10;//RTU 20 TCP 40 ASCII 20
	var number = Object.keys(Global_AzurePlatform);
	AzurePlatformFirstPage.prototype._UpdateTableToolbar_(number, DisplayNumber);
	AzurePlatformFirstPage.prototype._ShowTable_(number, DisplayNumber);
	var Id = "#AzureTable";
	$(Id).find(".Row").eq(0).find(":checkbox").prop("checked",false);
}

AzurePlatformFirstPage.prototype._AddNewRow_ = function(that)
{
	AzurePlatformFirstPage.prototype._CheckAzureName_();
	var Id = "#AzureTable";
	var ShowErrorMessage = $(Id).find(".Row").eq(0).find(".Message").is(":visible");
	if(ShowErrorMessage == true)	{return 0;}
	AzurePlatformFirstPage.prototype._BuildAzurePlatformObject_(that);
	AzurePlatformFirstPage.prototype._RedisplayUi_();
	AzurePlatformFirstPage.prototype._AutomaticAzureName_();
}

AzurePlatformFirstPage.prototype._ShowPreviousPage_ = function()
{
	var Id = "#Toolbar";
	var CurrentlyPage = $(Id).find(".Text").val();
	$(Id).find(".Text").val(parseInt(CurrentlyPage)-1);
	AzurePlatformFirstPage.prototype._RedisplayUi_();
}

AzurePlatformFirstPage.prototype._ShowNextPage_ = function()
{
	var Id = "#Toolbar";
	var CurrentlyPage = $(Id).find(".Text").val();
	$(Id).find(".Text").val(parseInt(CurrentlyPage)+1);
	AzurePlatformFirstPage.prototype._RedisplayUi_();
}

AzurePlatformFirstPage.prototype._RemoveRtuToMqttJsonGroupName_ = function(AzureName)
{
	AzureName=AzureName+" (Azure)";
	var object = jQuery.parseJSON(JSON.stringify(Global_RtuToMqttJsonVariable));
	var number=Object.keys(object);
	for(var i=0; i<number.length; i++)
	{
		var Variable = Object.keys(object[number[i]]);
		for(var j=0; j<Variable.length; j++)
		{
			if(AzureName == object[number[i]][Variable[j]]["ConnectionGroup"])
			{
				Global_RtuToMqttJsonVariable[number[i]][Variable[j]]["ConnectionGroup"] = "";
			}
		}
	}
}

AzurePlatformFirstPage.prototype._RemoveTcpToMqttJsonGroupName_ = function(AzureName)
{
	AzureName=AzureName+" (Azure)";
	var object = jQuery.parseJSON(JSON.stringify(Global_TcpToMqttJsonVariable));
	var number=Object.keys(object);
	for(var i=0; i<number.length; i++)
	{
		var Variable = Object.keys(object[number[i]]);
		for(var j=0; j<Variable.length; j++)
		{
			if(AzureName == object[number[i]][Variable[j]]["ConnectionGroup"])
			{
				Global_TcpToMqttJsonVariable[number[i]][Variable[j]]["ConnectionGroup"] = "";
			}
		}
	}
}

AzurePlatformFirstPage.prototype._RemoveAsciiToMqttJsonGroupName_ = function(AzureName)
{
	AzureName=AzureName+" (Azure)";
	var object = jQuery.parseJSON(JSON.stringify(Global_AsciiToMqttJsonVariable));
	var number=Object.keys(object);
	for(var i=0; i<number.length; i++)
	{
		var Variable = Object.keys(object[number[i]]);
		for(var j=0; j<Variable.length; j++)
		{
			if(AzureName == object[number[i]][Variable[j]]["ConnectionGroup"])
			{
				Global_AsciiToMqttJsonVariable[number[i]][Variable[j]]["ConnectionGroup"] = "";
			}
		}
	}
}

AzurePlatformFirstPage.prototype._RemoveGlobalVariable_ = function(number)
{
	var AzureName = Global_AzurePlatform[number]["Name"];
	Global_AzurePlatform[number] = null;	delete Global_AzurePlatform[number];
	
	AzurePlatformFirstPage.prototype._RemoveRtuToMqttJsonGroupName_(AzureName);
	AzurePlatformFirstPage.prototype._RemoveTcpToMqttJsonGroupName_(AzureName);
	AzurePlatformFirstPage.prototype._RemoveAsciiToMqttJsonGroupName_(AzureName);
}

AzurePlatformFirstPage.prototype._RemoveTickedAzure_ = function()
{
	var Id = "#AzureTable";
	var element = $(Id).find(".DynamicRow").find(":checked");
	var CheckedLength = element.length;
	for(var i=0; i<CheckedLength; i++)
	{
		var number = element.eq(i).closest(".DynamicRow").find(".Column").eq(0).text();
		AzurePlatformFirstPage.prototype._RemoveGlobalVariable_(number);
	}
}

AzurePlatformFirstPage.prototype._DeleteAzure_ = function()
{
	AzurePlatformFirstPage.prototype._RemoveTickedAzure_();
	AzurePlatformFirstPage.prototype._RedisplayUi_();
}

AzurePlatformFirstPage.prototype._IsNameRepeat_ = function(Name)
{
	var Return=false;
	var Row = $("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Row");
	var CurrentlyNumber = Row.eq(0).find(".Text").val();
	var number = Object.keys(Global_AzurePlatform);
	for(var i=0; i<number.length; i++)
	{
		if(Name == Global_AzurePlatform[number[i]]["Name"])
		{
			Return=true;
			break;
		}
	}
	return Return;
}

AzurePlatformFirstPage.prototype._IsTickedAzure_ = function()
{
	var Return=false;
	var Id = "#AzureTable";
	if($(Id).find(".DynamicRow").find(":checked").length >0)
	{
		Return=true;
	}
	return Return;
}

AzurePlatformFirstPage.prototype._Initialization_ = function()
{
	AzurePlatformFirstPage.prototype._RedisplayUi_();
}

AzurePlatformFirstPage.prototype._CheckAzureName_ = function()
{
	var Id = "#AzureTable";
	$(Id).find(".Message").hide();
	var Row=$(Id).find(".Row");
	var Name = Row.eq(1).find(".Text").val();
	var Class = new Type();
	if(Class.EnglishDigitalAndBottomline(Name) == false)
	{
		Row.eq(0).find(".Message").eq(0).show();
	}
	Class = null;
	if(AzurePlatformFirstPage.prototype._IsNameRepeat_(Name) == true)
	{
		Row.eq(0).find(".Message").eq(1).show();
	}
}

AzurePlatformFirstPage.prototype._TransmissionJson_ = function(ssocket, Command, string, Callback)
{
	var Length=20000, index=0;  var array = new Array("Start","");
	ssocket.emit(Command, array);	
	ssocket.on(Command, function (Return) {
		if(Return == "Start" || Return == "Send")
		{
			if(string.length > (index+Length)){
				array = new Array("Send", string.substring(index, index+Length));
			}
			else if(string.length <= (index+Length)){
				array = new Array("End", string.substring(index, string.length));
			}
			index = index + Length;
			ssocket.emit(Command, array);	
		}
		else if(Return == "End")
		{
			Callback();
		}
	});	
}

AzurePlatformFirstPage.prototype._SaveStart_ = function(that, ssocket)
{
	ssocket.emit("BackgroundExecution");
	ssocket.on("BackgroundExecution", function (Return) {
	if(Return == true)
	{
		var array = new Array(Global_AzurePlatform);
		ssocket.emit("SaveAzurePlatformSetting", array);

		var Callback0 = function(){AzurePlatformFirstPage.prototype._SaveFinished_(that, ssocket);}

		var JsonString1 = JSON.stringify(Global_RtuToMqttJsonVariable);
		var Callback1 = function(){AzurePlatformFirstPage.prototype._TransmissionJson_(ssocket, "SaveRtuToMqttJsonVariable", JsonString1, Callback0);}

		var JsonString2 = JSON.stringify(Global_TcpToMqttJsonVariable)
		var Callback2 = function(){AzurePlatformFirstPage.prototype._TransmissionJson_(ssocket, "SaveTcpToMqttJsonVariable", JsonString2, Callback1);}

		var JsonString3 = JSON.stringify(Global_AsciiToMqttJsonVariable);

		$(that).closest('.Row').find(".Message").hide();
		$(that).closest('.Row').find(".Loading").show();
		AzurePlatformFirstPage.prototype._TransmissionJson_(ssocket, "SaveAsciiToMqttJsonVariable", JsonString3, Callback2);
	}
	});
}

AzurePlatformFirstPage.prototype._SaveFinished_ = function(that, ssocket)
{
	$(that).closest('.Row').find(".Loading").hide();
	$(that).closest('.Row').find(".Message").eq(1).show();
	ssocket.emit("SaveFinished");
	ssocket.on("SaveFinished", function (Return) {
		if(Return == true)
		{
			$(that).closest('.Row').find(".Message").hide();
			$(that).closest('.Row').find(".Message").eq(0).show();
		}
		else
		{
			$(that).closest('.Row').find(".Message").hide();
			$(that).closest('.Row').find(".Message").eq(2).show();
		}
		ssocket.emit("SocketClose");
	});
}

AzurePlatformFirstPage.prototype._EditButton_ = function(that)
{
	$("#Main_Center-Content").find(".Body").eq(1).find(".Message").hide();
	var number = $(that).closest(".DynamicRow").find(".Column").eq(0).text();
	$("#Main_Center-Content").find(".Body").eq(0).hide();	
	var Name = $("#Main_Center-Content").find(".Body").eq(1).find(".FormTitle").eq(0).text();
	$("#Main_Center-Content").find(".Body").eq(1).show();
	var Class = new Path();
	Class.LoadPathHtml(Name, 2);
	Class = null;
	AzurePlatformSecondPage.prototype._SetInitialValue_(number);
}

AzurePlatformFirstPage.prototype._SaveButton_ = function(that)
{
	$(that).closest('.Row').find(".Loading").hide();
	$(that).closest('.Row').find(".Message").hide();
	var ssocket = io.connect();
	AzurePlatformFirstPage.prototype._SaveStart_(that, ssocket);
}





















AzurePlatformSecondPage.prototype._CheckAzureName_ = function(that)
{
	$(that).closest(".Row").find(".Message").hide();
	var Name = $(that).closest(".Row").find(".Text").val();
	var Class = new Type();
	if(Class.EnglishDigitalAndBottomline(Name) == false)
	{
		$(that).closest(".Row").find(".Message").eq(0).show();
	}
	Class = null;
	if(AzurePlatformSecondPage.prototype._IsNameRepeat_(Name) == true)
	{
		$(that).closest(".Row").find(".Message").eq(1).show();
	}
}

AzurePlatformSecondPage.prototype._CheckSasToken_ = function(that)
{
	$(that).closest(".Row").find(".Message").hide();
	var Name = $(that).closest(".Row").find(".TextArea").val();
	while(Name.indexOf('\r')!=-1 || Name.indexOf('\n')!=-1)
	{
		Name = Name.replace('\r', "");
		Name = Name.replace('\n', "");
		$(that).closest(".Row").find(".TextArea").val(Name);
	}
	var NameArray = Name.split(";");
	if(!(NameArray[0].indexOf("HostName=")!=-1 &&
		 NameArray[1].indexOf("DeviceId=")!=-1 &&
		 NameArray[2].indexOf("SharedAccessSignature=")!=-1))
	{
		$(that).closest(".Row").find(".Message").show();
		return 0;
	}
}
AzurePlatformSecondPage.prototype._CheckTrustedCertificate_ = function()
{
	var Row = $("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Row");
	Row.eq(3).find(".Message").hide();
	var TrustedCertificate = Row.eq(3).find(".Select").val();
	if(TrustedCertificate == "")
	{
		Row.eq(3).find(".Message").show();
	}
};

AzurePlatformSecondPage.prototype._CheckKeepAlive_ = function(that)
{
	var Name = $(that).closest(".Row").find(".Text").val();
	Name = parseInt(Name);
	$(that).closest(".Row").find(".Text").val(Name);
	var Class = new Type();
	if(Class.CheckPositiveIntegers(Name) == false)
	{
		$(that).closest(".Row").find(".Text").val(60);
	}
	Class = null;
	if(parseInt(Name) < 5)
	{
		$(that).closest(".Row").find(".Text").val(60);
	}
}

AzurePlatformSecondPage.prototype._CheckScanRate_ = function(that)
{
	var ScanRate = $(that).closest(".RightColumn").find(".Text").val();
	var Class = new Type();
	ScanRate = parseInt(ScanRate);
	if(Class.CheckPositiveIntegers(ScanRate) == false)
	{
		$(that).closest(".RightColumn").find(".Text").val(1000);
		return 0;
	}
	if(ScanRate < 100)
	{
		$(that).closest(".RightColumn").find(".Text").val(1000);
		return 0;
	}
	$(that).closest(".RightColumn").find(".Text").val(ScanRate);
}

AzurePlatformSecondPage.prototype._CheckDeadBand_ = function(that)
{
	var DeadBand = $(that).closest(".RightColumn").find(".Text").val();
	var Class = new Type();
	DeadBand = parseFloat(DeadBand);
	if(Class.CheckFloat(DeadBand) == false)
	{
		$(that).closest(".RightColumn").find(".Text").val(0);
		return 0;
	}
	if(DeadBand < 0)
	{
		$(that).closest(".RightColumn").find(".Text").val(0);
		return 0;
	}
	DeadBand = parseFloat(DeadBand.toFixed(4));
	$(that).closest(".RightColumn").find(".Text").val(DeadBand);
}

AzurePlatformSecondPage.prototype._CheckCompanyId_ = function(that)
{
	var CompanyId = $(that).closest(".RightColumn").find(".Text").val();
	CompanyId=parseInt(CompanyId);
	var Class = new Type();
	if(Class.CheckPositiveIntegersAndZero(CompanyId) == false)
	{
		$(that).closest(".RightColumn").find(".Text").val(0);
		return 0;
	}
	if(CompanyId < 0)
	{
		$(that).closest(".RightColumn").find(".Text").val(0);
		return 0;
	}
	$(that).closest(".RightColumn").find(".Text").val(CompanyId);
}

AzurePlatformSecondPage.prototype._CheckEquipmentId_ = function(that)
{
	$(that).closest(".RightColumn").find(".Message").hide();
	var EquipmentId = $(that).closest(".RightColumn").find(".Text").val();
	var Class = new Type();
	if(Class.EnglishDigital(EquipmentId) == false)
	{
		$(that).closest(".RightColumn").find(".Text").val("");
		$(that).closest(".RightColumn").find(".Message").show();
		return 0;
	}
	$(that).closest(".RightColumn").find(".Text").val(EquipmentId);
}

AzurePlatformSecondPage.prototype._CheckMessageId_ = function(that)
{
	$(that).closest(".RightColumn").find(".Message").hide();
	var MessageId = $(that).closest(".RightColumn").find(".Text").val();
	MessageId=parseInt(MessageId);
	var Class = new Type();
	if(Class.CheckPositiveIntegersAndZero(MessageId) == false)
	{
		$(that).closest(".RightColumn").find(".Text").val(0);
		return 0;
	}
	$(that).closest(".RightColumn").find(".Text").val(MessageId);
}

AzurePlatformSecondPage.prototype._ChangeCdsEnabled_ = function(that)
{
	var Bool = $(that).closest(".Row").find(":checkbox").prop("checked");
	var Row = $("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Row");
	if(Bool == true)
	{
		Row.eq(7).show();
		Row.eq(8).show();
		Row.eq(8).find(".RightColumn").find(".Message").show();
		Row.eq(9).show();
	}
	else if(Bool == false)
	{
		Row.eq(7).find(".RightColumn").find(".Text").val(0);
		Row.eq(7).find(".RightColumn").find(".Message").hide();
		Row.eq(7).hide();
		Row.eq(8).find(".RightColumn").find(".Text").val("");
		Row.eq(8).find(".RightColumn").find(".Message").hide();
		Row.eq(8).hide();
		Row.eq(9).hide();
	}
}

AzurePlatformSecondPage.prototype._IsNameRepeat_ = function(Name)
{
	var Return=false;
	var Row = $("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Row");
	var CurrentlyNumber = Row.eq(0).find(".Text").val();
	var number = Object.keys(Global_AzurePlatform);
	for(var i=0; i<number.length; i++)
	{
		if(number[i] == CurrentlyNumber)
		{
			continue;
		}	
		if(Name == Global_AzurePlatform[number[i]]["Name"])
		{
			Return=true;
			break;
		}
	}
	return Return;
}

AzurePlatformSecondPage.prototype._ClearForm_ = function()
{
	var Row = $("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Row");
	Row.eq(0).find(".Text").val("");
	Row.eq(1).find(".Text").val("");
	Row.eq(2).find(".TextArea").val("");
	Row.eq(3).find(".Text").val("");
	$("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Message").hide();
}

AzurePlatformSecondPage.prototype._GetSettingFormValue_ = function()
{
	var Row = $("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Row");
	var number = Row.eq(0).find(".Text").val();
	Global_AzurePlatform[number]["Name"]      = Row.eq(1).find(".Text").val();
	Global_AzurePlatform[number]["SasToken"]  = Row.eq(2).find(".TextArea").val();
	Global_AzurePlatform[number]["CaCertFile"] = Row.eq(3).find(".Select").val();
	Global_AzurePlatform[number]["Keepalive"] = parseInt(Row.eq(4).find(".Text").val());
	Global_AzurePlatform[number]["ScanRate"] = parseInt(Row.eq(5).find(".Text").val());
	Global_AzurePlatform[number]["DeadBand"] = parseFloat(Row.eq(6).find(".Text").val());
	Global_AzurePlatform[number]["CdsEnabled"] = Row.eq(7).find(":checkbox").prop("checked");
	Global_AzurePlatform[number]["CompanyId"] = parseInt(Row.eq(8).find(".Text").val());
	Global_AzurePlatform[number]["EquipmentId"] = Row.eq(9).find(".Text").val();
	Global_AzurePlatform[number]["MessageId"] = parseInt(Row.eq(10).find(".Text").val());
}

AzurePlatformSecondPage.prototype._SetFormInitialValue_ = function(number)
{
	var Name=Global_AzurePlatform[number]["Name"];
	var Row = $("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Row");
	Row.eq(0).find(".Text").val(number);
	Row.eq(1).find(".Text").val(Name);
	Row.eq(2).find(".TextArea").val(Global_AzurePlatform[number]["SasToken"]);
	AzurePlatformSecondPage.prototype._ShowCertificateDropDownMenu_();
	Row.eq(4).find(".Text").val(Global_AzurePlatform[number]["Keepalive"]);
	Row.eq(5).find(".Text").val(Global_AzurePlatform[number]["ScanRate"]);
	Row.eq(6).find(".Text").val(Global_AzurePlatform[number]["DeadBand"]);
	var Bool = Global_AzurePlatform[number]["CdsEnabled"];
	if(Bool==true)
	{
		Row.eq(7).show();	Row.eq(8).show();	Row.eq(9).show();
	}
	else
	{
		Row.eq(7).hide();	Row.eq(8).hide();	Row.eq(9).hide();
	}
	Row.eq(6).find(":checkbox").prop("checked", Bool);
	Row.eq(7).find(".Text").val(Global_AzurePlatform[number]["CompanyId"]);
	Row.eq(8).find(".Text").val(Global_AzurePlatform[number]["EquipmentId"]);
	Row.eq(9).find(".Text").val(Global_AzurePlatform[number]["MessageId"]);
}
AzurePlatformSecondPage.prototype._ShowCertificateDropDownMenu_ = function()
{
	var Result = {"Input":null};
	var Path = "/app/Certificates/MQTT";
	var array = new Array(Path);
	var Class = new Transmission();
	Class.TransmissionArray("MQTTCertificateList", array, Result);
	var SetInterval = setInterval(function()
	{
		if(Result["Input"]!=null)
		{
			Class = null; delete Class;
			clearInterval(SetInterval);
			AzurePlatformSecondPage.prototype._AddCertificateDropDownMenu_(Result["Input"]);
		}
	},500);
}
AzurePlatformSecondPage.prototype._AddCertificateDropDownMenu_ = function(CertificateList)
{
	var Row = $("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Row");
	var number = Row.eq(0).find(".Text").val();
	
	Row.eq(3).find(".Select").find("option").remove();
	for(var j=0;j<CertificateList[0].length;j++)
	{
		Row.eq(3).find(".Select").append($("<option></option>").attr("value",CertificateList[0][j]).text(CertificateList[0][j]));
	}
	Row.eq(3).find(".Select").val(Global_AzurePlatform[number]["CaCertFile"]);
	if(Row.eq(3).find(".Select").val() == null)
	{
		Row.eq(3).find(".Message").show();
	}
	if(Row.eq(3).find(".Select").val() == "")
	{
		Row.eq(3).find(".Message").show();
	}
}
RemoteBrokerSecondPage.prototype._SelectedClearError_ = function(that)
{
	$(that).closest(".Row").find(".Message").hide();
}


AzurePlatformSecondPage.prototype._SetInitialValue_ = function(number)
{
	AzurePlatformSecondPage.prototype._ClearForm_();
	AzurePlatformSecondPage.prototype._SetFormInitialValue_(number);
}

AzurePlatformSecondPage.prototype._ConfirmButton_ = function(that)
{
	var Message = $("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Message");
	for(var i=0; i<Message.length; i++)
	{
		if(Message.eq(i).is(":visible") == true ){
			$(that).closest(".Form").find(".Message").eq(1).show();
			return 0;
		}
	}
	var Row = $("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Row");
	var number = Row.eq(0).find(".Text").val();
	var OldGroupName = Global_AzurePlatform[number]["Name"];
	var NewGroupName = Row.eq(1).find(".Text").val();
	AzurePlatformSecondPage.prototype._ModifyGlobalVariable_(OldGroupName, NewGroupName);
	
	AzurePlatformSecondPage.prototype._GetSettingFormValue_();
	
	$("#Main_Center-Content").find(".Body").eq(1).hide();
	$("#Main_Center-Content").find(".Body").eq(0).show();
	AzurePlatformFirstPage.prototype._RedisplayUi_();
	var Class = new Path();
	Class.LoadPathHtml($("#Left-List-AzurePlatform").text(), 1, "main_PathAzurePlatform_click(this)");
	Class = null;
}

AzurePlatformSecondPage.prototype._NoConfirmButton_ = function()
{
	$("#Main_Center-Content").find(".Body").eq(1).hide();
	$("#Main_Center-Content").find(".Body").eq(0).show();
	var Class = new Path();
	Class.LoadPathHtml($("#Left-List-AzurePlatform").text(), 1, "main_PathAzurePlatform_click(this)");
	Class = null;
}

AzurePlatformSecondPage.prototype._ModifyGlobalVariable_ = function(OldGroupName, NewGroupName)
{
	AzurePlatformSecondPage.prototype._ModifyRtuToMqttJsonGroupName_(OldGroupName, NewGroupName);
	AzurePlatformSecondPage.prototype._ModifyTcpToMqttJsonGroupName_(OldGroupName, NewGroupName);
	AzurePlatformSecondPage.prototype._ModifyAsciiToMqttJsonGroupName_(OldGroupName, NewGroupName);
}

AzurePlatformSecondPage.prototype._ModifyRtuToMqttJsonGroupName_ = function(OldAzureName, NewAzureName)
{
	OldAzureName = OldAzureName+" (Azure)";
	NewAzureName = NewAzureName+" (Azure)";
	var object = jQuery.parseJSON(JSON.stringify(Global_RtuToMqttJsonVariable));
	var number=Object.keys(object);
	for(var i=0; i<number.length; i++)
	{
		var Variable = Object.keys(object[number[i]]);
		for(var j=0; j<Variable.length; j++)
		{
			if(OldAzureName == object[number[i]][Variable[j]]["ConnectionGroup"])
			{
				Global_RtuToMqttJsonVariable[number[i]][Variable[j]]["ConnectionGroup"] = NewAzureName;
			}
		}
	}
}

AzurePlatformSecondPage.prototype._ModifyTcpToMqttJsonGroupName_ = function(OldAzureName, NewAzureName)
{
	OldAzureName = OldAzureName+" (Azure)";
	NewAzureName = NewAzureName+" (Azure)";
	var object = jQuery.parseJSON(JSON.stringify(Global_TcpToMqttJsonVariable));
	var number=Object.keys(object);
	for(var i=0; i<number.length; i++)
	{
		var Variable = Object.keys(object[number[i]]);
		for(var j=0; j<Variable.length; j++)
		{
			if(OldAzureName == object[number[i]][Variable[j]]["ConnectionGroup"])
			{
				Global_TcpToMqttJsonVariable[number[i]][Variable[j]]["ConnectionGroup"] = NewAzureName;
			}
		}
	}
}

AzurePlatformSecondPage.prototype._ModifyAsciiToMqttJsonGroupName_ = function(OldAzureName, NewAzureName)
{
	OldAzureName = OldAzureName+" (Azure)";
	NewAzureName = NewAzureName+" (Azure)";
	var object = jQuery.parseJSON(JSON.stringify(Global_AsciiToMqttJsonVariable));
	var number=Object.keys(object);
	for(var i=0; i<number.length; i++)
	{
		var Variable = Object.keys(object[number[i]]);
		for(var j=0; j<Variable.length; j++)
		{
			if(OldAzureName == object[number[i]][Variable[j]]["ConnectionGroup"])
			{
				Global_AsciiToMqttJsonVariable[number[i]][Variable[j]]["ConnectionGroup"] = NewAzureName;
			}
		}
	}
}

// 遠端Azure 一般設定
RemoteBrokerSecondPage.prototype._AzurePlatformGeneralSetting_ = function()
{
	var AllDivButtonName = $("#Main_Center-Content").find(".Body").eq(1).find(".FormTitle");
	AllDivButtonName.css("border-right-color", "#FFFFFF");
	AllDivButtonName.css("border-left-color", "#FFFFFF");
	AllDivButtonName.css("border-top-color", "#FFFFFF");
	AllDivButtonName.css("background-color", "#FFFFFF");
	var DivButtonName = $("#Main_Center-Content").find(".Body").eq(1).find(".FormTitle").eq(0);
	DivButtonName.css("border-right-color", "#395d8b");
	DivButtonName.css("border-left-color", "#395d8b");
	DivButtonName.css("border-top-color", "#395d8b");
	DivButtonName.css("background-color", "#E5F1FF");
	$("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).show();
	$("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(1).show();
	$("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(2).hide();
}

// 遠端Azure 憑證設定
RemoteBrokerSecondPage.prototype._AzurePlatformCertificateSetting_ = function()
{
	var AllDivButtonName = $("#Main_Center-Content").find(".Body").eq(1).find(".FormTitle");
	AllDivButtonName.css("border-right-color", "#FFFFFF");
	AllDivButtonName.css("border-left-color", "#FFFFFF");
	AllDivButtonName.css("border-top-color", "#FFFFFF");
	AllDivButtonName.css("background-color", "#FFFFFF");
	
	var DivButtonName = $("#Main_Center-Content").find(".Body").eq(1).find(".FormTitle").eq(1);
	DivButtonName.css("border-right-color", "#395d8b");
	DivButtonName.css("border-left-color", "#395d8b");
	DivButtonName.css("border-top-color", "#395d8b");
	DivButtonName.css("background-color", "#E5F1FF");
	$("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).hide();
	$("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(1).hide();
	$("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(2).show();
}