var LinkApprove = "";
var CompanyIdVP = "";
var CompanyNameVP = "";
var IsASCIIvp = "";

function ShowConfirmation(Type)
{
	//Get span object it's rendered or not
	var sSubmit = document.getElementById("ssubmit");
	//Span not yet rendered
	if(sSubmit == null)
	{		
		setTimeout("ShowConfirmation('" + Type + "');", 300);
	}
	//span rendered
	else if(sSubmit != null)
	{
		RenderConfirmation(Type);
	}
	
}

//Set company id and Company Name for sending email and company id used for save to database, IsASCII to Show ASCII logo, if that company is ASCII member
function SetCompanyId(CompanyId, CompanyName, IsASCII)
{
	CompanyIdVP = CompanyId;
	CompanyNameVP = CompanyName;
	IsASCIIvp = IsASCII;
}

//Linl to approve company
function LinkApproved(CompanyId, CompanyName)
{
	LinkApprove = "<span id=\"sLinkApproved\">Click <a href=\"javascript:CompanyApproved('" + CompanyId + "', '" + CompanyName + "', 'VP')\">here</a> to approve this company</span>";
}

function RenderConfirmation(Type)
{	
	//Content View Profile
	var ContentVP = "";
	
	//Get all value on all input hidden
	var hAccountSetup = document.getElementById("hAccountSetup");
	var hCompany = document.getElementById("hCompany");
	var hLanguageSupport = document.getElementById("hLanguageSupport");
	var hCompanyProfile = document.getElementById("hCompanyProfile");
	var hPrimaryContact = document.getElementById("hPrimaryContact");
	var hServiceArea = document.getElementById("hServiceArea");
	var hIndustry = document.getElementById("hIndustry");
	var hServiceVar = document.getElementById("hServiceVar");
	var hPartnerships = document.getElementById("hPartnerships");	
	
	var linkEditCompany = "<span id=\"sEdit2\" class=\"sEditW\">&nbsp;</span>";
	var linkEditCompanyProfile = "<span id=\"sEdit3\" class=\"sEditW\">&nbsp;</span>";
	var linkEditAccountInfo= "<span id=\"sEdit1\" class=\"sEditW\">&nbsp;</span>";
	var linkEditPartnerships = "<span id=\"sEdit1\" class=\"sEditW\">&nbsp;</span>";
	var linkEditServiceArea = "<span id=\"sEdit5\" class=\"sEditW\">&nbsp;</span>";
	var linkEditContactInformation = "<span id=\"sEdit4\" class=\"sEditW\">&nbsp;</span>";
	
	//Show Edit link on confirmation if confirmation called from Register Page, after admin login or user login
	if(Type == "register" || Type == "admin" || Type == "user")
	{
		linkEditCompany = "<span id=\"sEdit2\" onclick=\"EditConfirmation(this.id)\" class=\"sEditB\">Edit</span>";		
		linkEditCompanyProfile = "<span id=\"sEdit3\" onclick=\"EditConfirmation(this.id)\" class=\"sEditB\">Edit</span>";		
		linkEditAccountInfo = "<span id=\"sEdit1\" onclick=\"EditConfirmation(this.id)\" class=\"sEditB\">Edit</span>";		
		linkEditPartnerships = "<span id=\"sEdit6\" onclick=\"EditConfirmation(this.id)\" class=\"sEditB\">Edit</span>";		
		linkEditServiceArea = "<span id=\"sEdit5\" onclick=\"EditConfirmation(this.id)\" class=\"sEditB\">Edit</span>";
		linkEditContactInformation = "<span id=\"sEdit4\" onclick=\"EditConfirmation(this.id)\" class=\"sEditB\">Edit</span>";
	}
	
	//========================================================================================================================================================================
	//================================================================ Google Map =============================================================================================
	var Location = "";
	
	//Company Location is Approximate Location
	if(IsApproximate == "1")	
		Location = "Approximate Location";	
	else
		Location = "Location";
	
	var ASCIIGMap = "<div id=\"ASCIIGMap\" style=\"width:200px;height:163px;border:1px solid #CCCCCC;\"></div>";
	
	//========================================================================================================================================================================
	//================================================================== Company Detail ========================================================================================	
	
	var CompanyName = "";
	var CompanyHours = "";
	var CompanyContact = "";
	var CompanyLanguage = "";

	var Latitude = "";
	var Longitude = "";
	var IsASCII = "";
	var IsApproximate = "";	
	
	var Phone = "";
	var TollFree = "";
	var Fax = "";
	var sPrimaryContact = "";
	var ContactName = "";
	var PhotoPath = "";
	var LinkNextPrevious = "";
	
	if(hPrimaryContact.value != "" && hPrimaryContact.value != null)
	{
		sPrimaryContact = hPrimaryContact.value.split("#");
		ContactName = DecodeTag(sPrimaryContact[0]) + " " + DecodeTag(sPrimaryContact[1]);
		
		Phone = DecodeTag(sPrimaryContact[2]);
		Fax = DecodeTag(sPrimaryContact[3]);
		TollFree = DecodeTag(sPrimaryContact[4]);
		
		//There is A photo uploaded
		if(sPrimaryContact[6] != "" && sPrimaryContact[6] != "" && sPrimaryContact[6].length > 0)
		{	
			var AllPhotoPath = sPrimaryContact[6].split(",");				
			PhotoPath = AllPhotoPath[0];
			
			//Photo more than 1 than show Link next and Previous
			if(AllPhotoPath.length != 1)
				LinkNextPrevious = "<a href=\"javascript:PreviousPhoto();\" title=\"Previous\"><<</a>&nbsp;&nbsp;&nbsp;" +
							     "<a href=\"javascript:NextPhoto();\" title=\"Next\">>></a>";
		}
	}
	
	if(hCompany.value != "" && hCompany.value != null)
	{
		var vCompany = hCompany.value.split("#");
		var Country = vCompany[6].split(",");
		var State = vCompany[4].split(",");
		var StartOperations = vCompany[8].split(",");
		var EndOperations = vCompany[9].split(",");
		var TimeZoneIndex = vCompany[10].split(",");
		
		var vAddress2 = "";
		//Check address 2
		if(vCompany[2] != "")
			vAddress2 = DecodeTag(vCompany[2]) + "<br/>"; //Address2
			
		var Website = 	DecodeTag(vCompany[7]);
		
		if(Website.length > 20)
			Website = Website.substring(0, 21) + "...";
			
		var strCompanyName = DecodeTag(vCompany[0]);
		var strCompanyName2 = strCompanyName;
		
		if(strCompanyName.length > 20) {
			strCompanyName2 = strCompanyName.substring(0, 21);
			strCompanyName2 += "<br/>" + strCompanyName.substring(21, 50);
		}
			
		CompanyName = "<div id=\"CompanyName\" class=\"CompanyDetailLeft\">" +
						//~ "<b>" + DecodeTag(vCompany[0]) + "</b><br/>" +  //Company Name
						"<b>" + strCompanyName2 + "</b><br/>" +  //Company Name
						DecodeTag(vCompany[1]) + "<br/>" + vAddress2 + //Address1 and Address2
						DecodeTag(vCompany[3]) + ", " + DecodeTag(State[0]) + " " + DecodeTag(vCompany[5]) + "<br/>" +  //City, State and ZipCode
						Country[0] + "<br/><br/>" + //Country
					  "</div>";	
					  
		CompanyHours = "<div id=\"CompanyHours\" class=\"CompanyDetailLeft\">" +
							"<b>Hours: </b><br/>" +
							"M-F: " + StartOperations[0] + " - " + EndOperations[0] + "<br/>" +
							"Time zone: " + TimeZoneIndex[2] +
					   "</div>";

		CompanyContact = "<div id=\"CompanyContact\" class=\"CompanyDetailLeft\">" +
							"<b>Contact: </b><br/>" +
							"Phone: " + DecodeTag(Phone) + "<br/>" + //Phone
							"Toll Free: " + DecodeTag(TollFree) + "<br/>" +   //Toll Free
							"Fax: " + DecodeTag(Fax) + "<br/><br/><br/>" +   //Fax
							"Website: <a href=\"javascript:OpenCompanyWebsite('" + DecodeTag(vCompany[7]) + "')\">" + Website + "</a><br/><br/>" +   //Website
					     "</div>";		
		
		//If there is Latitude and Longitude then set Latitude and Longitude from input hidden otherwise use the default value to 0 for Latitude and Longitude
		if(vCompany[11] != "" && vCompany[11] != null)
			Latitude = vCompany[11];
		else
		{		
			setTimeout("RenderConfirmation('" + Type + "')", 300);
			return;
		}
		
		if(vCompany[12] != "" && vCompany[12] != null)
			Longitude = vCompany[12];
			
		if(vCompany[13] != "" && vCompany[13] != null)
			IsApproximate = vCompany[13];
			
		//Check Company is ASCII member or not when view profile from CompanyList Page or After search result
		
	}
	
	//========================================================================================================================================================================
	//================================================================== Language =============================================================================================	
	var LanguageSelected = "";
	//Check if There is no Language Selected
	if(hLanguageSupport.value != "" && hLanguageSupport.value != null)
	{
		//Split Language Support from Hidden Input		
		var vLanguage = hLanguageSupport.value.split("#");
		//Populate Language Checked
		for(var i = 0; i < vLanguage.length; i++)
		{
			//Split Language Id and Language Name
			var LanguageName = vLanguage[i].split(",");
			LanguageSelected += LanguageName[1] + "<br/>";
		}
	}
	else
	{
		CompanyLanguage = "No language";
	}

	var CompanyLanguage = "<div id=\"CompanyLanguage\" class=\"CompanyDetailLeft\">" +								
							"<b>Languages: </b><br/>" +
							LanguageSelected +
						"</div>";
						    
	//If that company no have a language spoken then don't show Language Box on View Profile
	if(Type == "viewprofile" && hLanguageSupport.value == "")
		CompanyLanguage = "";
	
	
	var companyDetail = "<div id=\"CompanyDetail\">" +						
						"<table>" +							
							"<tr>" +
								"<td valign=\"top\">" + CompanyName + "</td>" +
								"<td valign=\"top\">" + CompanyHours + "</td>" +
							"</tr>" +
							"<tr>" +
								"<td valign=\"top\">" + CompanyContact + "</td>" +
								"<td valign=\"top\">" + CompanyLanguage + "</td>" +
							"</tr>" +
						"</table>" +						
					"</div>";
	
	var mapAndCompanyName = "<div class=\"mapAndCompanyName\">" +
								"<div class=\"mapAndCompanyNameTop\"></div>" +
								"<div class=\"mapAndCompanyNameMiddle\">" +	
									"<table width=\"100%\" border=\"0\">" +
										"<tr>" +
											"<td align=\"right\" style=\"padding:0 10px 0 0;\">" +
												"<div id=\"btnEditYellow\">" +
													linkEditCompany +
												"</div>" +
											"</td>" +
										"</tr>" +
									"</table>" +
									ASCIIGMap +
									companyDetail +									
								"</div>" +
								"<div class=\"mapAndCompanyNameBottom\"></div>" +
						     "</div>";

	//=========================================================================================================================================================================================
	//================================================================== Contact Info, Photo and Logo =============================================================================================	
	var photo = "";
	var contact = "";
	var logo = "";
	var LogoPath = "Upload/no_logo.gif";
	
	
	var TagPhoto = "";
	if (PhotoPath.length > 0)
		TagPhoto ="<img id=\"imgPhoto\" src=\"" + PhotoPath + "\" />";	
	else
		TagPhoto ="<img id=\"imgPhoto\" src=\"thumb.php?img=upload/no_photo.gif&w=80&h=85\" />";	
		
	
	if(hCompanyProfile.value != "" && hCompanyProfile.value != null)
	{
		var vCompanyProfile = hCompanyProfile.value.split("#");
		//There is a company logo
		if(vCompanyProfile[2] != null && vCompanyProfile[2] != "")
			LogoPath = DecodeTag(vCompanyProfile[2]);
	}	
	
	if (LogoPath.length == 0)
	{
		LogoPath = 'Upload/no_logo.gif';
	}

	photo = "<div class=\"photo\">" +
				TagPhoto +
				LinkNextPrevious +
		    "</div>";
	
	contact = "<div class=\"contact\">" +
				"<b>" + DecodeTag(CompanyNameVP) + "</b><br/>" +
				"Call " + ContactName + " at " + Phone + " or <br/>" +
				"<a href=\"javascript:EmailPopup('" + CompanyIdVP + "', '" + DecodeTag(sPrimaryContact[5]) + "', '" + CompanyNameVP + "', '" + ContactName + "')\">send request here</a> to get started <br/> " + 	//Email
		       "</div>";
	
	logo = "<div class=\"logo\">" +		
			"<img id=\"imgCompany\" src=\"" + LogoPath + "\" />" +
		   "</div>";
	
	var photoAndLogo = "<div class=\"photoAndLogo\">" +
						"<div class=\"photoAndLogoTop\"></div>" +
						"<div class=\"photoAndLogoMiddle\">" +
							"<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">" +
								"<tr>" +
									"<td align=\"right\" style=\"padding:0 10px 0 0;\">" +
										"<div id=\"btnEditBlue\">" +
											linkEditContactInformation +
										"</div>" +
									"</td>" +
								"</tr>" +
								"<tr>" +
									"<td>" +
										photo +
										contact +
										logo +
									"</td>" +
								"</tr>" +	
								"<tr>" +
									"<td>&nbsp;</td>" +
								"</tr>" +										
							"</table>" +
							//~ "<div class=\"clearBoth\">" +
						"</div>" +						
						"<div class=\"photoAndLogoBottom\"></div>" +
				       "</div>";
	
	//=========================================================================================================================================================================================
	//========================================================================= Company Description =============================================================================================
	var CompanyDesc = "";	
	var ServiceOffer = "";
	var specialOffers = "";
	
	if(hCompanyProfile.value != "" && hCompanyProfile.value != null)
	{		
		//Split All Value
		var vCompanyProfile = hCompanyProfile.value.split("#");
		
		if(vCompanyProfile[0] != "" && vCompanyProfile[0] != null)
			CompanyDesc = DecodeTag(vCompanyProfile[0]); //Company Description
			
		if(vCompanyProfile[1] != "" && vCompanyProfile[1] != null)
		{
			ServiceOffer = DecodeTag(vCompanyProfile[1]); //Special Offer
			
			//=========================================================================================================================================================================================
			//==================================================================================== Special Offers =======================================================================================	
			specialOffers = "<div class=\"specialOffers\">" +
							"<div class=\"specialOffersTop\"></div>" +
							"<div class=\"specialOffersMiddle\">" +
								"<div id=\"btnEditYellow\">" +
									linkEditCompanyProfile +
								"</div>" +
								"<br/>" +
								"<h3>Special Offers:</h3>" +
								ServiceOffer +
							"</div>" +
							"<div class=\"specialOffersBottom\"></div>" +
						"</div><br/>";	
		}
	}
	else
	{
		CompanyDesc = "No Company Description";
	}
		
	var companyDescription = "<div class=\"companyDescription\">" +
							"<div class=\"companyDescriptionTop\"></div>" +
							"<div class=\"companyDescriptionMiddle\">" +
								"<div id=\"btnEditBlue\">" +
									linkEditCompanyProfile +
								"</div>" +
								"<h3>How We Can Help</h3><br/>" +
								CompanyDesc +
							"</div>" +
							"<div class=\"companyDescriptionBottom\"></div>" +
						"</div>";
	

			     
	//========================================================================================================================================================================
	//================================================================ Service Var =============================================================================================
	var serviceOfferedList = "No service offered";
	if(hServiceVar.value != "" && hServiceVar.value != null)
	{
		serviceOfferedList = "";
		//Split All ServiceVar
		var ServiceVar = hServiceVar.value.split("|");
		for(var i = 0; i < ServiceVar.length; i++)
		{		
			//Split ServiceVar and There Requirements
			var SVnRequirements = ServiceVar[i].split("#");			
			//Get Service Var Name
			var ServiceVarName = SVnRequirements[0].split("^");
			serviceOfferedList += ServiceVarName[1] + "<br/>";
		}
	}
	
	//========================================================================================================================================================================
	//================================================================ Industry ================================================================================================
	//Industry
	var IndustrySelected = "";
	if(hIndustry.value != "" && hIndustry.value != null)
	{
		//Split industry from hidden input
		var vIndustry = hIndustry.value.split("#");
		//Populate Industry Checked
		for(var i = 0; i < vIndustry.length; i++)
		{
			//Get Industry Name
			var IndustryName = vIndustry[i].split(",");
			IndustrySelected += IndustryName[1] + "<br/>";
		}
	}
	else
	{
		IndustrySelected = "No vertical expertise";
	}
	
	
	//========================================================================================================================================================================
	//================================================================ Partnerships =============================================================================================
	var PartnershipSelected = "";
	if(hPartnerships.value != "" && hPartnerships.value != null)
	{
		//Split partnerships from Hidden Input		
		var vPartnerships = hPartnerships.value.split("#");
		//Populate partnership Checked
		for(var i = 0; i < vPartnerships.length; i++)
		{
			//Get Partnership name
			var PartnershipName = vPartnerships[i].split(",");
			PartnershipSelected += PartnershipName[1] + "<br/>";
		}
	}
	else
	{
		PartnershipSelected = "No partnerships";
	}
	
	//========================================================================================================================================================================
	//================================================================ IsASCII Member =========================================================================================
	var IsASCIIMember = "";
	//Check company is ASCII member or not, if ASCII member then show ASCII Logo, otherwise don't show ASCII logo
	if(IsASCIIvp == "1")
	{
		IsASCIIMember = "<div>" +
							"<div id=\"dImgASCII\">" +
								"<img id=\"imgASCII\" src=\"Images/cropascii.png\"/>" +
							"</div>" +
					    "</div>";
	}
	
	//=========================================================================================================================================================================================
	//==================================================================================== Services2 ===========================================================================================
	var servicesOffered = "<div>" +						
						"<h3>Services</h3>" +
						serviceOfferedList +
					 "</div>";
					 
	var areasOfExpertise = "<div>" +
						"<h3>Areas Of Expertise</h3>" +
						IndustrySelected +
					   "</div>";
					   
	var partnerShips = "<div>" +						
						"<h3>Partnerships</h3>" +
						PartnershipSelected +
				     "</div>";
	
	var services2 = "<div class=\"services\">" +
					"<div class=\"servicesTop\"></div>" +
					"<div class=\"servicesMiddle\">" +
						"<div id=\"btnEditYellow\">" +
							linkEditPartnerships +
						"</div>" +
						"<br/>" +
						servicesOffered +
						//areasOfExpertise +
						//partnerShips +
						//IsASCIIMember +						
					"</div>" +
					"<div class=\"servicesBottom\"></div>" +
				"</div>";
				
	var contentSubmitPage =   "<span id=\"Notification\" style=\"color:red\"></span>" +
						"<span id=\"Confirmation\"></span>" +
						"<!-- Span for checking All component is rendered -->" +
						"<span id=\"sSubmit\"></span>";	
				
	var AllContent = contentSubmitPage +
				"<div id=\"tblConfirmation\">" +
					"<div id=\"dVPLeft\">" +
						mapAndCompanyName +
						"<div class=\"clearBoth\"></div><br/>" +
						photoAndLogo +
						"<br/>" +
						companyDescription +								
					"</div>" +
					"<div id=\"dVPRight\">" +
						//specialOffers +						
						services2 +
					"</div>" +		
					"<div class=\"clearBoth\"></div>" +
				"</div>" +
				"<div class=\"clearBoth\"></div>";					
				
	var divContentVP = document.getElementById("content");	
	//Render all information
	divContentVP.innerHTML = AllContent;
	//~ CompanyLocation(vCompany[5]); //Zip Code	
	CompanyLocation2(Latitude, Longitude);
	//Hide Modal
	hideModal("modalPage");
}

function CreateServiceAreaTableConfirmation()
{
	var hServiceAreaList = document.getElementById("hServiceArea");
	var CurIndexSAList = 0;
	var ServiceAreaTable = "<table id=\"tblServiceArea\" cellspacing=\"0\" width=\"100%\">";
	var SAList = hServiceAreaList.value.split("^");				
	var RoundedSAList = Math.round(SAList.length / 2);
	
	//Get SpanId for Render ServiceAreaList
	var SpanId = document.getElementById("ServiceAreaList");

	
	if(hServiceAreaList.value == "")
		RoundedSAList = 0;
	
	for(var i = 0; i < RoundedSAList; i++)
	{					
		//Split Service Area Information
		var SAInfo = SAList[CurIndexSAList].split("#");
		var Country = SAInfo[11].split(",");
		var State = SAInfo[10].split(",");
		var StartOperations = SAInfo[12].split(",");
		var EndOperations = SAInfo[13].split(",");
		var TimeZone = SAInfo[14].split(",");
		
		ServiceAreaTable += "<tr>" +
						//Column 1
						"<td class=\"tblServiceAreaTDLeft\">" +
							"<table>" +
								"<tr>" +
									//Area Name
									"<td>" + DecodeTag(SAInfo[0]) + "</td>" +
									//First Name
									"<td>" + DecodeTag(SAInfo[2]) + "</td>" +
								"</tr>" +
								"<tr>" +
									//Company Website
									"<td>" + DecodeTag(SAInfo[1]) + "</td>" +
									//Last Name
									"<td>" + DecodeTag(SAInfo[3]) + "</td>" +
								"</tr>" +
								"<tr>" +
									//Address1
									"<td>" + DecodeTag(SAInfo[5]) + "</td>" +
									//Email
									"<td>" + DecodeTag(SAInfo[4]) + "</td>" +
								"</tr>" +
								"<tr>" +
									//Address2
									"<td>" + DecodeTag(SAInfo[6]) + "</td>" +
									//Phone
									"<td>" + DecodeTag(SAInfo[7]) + "</td>" +
								"</tr>" +
								"<tr>" +
									//City
									"<td>" + DecodeTag(SAInfo[8]) + "</td>" +
									"<td></td>" +
								"</tr>" +
								"<tr>" +
									//Zip Code
									"<td>" + DecodeTag(SAInfo[9]) + "</td>" +
									"<td></td>" +
								"</tr>" +
								"<tr>" +
									//State
									"<td>" + DecodeTag(State[0]) + "</td>" +
									"<td></td>" +
								"</tr>" +
								"<tr>" +
									//Country
									"<td>" + Country[0] + "</td>" +
									"<td></td>" +
								"</tr>" +
								"<tr>" +
									//Start Operations
									"<td>" + StartOperations[0] + "</td>" +
									"<td></td>" +
								"</tr>" +
								"<tr>" +
									//End Operations
									"<td>" + EndOperations[0] + "</td>" +
									"<td></td>" +
								"</tr>" +
								"<tr>" +
									//Time Zone
									"<td>" + TimeZone[2] + "</td>" +
									"<td></td>" +
								"</tr>" +								
							"</table>" +
						"</td>";
		
			//Column Two
			ServiceAreaTable += "<td class=\"tblServiceAreaTDRight\">";
			
			//Increase 1 to Current Index it's mean to next value of split
			CurIndexSAList += 1;						
			
			if(SAList[CurIndexSAList] != "" && SAList[CurIndexSAList] != null)
			{
				//Split Service Area Information
				SAInfo = SAList[CurIndexSAList].split("#");
				Country = SAInfo[11].split(",");
				State = SAInfo[10].split(",");
				StartOperations = SAInfo[12].split(",");
				EndOperations = SAInfo[13].split(",");
				TimeZone = SAInfo[14].split(",");
				
				ServiceAreaTable += "<table>" +
								"<tr>" +
									//Area Name
									"<td>" + DecodeTag(SAInfo[0]) + "</td>" +
									//First Name
									"<td>" + DecodeTag(SAInfo[2]) + "</td>" +
								"</tr>" +
								"<tr>" +
									//Company Website
									"<td>" + DecodeTag(SAInfo[1]) + "</td>" +
									//Last Name
									"<td>" + DecodeTag(SAInfo[3]) + "</td>" +
								"</tr>" +
								"<tr>" +
									//Address1
									"<td>" + DecodeTag(SAInfo[5]) + "</td>" +
									//Email
									"<td>" + DecodeTag(SAInfo[4]) + "</td>" +
								"</tr>" +
								"<tr>" +
									//Address2
									"<td>" + DecodeTag(SAInfo[6]) + "</td>" +
									//Phone
									"<td>" + DecodeTag(SAInfo[7]) + "</td>" +
								"</tr>" +
								"<tr>" +
									//City
									"<td>" + DecodeTag(SAInfo[8]) + "</td>" +
									"<td></td>" +
								"</tr>" +
								"<tr>" +
									//Zip Code
									"<td>" + DecodeTag(SAInfo[9]) + "</td>" +
									"<td></td>" +
								"</tr>" +
								"<tr>" +
									//State
									"<td>" + DecodeTag(State[0]) + "</td>" +
									"<td></td>" +
								"</tr>" +
								"<tr>" +
									//Country
									"<td>" + Country[0] + "</td>" +
									"<td></td>" +
								"</tr>" +
								"<tr>" +
									//Start Operations
									"<td>" + StartOperations[0] + "</td>" +
									"<td></td>" +
								"</tr>" +
								"<tr>" +
									//End Operations
									"<td>" + EndOperations[0] + "</td>" +
									"<td></td>" +
								"</tr>" +
								"<tr>" +
									//Time Zone
									"<td>" + TimeZone[2] + "</td>" +
									"<td></td>" +
								"</tr>" +							
							"</table>";
			}
			
			ServiceAreaTable += "</td>";
		
		ServiceAreaTable += "</tr>";
		
		//Increase 1 to Current Index it's mean to next value of split
		CurIndexSAList += 1;
	}
	
	ServiceAreaTable += "</table>";
	
	return ServiceAreaTable;
}


function CreateServiceAreaTableConfirmation2()
{
	var hServiceAreaList = document.getElementById("hServiceArea");	
	var ServiceAreaTable = "";
	var SAList = hServiceAreaList.value.split("^");	
	
	for(var i = 0; i < SAList.length; i++)
	{
		//Split Service Area Information
		var SAInfo = SAList[i].split("#");
		var Country = SAInfo[11].split(",");
		var State = SAInfo[10].split(",");
		var StartOperations = SAInfo[12].split(",");
		var EndOperations = SAInfo[13].split(",");
		var TimeZone = SAInfo[14].split(",");
		
		ServiceAreaTable += "<br/><table id=\"tblServiceArea\" cellspacing=\"0\" width=\"100%\">" +
							"<tr>" +
							
								"<td class=\"tblTdSALeft\">" +
									"<table>" +
										"<tr>" +
											//Area Name
											"<td>" + DecodeTag(SAInfo[0]) + "</td>" +
										"</tr>" +
										"<tr>" +
											//Company Website
											"<td>" + DecodeTag(SAInfo[1]) + "</td>" +
										"</tr>" +
										"<tr>" +
											//Address1
											"<td>" + DecodeTag(SAInfo[5]) + "</td>" +
										"</tr>" +
										"<tr>" +
											//Address2
											"<td>" + DecodeTag(SAInfo[6]) + "</td>" +
										"</tr>" +
										"<tr>" +
											//City, State, Zip Code
											"<td>" + DecodeTag(SAInfo[8]) + " " + DecodeTag(State[0]) + " " + DecodeTag(SAInfo[9]) + "</td>" +
										"</tr>" +										
										"<tr>" +
											//Country
											"<td>" + Country[0] + "</td>" +
										"</tr>" +
										"<tr>" +
											//Start Operations - End Operations
											"<td>M-F: " + StartOperations[0] + " - " + EndOperations[0] + "</td>" +
										"</tr>" +
										"<tr>" +
											//Time Zone
											"<td>Time Zone: " + TimeZone[2] + "</td>" +
										"</tr>" +
									"</table>" +
								"</td>" +
								
								"<td class=\"tblTdSARight\">" +
									"<div id=\"CIandSO\">" +
										"<h5>Contact Information</h5>" +
										"<table>" +
											"<tr>" +
												//First Name and Last Name
												"<td>" + DecodeTag(SAInfo[2])  + " " + DecodeTag(SAInfo[3]) + "</td>" +
											"</tr>" +
											"<tr>" +
												//Email
												"<td>" + DecodeTag(SAInfo[4]) + "</td>" +
											"</tr>" +
											"<tr>" +
												//Phone
												"<td>" + DecodeTag(SAInfo[7]) + "</td>" +
											"</tr>" +
										"</table>" +
									"</div>" +
								"</td>" +
								
							"</tr>" +
						"</table><br/>";	
	}
	
	return ServiceAreaTable;
}

var IndexPhoto = 0;

function NextPhoto()
{
	//Get Photo Image Object
	var imgPhoto = document.getElementById("imgPhoto");
	//Get All Value primary contact from input hidden
	var hPrimaryContact = document.getElementById("hPrimaryContact");
	//Split Value of Primary Contact
	var AllValuePC = hPrimaryContact.value.split("#");
	if(AllValuePC[6] != "" && AllValuePC[6] != null && AllValuePC[6].length > 0)
	{	
		var imgPhotoPath = AllValuePC[6].split(",");
		if(imgPhotoPath.length > 0 && IndexPhoto != imgPhotoPath.length -1)
			IndexPhoto += 1;
		else if(IndexPhoto == imgPhotoPath.length -1)
			IndexPhoto = 0;	
		
		imgPhoto.src = DecodeTag(imgPhotoPath[IndexPhoto]);	
	}
	else
	{
		imgPhoto.src = "thumb.php?img=upload/no_photo.gif&w=60&h=80";
	}	
}

function PreviousPhoto()
{
	//Get Photo Image Object
	var imgPhoto = document.getElementById("imgPhoto");
	//Get All Value primary contact from input hidden
	var hPrimaryContact = document.getElementById("hPrimaryContact");
	//Split Value of Primary Contact
	var AllValuePC = hPrimaryContact.value.split("#");
	if(AllValuePC[6] != "" && AllValuePC[6] != null && AllValuePC[6].length > 0)
	{
		var imgPhotoPath = AllValuePC[6].split(",");
		 if(IndexPhoto == 0)
			IndexPhoto = imgPhotoPath.length -1;
		else
			IndexPhoto -= 1;
		
		imgPhoto.src = DecodeTag(imgPhotoPath[IndexPhoto]);
	}
	else
	{
		imgPhoto.src = "thumb.php?img=upload/no_photo.gif&w=60&h=80";
	}	
}