function getGcOptionSelect()
{
	var lSearchElement;
	var lSearch;
	var lEntityConfiguration;
	var lRequest;
	var lXMLResponse;
	var lRoot;
	var lSearch;

  	var lAJAXInteraction = new AJAXInteraction("/dotcom/oxford/GiftCertificates/jsp/GcOptionSelect.jsp", null, true);
		lRequest = lAJAXInteraction.doPost('LK=' + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lSearchElement = copyNodes(lRoot);


	clearDIV("Search");
//	clearDIV("AddEdit");	
	lSearch = document.getElementById("Search");
	lSearch.appendChild(lSearchElement);
}
function getofflineGcForm()
{
  if(IS_USER_LOGGED_IN == 0)
  {
		alert(MSG_LOGIN_BEFORE_ACESS);
  }
  else
  {
	clearDIV("Search");
    var lEntity='giftcertificates';
	var	gEntityConfig;
	gEntityConfig = eval("entityConfiguration." + lEntity);		
	showOnlyEntity(lEntity);
	lEntityConfiguration = gEntityConfig;	
	gCurrentEntity = lEntityConfiguration.entity;
	gCurrentSearchTemplate = lEntityConfiguration.searchTemplate;
	gCurrentAddEditTemplate = lEntityConfiguration.addEditTemplate;
	gCurrentListTemplate = lEntityConfiguration.listTemplate;
	gCurrentViewTemplate = lEntityConfiguration.viewTemplate;
	gCurrentEntityIdField = lEntityConfiguration.entityIdField;
	gCurrentEntityListURL = lEntityConfiguration.URLForEntityList;
	gCurrentEntityPreEditURL = lEntityConfiguration.URLForEntityPreEdit;
	gCurrentEntitySaveURL = lEntityConfiguration.URLForEntitySave;
	gCurrentEntityPreURL = lEntityConfiguration.URLForPreFetch;
	gCurrentEntityDeleteURL = lEntityConfiguration.URLForEntityDelete;
	gPostAddEdit = lEntityConfiguration.postAddEdit;
	gPostSearch = lEntityConfiguration.postSearch;
	gPostEdit = lEntityConfiguration.postEdit;
	gPostList = lEntityConfiguration.postList;
	gClearAddEdit = true;
	showEntityAdd();
   }
}
function getGcForm()
{
   if(IS_USER_LOGGED_IN == 0)
   {
		alert(MSG_LOGIN_BEFORE_ACESS);
   }
   else
   {	
	clearDIV("Search");
    var lEntity='giftcertificatesonline';
	var	gEntityConfig;
	gEntityConfig = eval("entityConfiguration." + lEntity);		
	showOnlyEntity(lEntity);
	lEntityConfiguration = gEntityConfig;	
	gCurrentEntity = lEntityConfiguration.entity;
	gCurrentSearchTemplate = lEntityConfiguration.searchTemplate;
	gCurrentAddEditTemplate = lEntityConfiguration.addEditTemplate;
	gCurrentListTemplate = lEntityConfiguration.listTemplate;
	gCurrentViewTemplate = lEntityConfiguration.viewTemplate;
	gCurrentEntityIdField = lEntityConfiguration.entityIdField;
	gCurrentEntityListURL = lEntityConfiguration.URLForEntityList;
	gCurrentEntityPreEditURL = lEntityConfiguration.URLForEntityPreEdit;
	gCurrentEntitySaveURL = lEntityConfiguration.URLForEntitySave;
	gCurrentEntityPreURL = lEntityConfiguration.URLForPreFetch;
	gCurrentEntityDeleteURL = lEntityConfiguration.URLForEntityDelete;
	gPostAddEdit = lEntityConfiguration.postAddEdit;
	gPostSearch = lEntityConfiguration.postSearch;
	gPostEdit = lEntityConfiguration.postEdit;
	gPostList = lEntityConfiguration.postList;
	gClearAddEdit = true;
	showEntityAdd();
   }
}

function validateGcDetails(sessionId,orgID,custId)
{
var pformname = "document.AddEdit";
var amt= document.AddEdit.gcamount.value;
var to= document.AddEdit.gctoname.value;
var from= document.AddEdit.gcfromname.value;
var mesg= document.AddEdit.gcmsg.value;
if(amt)
{
if(isInteger(amt)==true)
{
 if( 100>amt || amt >5000)
 {
   alert(MSG_ENTER_AMT_IN_LMT);
   return;
 } 
}
else
{
  alert( MSG_ENTER_VALID_AMT);
  return;
}
if((amt%100))
{
alert(MSG_ENTER_AMT_IN_MULTIPLE);
return;
}
}
else
{
  alert(MSG_ENTER_AMT);
  return;
}

if(!to)
{
	alert(MSG_ENTER_RECIPEINTS_NAME);
		 return;
}
if(!from)
{
	alert(MSG_ENTER_SENDERS_NAME);
		 return;
}
if(!mesg)
{
	alert(MSG_ENTER_MESSAGE);
		 return;
}
proceedToCheckOutForGC(sessionId,orgID,custId);
//showShipNPayforGc()
//proceedToCheckOutForonlineGC(sessionId,orgID,custId);
}

function proceedToCheckOutForGC(sessionId,orgID,custId)
{	
	if(IS_USER_LOGGED_IN == 0)
	{
		alert(MSG_LOGIN_BEFORE_CHECKOUT);
		return false;
	}
	else
	{
		var lEntity='giftcertificates';
		var	lEntityConfig = eval("entityConfiguration." + lEntity);
		//lEntityConfig.URLForEntitySave ="/dotcom/GcAdd.kar";
		submitForm(document.AddEdit,lEntityConfig.URLForEntitySave+'?gcsessionid='+sessionId+'&gcorgid='+orgID+'&gccustid='+custId, "POST", null, gLoginKey, null);
//        alert('after save');
		lEntityConfig.addEditTemplate=lEntityConfig.BillingAddressTemplate;
		gCurrentAddEditTemplate = lEntityConfig.BillingAddressTemplate;		
		gEntityConfig.URLForPreFetch  ="/dotcom/GcAddressPrefetch.kar";	
		//scancelGiftWrapper();
//		alert('gCurrentAddEditTemplate'+gCurrentAddEditTemplate);
		var div = document.getElementById("CartAddEdit")
        document.getElementById("CartAddEdit").style.display = "none";
		showGCEntityAddEdit();
		getGcAddress();
		document.getElementById("Prefix1").focus();
	}
}


function showGCEntityAddEdit()
{
	var lAddEditElement;
	var lRoot;
	var lAddEditElement;
	var lRequest;
	//lAddEditElement = gCache.get(gCurrentEntity + "ADDEDIT");
	lAddEditElement = null;
//	alert(gCurrentAddEditTemplate+'gCurrentAddEditTemplate');
	if (lAddEditElement == null)
	{
		var lAJAXInteraction = new AJAXInteraction(gCurrentAddEditTemplate, null, true);
		lRequest = lAJAXInteraction.doPost("LK=" + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lRoot = copyNodes(lRoot);
		lAddEditElement = lRoot.childNodes[1];
		//gCache.add(gCurrentEntity + "ADDEDIT", lAddEditElement);
	}
	showGCAddEdit(lAddEditElement);
}
/**
 * This function shows the AddEdit are and if it is an edit request
 * it posts a request to the edit URL for the entity.
 * @param pAddEditElement - The Add Edit Element that is to be
 * shown in the AddEdit DIV.
 */
function showGCAddEdit(pAddEditElement)
{
	var lAddEdit;
	clearDIV("AddEdit");
	lAddEdit = document.getElementById("AddEdit");
//	alert(lAddEdit  + 'div');
	lAddEdit.appendChild(pAddEditElement);
	//clearForm("AddEdit");
	clearExtras();
	getPreEntity();
	if (gEntityConfig.postAddEdit != null)
	{
		eval(gEntityConfig.postAddEdit + "()");
	}

} 

function validateOnlineGcDetails(sessionId,orgID,custId)
{
var pformname = "document.AddEdit";
var amt= document.AddEdit.gcdoamount.value;
var to= document.AddEdit.gcdotoname.value;
var from= document.AddEdit.gcdofromname.value;
var mesg= document.AddEdit.gcdomsg.value;
var recmail= document.AddEdit.gcdotoemailid.value;
var conrecmail= document.AddEdit.gcdotoconfirmemailid.value;

if(amt)
{
if(isInteger(amt)==true)
{
 if( 100>amt || amt >5000)
 {
   alert(MSG_ENTER_AMT_IN_LMT);
   return;
 } 
}
else
{
  alert(MSG_ENTER_VALID_AMT);
  return;
}
if((amt%100))
{
alert(MSG_ENTER_AMT_IN_MULTIPLE);
return;
}
}
else
{
  alert(MSG_ENTER_AMT);
  return;
}

if(!to)
{
	alert(MSG_ENTER_RECIPEINTS_NAME);
		 return;
}
if(!from)
{
	alert(MSG_ENTER_SENDERS_NAME);
		 return;
}
if(!mesg)
{
	alert(MSG_ENTER_MESSAGE);
		 return;
}
if(!recmail)
{
	alert(MSG_ENTER_RECIPEINTS_EMAIL);
		 return;
}
else
{
if(emailidcheck(recmail)==false)
	{
		return;
	}
}
if(!conrecmail)
{
	alert(MSG_CONFIRM_RECIPEINTS_EMAIL);
		 return;
}
else
{
	if(emailidcheck(conrecmail)==false)
	{
		return;
	}
}
if(recmail != conrecmail)
{
		alert(MSG_CONFIRM_RECIPEINTS_EMAIL);
		 return;
}
proceedToCheckOutForonlineGC(sessionId,orgID,custId);
//showShipNPayforGc()
//proceedToCheckOutForonlineGC(sessionId,orgID,custId);
}

 function emailidcheck(srt) 
	   {		
		 var at="@";
		 var dot=".";
		 var lat=srt.indexOf(at);
		 var lstr=srt.length;
		 var ldot=srt.indexOf(dot);
         var splChars = '*|\":<>[]{}`\';()&$#%^';
    	 for (j = 0;j < srt.length; j++)
		 {
		   if (splChars.indexOf(srt.charAt(j)) != -1)
			{
			   showMessage(INVALID_EMAIL_ID);		   
               return false;
			}
		 }
		 if (srt.indexOf(at)==-1)
		 {    	   
		   showMessage(INVALID_EMAIL_ID);		   
		   return false;
		 }
		 if (srt.indexOf(at)==-1 || srt.indexOf(at)==0 || srt.indexOf(at)==lstr)
		 {     	   
		   showMessage(INVALID_EMAIL_ID);
		   return false;
		 }
		 if (srt.indexOf(dot)==-1 || srt.indexOf(dot)==0 || srt.indexOf(dot)==lstr)
		 {        	
		    showMessage(INVALID_EMAIL_ID);
		    return false;
		 }
		 if (srt.indexOf(at,(lat+1))!=-1)
	     {        	
		    showMessage(INVALID_EMAIL_ID);
		    return false;
		 }
		 if (srt.substring(lat-1,lat)==dot || srt.substring(lat+1,lat+2)==dot)
		 {
     	    showMessage(INVALID_EMAIL_ID);
		    return false;
		 }
		 if (srt.indexOf(dot,(lat+2))==-1)
		 {     	   
		    showMessage(INVALID_EMAIL_ID);
		    return false;
		 }
		 if (srt.indexOf(" ")!=-1)
	     {     	  
		    showMessage(INVALID_EMAIL_ID);
		    return false;
		 }
 			return true;
	}
	
function proceedToCheckOutForonlineGC(sessionId,orgID,custId)
{
		
	if(IS_USER_LOGGED_IN == 0)
	{
		alert(MSG_LOGIN_BEFORE_CHECKOUT);
		return false;
	}
	else
	{
 var lEntity='giftcertificatesonline';
 var lEntityConfig = eval("entityConfiguration." + lEntity);
// alert(lEntityConfig.URLForEntitySave+'         lEntityConfig.URLForEntitySave');
//  submitForm(document.AddEdit,lEntityConfig.URLForSCPaymentPreEdit, "POST", displayPaymentOptionsforGc, gLoginKey, null);
		submitForm(document.AddEdit,lEntityConfig.URLForEntitySave+'?gcdosessionid='+sessionId+'&gcdoorgid='+orgID+'&gcdocustid='+custId, "POST", null, gLoginKey, null);
  showPaymentforonlineGc();
	}
}
function getGcAddress()
{
	submitForm(document.AddEdit, "/dotcom/GcRegisterAddressGet.kar", "POST", handleAddressEditforGc, gLoginKey, null);
}
function handleAddressEditforGc(pXMLObject)
{
//	alert('in callback for gc');
	showEdit(pXMLObject);
	if(document.getElementById("shipBill").value == null || document.getElementById("shipBill").value == "" || document.getElementById("shipBill").value == 1)
	{
		document.getElementById("shipToBill").checked=true;		
		document.getElementById("shipAddDiv").style.display="none";
	}
	else
	{
		document.getElementById("shipToBill").checked=false;
		document.getElementById("shipAddDiv").style.display="block";
	}
}

function saveAddressForGc()
{
	//alert('Hi over here ');
	pPrefix = document.getElementById("Prefix1").name;
	pFirstName = document.getElementById("Fname1").name;
	pLastName = document.getElementById("Lname1").name;
	pAddrLn1 = document.getElementById("Add11").name;
	pCity =	document.getElementById("City1").name;
	pState = document.getElementById("State1").name;
	pCountry = document.getElementById("Country1").name;
	pZip = document.getElementById("ZipC1").name;
	pContactNo = document.getElementById("Contact1").name;


	if(validateBillingShippingAddress(pPrefix, pFirstName, pLastName, pAddrLn1, pCity, pState, pCountry, pZip, pContactNo))
	{

	if(!document.getElementById("shipToBill").checked)
		{
			pPrefix = document.getElementById("Prefix").name;
			pFirstName = document.getElementById("Fname").name;
			pLastName = document.getElementById("Lname").name;
			pAddrLn1 = document.getElementById("Add1").name;
			pCity =	document.getElementById("City").name;
			pState = document.getElementById("State").name;
			pCountry = document.getElementById("Country").name;
			pZip = document.getElementById("ZipC").name;
			pContactNo = document.getElementById("Contact").name;
			//alert('inside if of shipping checked');

			if(validateBillingShippingAddress(pPrefix, pFirstName, pLastName, pAddrLn1, pCity, pState, pCountry, pZip, pContactNo))
			{
				if(!document.getElementById("shipToBill").checked)
					document.getElementById("shipBill").value=0;
				else
					document.getElementById("shipBill").value=1;
				  var lst = document.getElementById("Country");				

				if(lst.options[lst.selectedIndex].value != "")
					document.getElementById("shipcountry").value=lst.options[lst.selectedIndex].text;
				 var lst1 = document.getElementById("Country1");
				if(lst1.options[lst1.selectedIndex].value != "")
					document.getElementById("billcountry").value=lst1.options[lst1.selectedIndex].text;
					submitForm(document.AddEdit,"/dotcom/GcAddressSave.kar", "POST", handleAddressSaveforGc, gLoginKey, null);
			 }
		}
		else
		{

			//alert('inside else of shipping checked');

			if(!document.getElementById("shipToBill").checked)
					document.getElementById("shipBill").value=0;
			else
					document.getElementById("shipBill").value=1;
				    var lst = document.getElementById("Country");
				
				if(lst.options[lst.selectedIndex].value != "")
					document.getElementById("shipcountry").value=lst.options[lst.selectedIndex].text;
				 var lst1 = document.getElementById("Country1");
				if(lst1.options[lst1.selectedIndex].value != "")
					document.getElementById("billcountry").value=lst1.options[lst1.selectedIndex].text;				
					submitForm(document.AddEdit,"/dotcom/GcAddressSave.kar", "POST", handleAddressSaveforGc, gLoginKey, null);
				
		}

	}
}

function handleAddressSaveforGc(pXMLObject)
{	
	//alert('in callback for gc');
	var lXMLResponse;
	var lRoot;
	var lSuccess;
	lXMLResponse = pXMLObject.responseXML;
	lRoot = lXMLResponse.documentElement;
	lRoot = copyNodes(lRoot);
	lSuccess = handleResult(lRoot.childNodes[0], 'AddEdit');	
	if (lSuccess)
	{		
		editAddressforGc();
		editCourierPaymentforGc();
	}
}

function editCourierPaymentforGc()
{	
	var lEntity='giftcertificates';
	var	lEntityConfig = eval("entityConfiguration." + lEntity);
	if(showShipNPayforGc() == true)
		submitForm(document.AddEdit, lEntityConfig.URLForSCCourierPaymentPreEdit, "POST", showEdit, gLoginKey, null);
}

function editAddressforGc()
{
	var lEntity='giftcertificates';
	var	lEntityConfig = eval("entityConfiguration." + lEntity);
	var temp=	lEntityConfig.addEditTemplate;
	lEntityConfig.addEditTemplate=lEntityConfig.BillingAddressTemplate;
	gCurrentAddEditTemplate = lEntityConfig.BillingAddressTemplate;	
	lEntityConfig.URLForPreFetch ="/dotcom/GcAddressPrefetch.kar";
	showOnlyEntity(lEntity);
	document.getElementById("CartAddEdit").style.display = "none";
	showGCEntityAddEdit();
    getGcAddress();
	document.getElementById("Prefix1").focus();
	lEntityConfig.addEditTemplate=temp;
}

function showPaymentforonlineGc()
{
	//alert('hi in payment');
	var lEntity='giftcertificatesonline';
	var	lEntityConfig = eval("entityConfiguration." + lEntity);
	var lRegularAddEdit = lEntityConfig.addEditTemplate
	lEntityConfig.addEditTemplate=lEntityConfig.ShipNPayTemplate;
	showOnlyEntity(lEntity);
	clearDIV('AddEdit');
	document.getElementById("CartAddEdit").style.display = "none";

	var lAddEditElement;
	var lRoot;
	var lRequest;	
	lAddEditElement = null;
	if (lAddEditElement == null)
	{
		//alert('gCurrentAddEditTemplate      '+ gCurrentAddEditTemplate);
		var lAJAXInteraction = new AJAXInteraction(gCurrentAddEditTemplate, null, true);
		lRequest = lAJAXInteraction.doPost("LK=" + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lRoot = copyNodes(lRoot);
		lAddEditElement = lRoot.childNodes[1];
	}
	lAddEdit = document.getElementById("AddEdit");
	lAddEdit.appendChild(lAddEditElement);
	submitForm(document.AddEdit,lEntityConfig.URLForSCPaymentPreEdit, "POST", displayPaymentOptionsforonlineGc, gLoginKey, null);
	return true;
}
function showShipNPayforGc()
{
	//alert('hi in payment');
	var lEntity='giftcertificates';
	var	lEntityConfig = eval("entityConfiguration." + lEntity);
	var lRegularAddEdit = lEntityConfig.addEditTemplate
	lEntityConfig.addEditTemplate=lEntityConfig.ShipNPayTemplate;
	showOnlyEntity(lEntity);
	document.getElementById("CartAddEdit").style.display = "none";

	var lAddEditElement;
	var lRoot;
	var lRequest;	
	lAddEditElement = null;
	if (lAddEditElement == null)
	{
		//alert('gCurrentAddEditTemplate      '+ gCurrentAddEditTemplate);
		var lAJAXInteraction = new AJAXInteraction(gCurrentAddEditTemplate, null, true);
		lRequest = lAJAXInteraction.doPost("LK=" + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lRoot = copyNodes(lRoot);
		lAddEditElement = lRoot.childNodes[1];
	}
	lAddEdit = document.getElementById("AddEdit");
	lAddEdit.appendChild(lAddEditElement);
	//alert(	lAddEdit+'	lAddEdit');
	submitForm(document.AddEdit,lEntityConfig.URLForSCCourierPreEdit, "POST", displayCourierOptionsforGc, gLoginKey, null);
	//alert('after courier get');
	submitForm(document.AddEdit,lEntityConfig.URLForSCPaymentPreEdit, "POST", displayPaymentOptionsforGc, gLoginKey, null);
	//alert('after payment get');
	return true;
}
function savePaymentinfoforonlineGc(sessionId,orgId,custId)
{
	var lEntity='giftcertificatesonline';
	var	lEntityConfig = eval("entityConfiguration." + lEntity);
	submitForm(document.AddEdit, lEntityConfig.URLForPaymentSave, "POST", null, gLoginKey, null);
	//submitForm(document.AddEdit, lEntityConfig.viewTemplate, "POST", showView, gLoginKey, null);
	ShowOnlineGcConfirmView(sessionId,orgId,custId)
}

function saveCourierPaymentforofflineGc()
{
	var lEntity='giftcertificates';
	var	lEntityConfig = eval("entityConfiguration." + lEntity);
	submitForm(document.AddEdit, lEntityConfig.URLForCourierPaymentSave, "POST", handleSaveCourierPaymentforGc, gLoginKey, null);
}
function ShowOfflineGcEdit(sessionId,orgId,custId)
{		
	clearDIV("AddEdit");
	var lElement;
	var lSearch;
	var lRequest;
	var lXMLResponse;
	var lRoot;	
	var lViewGctemplate="/dotcom/oxford/GiftCertificates/jsp/giftCetificatesForm.jsp";
	var lAJAXInteraction = new AJAXInteraction(lViewGctemplate, null, true);
		lRequest = lAJAXInteraction.doPost('LK=' + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lElement = copyNodes(lRoot);

	var lSearch= document.getElementById("AddEdit");
	lSearch.appendChild(lElement);
	getViewOfflineConfrimPreEntity(sessionId,orgId,custId);
}


function ShowOnlineGcConfirmView(sessionId,orgId,custId)
{		
	clearDIV("AddEdit");
	var lElement;
	var lSearch;
	var lRequest;
	var lXMLResponse;
	var lRoot;	
	var lViewFeedbacktemplate="/dotcom/oxford/GiftCertificates/jsp/OnlineOrderSummary.jsp";
	var lAJAXInteraction = new AJAXInteraction(lViewFeedbacktemplate, null, true);
		lRequest = lAJAXInteraction.doPost('LK=' + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lElement = copyNodes(lRoot);

	var lSearch= document.getElementById("AddEdit");
	lSearch.appendChild(lElement);
	getViewOnlineConfrimPreEntity(sessionId,orgId,custId);
}
function ShowOnlineGcEdit(sessionId,orgId,custId)
{		
	clearDIV("AddEdit");
	var lElement;
	var lSearch;
	var lRequest;
	var lXMLResponse;
	var lRoot;	
	var lViewFeedbacktemplate="/dotcom/oxford/GiftCertificates/jsp/OnlineGiftCetificatesForm.jsp";
	var lAJAXInteraction = new AJAXInteraction(lViewFeedbacktemplate, null, true);
		lRequest = lAJAXInteraction.doPost('LK=' + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lElement = copyNodes(lRoot);

	var lSearch= document.getElementById("AddEdit");
	lSearch.appendChild(lElement);
	getViewOnlineConfrimPreEntity(sessionId,orgId,custId);
}


function getViewOnlineConfrimPreEntity(sessionId,orgId,custId)
{
	var lViewOnlineConfirmUrl="/dotcom/GcOnlineConfirmDetails.kar";
	//alert('lViewOnlineConfirmUrl');
	submitForm(document.AddEdit, lViewOnlineConfirmUrl+'?sessionID='+sessionId+'&orgid='+orgId+'&custid='+custId, "POST", showViewGc, gLoginKey, null);
}
function getViewOfflineConfrimPreEntity(sessionId,orgId,custId)
{
	var lViewOfflineConfirmUrl="/dotcom/GcOfflineConfirmDetails.kar";
	//alert('lViewOfflineConfirmUrl');
	submitForm(document.AddEdit, lViewOfflineConfirmUrl+'?sessionID='+sessionId+'&orgid='+orgId+'&custid='+custId, "POST", showViewGc, gLoginKey, null);
}
function showViewGc(pXMLObject)
{
	var lXMLResponse;
	var lBaseEdit;
	var lEntity;
	var lData;
	var lLists;
	var lChildren;
	var lCount;
	var lSuccess;
	lXMLResponse = pXMLObject.responseXML;
	lBaseEdit = lXMLResponse.documentElement;
	lBaseEdit = copyNodes(lBaseEdit);
	lSuccess = handleResult(lBaseEdit.childNodes[0]);
	if (lSuccess)
	{
		lChildren = lBaseEdit.childNodes;
		lLists = null;
		for (lCount = 1; lCount < lChildren.length; lCount++)
		{
			if (!isNodeNull(lChildren[lCount]))
			{
					if (lChildren[lCount].nodeName == "DATA")
				{
						lData = lChildren[lCount];
				}
				else if (lChildren[lCount].nodeName == "LISTS")
				{
					lLists = parseLists(lChildren[lCount]);
				}
			}
		}
		for (lCount = 0; lCount < lData.childNodes.length; lCount++)
		{
			fillViewGc(lData.childNodes[lCount]);
		}
		if (gEntityConfig.postView != null)
		{
			eval (gEntityConfig.postView + "(pXMLObject)");
		}
	}
}
function fillViewGc(pEntity)
{
	var lCount;
	var lSpan;
	for (lCount = 0; lCount < pEntity.attributes.length; lCount++)
	{
		lSpan = document.getElementById(pEntity.attributes[lCount].name);
		if (lSpan)
		{
			if (document.all)
			{
				lSpan.innerText = Url.decode(pEntity.attributes[lCount].value);
			}
			else
			{
				clearDIV(pEntity.attributes[lCount].name);
				lSpan.appendChild(document.createTextNode(Url.decode(pEntity.attributes[lCount].value)));
			}
		}
	}
}
function displayCourierOptionsforGc(pXMLObject)
{
	var lXMLResponse;
	var lBaseEdit;
	var lData;
	var lCount;
	var lSuccess;
	var lValue;
	var lDisplayText;
	var lElement;
	var lTextElement;
	var lBreakElement;
	var lCourierStartAmount;
	lXMLResponse = pXMLObject.responseXML;
	lBaseEdit = lXMLResponse.documentElement;
	lBaseEdit = copyNodes(lBaseEdit);
	lSuccess = handleResult(lBaseEdit.childNodes[0]);
	if (lSuccess)
	{
		lData = lBaseEdit.childNodes[1];
		var td = document.getElementById("courierSelect");
		lElement = gDOM.createNewElement("input", [{name:"type",value:"radio"}, {name:"name",value:"gcshppaycourierid"}, {name:"value",value:0}]);
		lElement.style.display="none";
		td.appendChild(lElement);
		if(lData.childNodes.length == 0)
		{
			var lSpan = document.getElementById("shippingInstrText");
			lSpan.removeChild(lSpan.childNodes[0]);
            alert(FIELD_DEFAULT_SHIPPING_1+'FIELD_DEFAULT_SHIPPING_1');
			var lDisplayText = FIELD_DEFAULT_SHIPPING_1 + FIELD_DEFAULT_SHIPPING_2 + FIELD_DEFAULT_SHIPPING_3;
			lTextElement = document.createTextNode(lDisplayText);
			lSpan.appendChild(lTextElement);
			lElement = gDOM.createNewElement("input", [{name:"type",value:"radio"}, {name:"name",value:"gcshppaycourierid"}, {name:"value",value:CONST_IPS_ID}, {name:"checked",value:true}]);
			lTextElement = document.createTextNode("INDIAN POSTAL SERVICE");
			lBreakElement = document.createElement("BR");
			td.appendChild(lElement);
			td.appendChild(lTextElement);
			td.appendChild(lBreakElement);
		}
		//alert("in courier display: " + lData.childNodes.length);
		for (lCount = 0; lCount < lData.childNodes.length; lCount++)
		{
			for (var lAttributeCount = 0; lAttributeCount < lData.childNodes[lCount].attributes.length; lAttributeCount++)
			{
				var lAttribute = lData.childNodes[lCount].attributes[lAttributeCount];
				//alert("lAttribute: " + lAttribute);
				if (!isNodeNull(lAttribute))
				{					
					if (lAttribute.nodeName == "couriermstrid")
					{
						lValue = lAttribute.value;
					}
					else if (lAttribute.nodeName == "couriermstrcouriername")
					{
						lDisplayText = Url.decode(lAttribute.value);
					}
					else if (lAttribute.nodeName == "couriermstrstartamtrs")
					{
						lCourierStartAmount = lAttribute.value;
					}
				}
			}
			if(lCourierStartAmount != 0)
			{
				lTextElement = document.createTextNode(lDisplayText);
				if(lCount == 0)
					lElement = gDOM.createNewElement("input", [{name:"type",value:"radio"}, {name:"name",value:"gcshppaycourierid"}, {name:"value",value:lValue}, {name:"checked",value:true}]);
				else
					lElement = gDOM.createNewElement("input", [{name:"type",value:"radio"}, {name:"name",value:"gcshppaycourierid"}, {name:"value",value:lValue}]);
				lBreakElement = document.createElement("BR");
				td.appendChild(lElement);
				td.appendChild(lTextElement);
				td.appendChild(lBreakElement);
			}
		}	

	}
}
function displayPaymentOptionsforGc(pXMLObject)
{
	var lXMLResponse;
	var lBaseEdit;
	var lData;
	var lCount;
	var lSuccess;
	var lValue;
	var lDisplayText;
	var lElement;
	var lTextElement;
	var lBreakElement;
	var lPaymentCode;
	lXMLResponse = pXMLObject.responseXML;
	lBaseEdit = lXMLResponse.documentElement;
	lBaseEdit = copyNodes(lBaseEdit);
	lSuccess = handleResult(lBaseEdit.childNodes[0]);
	if (lSuccess)
	{
		lData = lBaseEdit.childNodes[1];
		var td = document.getElementById("paymentSelect");
		for (lCount = 0; lCount < lData.childNodes.length; lCount++)
		{
			for (var lAttributeCount = 0; lAttributeCount < lData.childNodes[lCount].attributes.length; lAttributeCount++)
			{
				var lAttribute = lData.childNodes[lCount].attributes[lAttributeCount];
				//alert("lAttribute: " + lAttribute);
				if (!isNodeNull(lAttribute))
				{					
					if (lAttribute.nodeName == "pmtmstpaymentmodeid")
					{
						lValue = lAttribute.value;
					}
					else if (lAttribute.nodeName == "orgpgmappaymodedisplayname")
					{
						lDisplayText = Url.decode(lAttribute.value);
					}
					else if (lAttribute.nodeName == "pmtmstpaymentmodename" && (lDisplayText == null || lDisplayText == ""))
					{
						lDisplayText = Url.decode(lAttribute.value);
					}
					else if (lAttribute.nodeName == "pmtmstpaymentmodecode")
					{
						lPaymentCode = lAttribute.value;
					}
				}
			}
			lTextElement = document.createTextNode(lDisplayText);
			var lTable = document.createElement("TABLE");
			lTable.setAttribute("width","100%");
			lTable.setAttribute("cellSpacing","0");
			lTable.setAttribute("cellPadding","0");
			lTable.setAttribute("border","0");
			var lTBody = document.createElement("TBODY");
			var lTR = document.createElement("TR");
			var lTD = document.createElement("TD");
			lTD.setAttribute("width","5%");
			lTD.setAttribute("vAlign","top");
			if(lCount == 0)		
				lElement = gDOM.createNewElement("input", [{name:"type",value:"radio"}, {name:"name",value:"gcshppaypaymentmodeid"}, {name:"value",value:lValue}, {name:"checked",value:true}]);
			else
				lElement = gDOM.createNewElement("input", [{name:"type",value:"radio"}, {name:"name",value:"gcshppaypaymentmodeid"}, {name:"value",value:lValue}]);
         	lBreakElement = document.createElement("BR");
			lTD.appendChild(lElement);
			lTR.appendChild(lTD);
			var lTD = document.createElement("TD");
			lTD.setAttribute("vAlign","top");
			lTD.setAttribute("width","95%");
			lTD.innerHTML= lDisplayText;
			lTR.appendChild(lTD);
			lTBody.appendChild(lTR);
			lTable.appendChild(lTBody);
			td.appendChild(lBreakElement);
			td.appendChild(lTable);
		}
	}
}
 



 function displayPaymentOptionsforonlineGc(pXMLObject)
{
	var lXMLResponse;
	var lBaseEdit;
	var lData;
	var lCount;
	var lSuccess;
	var lValue;
	var lDisplayText;
	var lElement;
	var lTextElement;
	var lBreakElement;
	var lPaymentCode;
	lXMLResponse = pXMLObject.responseXML;
	lBaseEdit = lXMLResponse.documentElement;
	lBaseEdit = copyNodes(lBaseEdit);
	lSuccess = handleResult(lBaseEdit.childNodes[0]);
	if (lSuccess)
	{
		lData = lBaseEdit.childNodes[1];
		var td = document.getElementById("paymentSelect");
		for (lCount = 0; lCount < lData.childNodes.length; lCount++)
		{
			for (var lAttributeCount = 0; lAttributeCount < lData.childNodes[lCount].attributes.length; lAttributeCount++)
			{
				var lAttribute = lData.childNodes[lCount].attributes[lAttributeCount];
				//alert("lAttribute: " + lAttribute);
				if (!isNodeNull(lAttribute))
				{					
					if (lAttribute.nodeName == "pmtmstpaymentmodeid")
					{
						lValue = lAttribute.value;
					}
					else if (lAttribute.nodeName == "orgpgmappaymodedisplayname")
					{
						lDisplayText = Url.decode(lAttribute.value);
					}
					else if (lAttribute.nodeName == "pmtmstpaymentmodename" && (lDisplayText == null || lDisplayText == ""))
					{
						lDisplayText = Url.decode(lAttribute.value);
					}
					else if (lAttribute.nodeName == "pmtmstpaymentmodecode")
					{
						lPaymentCode = lAttribute.value;
					}
				}
			}
			lTextElement = document.createTextNode(lDisplayText);
			var lTable = document.createElement("TABLE");
			lTable.setAttribute("width","100%");
			lTable.setAttribute("cellSpacing","0");
			lTable.setAttribute("cellPadding","0");
			lTable.setAttribute("border","0");
			var lTBody = document.createElement("TBODY");
			var lTR = document.createElement("TR");
			var lTD = document.createElement("TD");
			lTD.setAttribute("width","5%");
			lTD.setAttribute("vAlign","top");
			if(lCount == 0)		
				lElement = gDOM.createNewElement("input", [{name:"type",value:"radio"}, {name:"name",value:"gcdopaymentmodeid"}, {name:"value",value:lValue}, {name:"checked",value:true}]);
			else
				lElement = gDOM.createNewElement("input", [{name:"type",value:"radio"}, {name:"name",value:"gcdopaymentmodeid"}, {name:"value",value:lValue}]);
			lBreakElement = document.createElement("BR");
			lTD.appendChild(lElement);
			lTR.appendChild(lTD);
			var lTD = document.createElement("TD");
			lTD.setAttribute("vAlign","top");
			lTD.setAttribute("width","95%");
			lTD.innerHTML= lDisplayText;
			lTR.appendChild(lTD);
			lTBody.appendChild(lTR);
			lTable.appendChild(lTBody);
			td.appendChild(lBreakElement);
			td.appendChild(lTable);
		}
	}
}
function showGcConfirmView()
{
	var lViewElement;
	var lRoot;
	var lRequest;
	
	lViewElement = gCache.get(gEntityConfig.CurrentEntity + "VIEW");
	lViewElement = null;
	if (lViewElement == null)
	{
		var lEntity='giftcertificates';
		var	lEntityConfig = eval("entityConfiguration." + lEntity);
		showOnlyEntity(lEntity);
		var lRegularViewTemplate = lEntityConfig.viewTemplate;
       lEntityConfig.viewTemplate=lEntityConfig.viewConfirmTemplate;	
	   //alert('       lEntityConfig.viewTemplate'+       lEntityConfig.viewTemplate);

		var lAJAXInteraction = new AJAXInteraction(lEntityConfig.viewTemplate, null, true);
		lRequest = lAJAXInteraction.doPost("LK=" + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lRoot = copyNodes(lRoot);
		lViewElement = lRoot.childNodes[1];
		gCache.add(gCurrentEntity + "VIEW", lViewElement);
		  //alert('lViewElement'+lViewElement);
		lEntityConfig.viewTemplate = lRegularViewTemplate;
	}
//	cancelGiftWrapper();
	clearDIV("AddEdit");
	lAddEdit = document.getElementById("AddEdit");
	lAddEdit.appendChild(lViewElement);
	//alert(lEntityConfig.URLForSCCourierPaymentPreEdit+'lEntityConfig.URLForSCCourierPaymentPreEdit');
    submitForm(document.AddEdit, gEntityConfig.URLForOfflineGcPreEdit, "POST", showView, gLoginKey, null);
	submitForm(document.AddEdit, gEntityConfig.URLForEntityPreEdit, "POST", showGCView, gLoginKey, null);
	submitForm(document.AddEdit, lEntityConfig.URLForSCCourierPaymentPreEdit, "POST", showView, gLoginKey, null);	
	
	//gEditCartFromConfirm = false;
	//gCartOnConfirm = true;
	//displayCartDetails(gCartXMLObject);
	//showEntityViewGCert();
	//submitForm(document.VIEWCART,lEntityConfig.URLForEntityCartSave, "POST", displayCartDetails, gLoginKey, null);
	//document.getElementById("CartAddEdit").style.display = "block";
	//return true;
}
function placeonlinegcOrder(sessionId,orgId,custId)
{
		var lEntity='giftcertificatesonline';
		var	lEntityConfig = eval("entityConfiguration." + lEntity);	
		submitForm(document.AddEdit,lEntityConfig.URLForEntityOrderSave+'?sessionID='+sessionId+'&orgid='+orgId+'&custid='+custId, "POST", handleGcOnlineOrderSave, gLoginKey, null);
		//return true;
}
function placeofflinegcOrder(custId)
{
		var lEntity='giftcertificates';
		var	lEntityConfig = eval("entityConfiguration." + lEntity);	
		submitForm(document.AddEdit,lEntityConfig.URLForEntityOrderSave+'?custid='+custId, "POST", handleGcOfflineOrderSave, gLoginKey, null);
		//return true;
}
function handleGcOnlineOrderSave(pXMLObject)
{
	var lXMLResponse;
	var lRoot;
	var lStatus;
	var lResult;
	var lStatus;
	var lResponse;
	var lCount;
	var lFocusField;
	var lCount;
	var lSuccess;
	var lValue;
	lXMLResponse = pXMLObject.responseXML;
	lBaseEdit = lXMLResponse.documentElement;
	lBaseEdit = copyNodes(lBaseEdit);
	lSuccess = handleResult(lBaseEdit.childNodes[0]);
	if (lSuccess)
	{
		//alert("....inside...2.");
		lData = lBaseEdit.childNodes[1];
		//alert("in courier display: " + lData.childNodes.length);
		if(lData.childNodes[0].getAttribute("GATEWAY_URL")!= null && lData.childNodes[0].getAttribute("GATEWAY_URL") != "")
		{
			//alert('come over here');
			lAttribute = Url.decode(lData.childNodes[0].getAttribute("GATEWAY_URL"));
			document.Redirect.action = lAttribute;
			document.Redirect.method = "POST";
			document.Redirect.submit();
		}
		else
		{		
			var lEntity='giftcertificatesonline';
			var	lEntityConfig = eval("entityConfiguration." + lEntity);
			var lRegularAddEdit = lEntityConfig.addEditTemplate
			lEntityConfig.addEditTemplate=lEntityConfig.orderPlaceTemplate;
			showOnlyEntity(lEntity);
			document.getElementById("CartAddEdit").style.display = "none";


			var lAddEditElement;
			var lRoot;
			var lRequest;
			//lAddEditElement = gCache.get(gCurrentEntity + "ADDEDIT");
			lAddEditElement = null;
			if (lAddEditElement == null)
			{
				var lAJAXInteraction = new AJAXInteraction(gCurrentAddEditTemplate, null, true);
				lRequest = lAJAXInteraction.doPost("LK=" + gLoginKey);
				lXMLResponse = lRequest.responseXML;
				lRoot = lXMLResponse.documentElement;
				lRoot = copyNodes(lRoot);
				lAddEditElement = lRoot.childNodes[1];
				lEntityConfig.addEditTemplate = lRegularAddEdit;
				//gCache.add(gCurrentEntity + "ADDEDIT", lAddEditElement);
			}
			clearDIV("AddEdit");
			lAddEdit = document.getElementById("AddEdit");
			lAddEdit.appendChild(lAddEditElement);
			showView(pXMLObject);
		}

	}
}

function showGCView(pXMLObject)
{
	var lXMLResponse;
	var lBaseEdit;
	var lEntity;
	var lData;
	var lLists;
	var lChildren;
	var lCount;
	var lSuccess;
	lXMLResponse = pXMLObject.responseXML;
	lBaseEdit = lXMLResponse.documentElement;
	lBaseEdit = copyNodes(lBaseEdit);
	lSuccess = handleResult(lBaseEdit.childNodes[0]);
	if (lSuccess)
	{
		lChildren = lBaseEdit.childNodes;
		lLists = null;
		for (lCount = 1; lCount < lChildren.length; lCount++)
		{
			if (!isNodeNull(lChildren[lCount]))
			{
					if (lChildren[lCount].nodeName == "DATA")
				{
						lData = lChildren[lCount];
				}
				else if (lChildren[lCount].nodeName == "LISTS")
				{
					lLists = parseLists(lChildren[lCount]);
				}
			}
		}
		for (lCount = 0; lCount < lData.childNodes.length; lCount++)
		{
			fillView(lData.childNodes[lCount]);
		}
		if (gEntityConfig.postView != null)
		{
			eval (gEntityConfig.postView + "(pXMLObject)");
		}

		if(document.getElementById("blgadd") != null)
		{
			document.getElementById("blgadd").innerHTML = getFormattedNameAddress("blgadd");
			var lShippingAddrLn1 = document.getElementById('shpaddln1').textContent?document.getElementById('shpaddln1').textContent:document.getElementById('shpaddln1').value;

			if(lShippingAddrLn1 != null && lShippingAddrLn1 != "")
				document.getElementById("shpadd").innerHTML = getFormattedNameAddress("shpadd");
			else
				document.getElementById("shpadd").innerHTML = getFormattedNameAddress("blgadd");
			if(document.getElementById("trackingUrlLink") != null)
				document.getElementById("trackingUrlLink").href=(document.getElementById("couriermstrtrackingurl").textContent)?document.getElementById("couriermstrtrackingurl").textContent:document.getElementById("couriermstrtrackingurl").value;
		}else if(document.getElementById("requesterName") != null)
		{
			document.getElementById("requesterName").innerHTML = getFormattedRequesterName();
			document.getElementById("requesterAddress").innerHTML = getFormattedRequesterAddress();
			clearDIV("Listing");
			document.getElementById("RequestListingButtons").style.display="none";
		}
	}
}
function getFormattedNameAddress(pAddress)
{
	var lSalutation = (document.getElementById(pAddress + 'salsalutation').textContent)?document.getElementById(pAddress + 'salsalutation').textContent:document.getElementById(pAddress + 'salsalutation').value;
	var lFirst = document.getElementById(pAddress + 'firstname').textContent?document.getElementById(pAddress + 'firstname').textContent:document.getElementById(pAddress + 'firstname').value;
	var lMiddle = document.getElementById(pAddress + 'middlename').textContent?document.getElementById(pAddress + 'middlename').textContent:document.getElementById(pAddress + 'middlename').value;
	var lLast = document.getElementById(pAddress + 'lastname').textContent?document.getElementById(pAddress + 'lastname').textContent:document.getElementById(pAddress + 'lastname').value;
	var lAddr1 = document.getElementById(pAddress + 'ln1').textContent?document.getElementById(pAddress + 'ln1').textContent:document.getElementById(pAddress + 'ln1').value;
	var lAddr2 = document.getElementById(pAddress + 'ln2').textContent?document.getElementById(pAddress + 'ln2').textContent:document.getElementById(pAddress + 'ln2').value;
	var lCity = document.getElementById(pAddress + 'city').textContent?document.getElementById(pAddress + 'city').textContent:document.getElementById(pAddress + 'city').value;
	var lZip = document.getElementById(pAddress + 'zipcode').textContent?document.getElementById(pAddress + 'zipcode').textContent:document.getElementById(pAddress + 'zipcode').value;
	var lState = document.getElementById(pAddress + 'state').textContent?document.getElementById(pAddress + 'state').textContent:document.getElementById(pAddress + 'state').value;
	var lCountry = document.getElementById(pAddress + 'country').textContent?document.getElementById(pAddress + 'country').textContent:document.getElementById(pAddress + 'country').value;

	var lFormattedAddress = lSalutation + " " + lFirst + " ";
	if(lMiddle != null && lMiddle != "")
	{
		lFormattedAddress += lMiddle + " ";
	}
	lFormattedAddress += lLast + ",<br>";
	lFormattedAddress += lAddr1 + ",<br>";
	if(lAddr2 != null && lAddr2 != "")
	{
		lFormattedAddress += lAddr2 + ",<br>";
	}
	lFormattedAddress += lCity + ", " + lZip + "<br>";
	lFormattedAddress += lState + "<br>";
	lFormattedAddress += lCountry + "<br>";
	return lFormattedAddress;
}
function handleGcOfflineOrderSave(pXMLObject)
{
	var lXMLResponse;
	var lRoot;
	var lStatus;
	var lResult;
	var lStatus;
	var lResponse;
	var lCount;
	var lFocusField;
	var lCount;
	var lSuccess;
	var lValue;
	lXMLResponse = pXMLObject.responseXML;
	lBaseEdit = lXMLResponse.documentElement;
	lBaseEdit = copyNodes(lBaseEdit);
	lSuccess = handleResult(lBaseEdit.childNodes[0]);
	if (lSuccess)
	{
		//alert("....inside...2.");
		lData = lBaseEdit.childNodes[1];
		//alert("in courier display: " + lData.childNodes.length);
		if(lData.childNodes[0].getAttribute("GATEWAY_URL")!= null && lData.childNodes[0].getAttribute("GATEWAY_URL") != "")
		{
			//alert('come over here');
			lAttribute = Url.decode(lData.childNodes[0].getAttribute("GATEWAY_URL"));
			document.Redirect.action = lAttribute;
			document.Redirect.method = "POST";
			document.Redirect.submit();
		}
		else
		{		
			var lEntity='giftcertificates';
			var	lEntityConfig = eval("entityConfiguration." + lEntity);
			var lRegularAddEdit = lEntityConfig.addEditTemplate
			lEntityConfig.addEditTemplate=lEntityConfig.orderPlaceTemplate;
			showOnlyEntity(lEntity);
			document.getElementById("CartAddEdit").style.display = "none";


			var lAddEditElement;
			var lRoot;
			var lRequest;
			//lAddEditElement = gCache.get(gCurrentEntity + "ADDEDIT");
			lAddEditElement = null;
			if (lAddEditElement == null)
			{
				var lAJAXInteraction = new AJAXInteraction(gCurrentAddEditTemplate, null, true);
				lRequest = lAJAXInteraction.doPost("LK=" + gLoginKey);
				lXMLResponse = lRequest.responseXML;
				lRoot = lXMLResponse.documentElement;
				lRoot = copyNodes(lRoot);
				lAddEditElement = lRoot.childNodes[1];
				lEntityConfig.addEditTemplate = lRegularAddEdit;
				//gCache.add(gCurrentEntity + "ADDEDIT", lAddEditElement);
			}
			clearDIV("AddEdit");
			lAddEdit = document.getElementById("AddEdit");
			lAddEdit.appendChild(lAddEditElement);
			showView(pXMLObject);
		}

	}
}
function handleSaveCourierPaymentforGc(pXMLObject)
{
	var lXMLResponse;
	var lRoot;
	var lResult;
	var lSuccess;
	lXMLResponse = pXMLObject.responseXML;
	lRoot = lXMLResponse.documentElement;
	lRoot = copyNodes(lRoot);
	lResult = lRoot.childNodes[0];
	lSuccess = handleResult(lResult, "AddEdit");
	if (lSuccess)
	{
		showGcConfirmView();
	}

}
function showGatewayReturnforOnlineGc()
{
	var lEntity='giftcertificatesonline';
	var	lEntityConfig = eval("entityConfiguration." + lEntity);
	var lRegularAddEdit = lEntityConfig.addEditTemplate
	lEntityConfig.addEditTemplate=lEntityConfig.orderPlaceTemplate;
	showOnlyEntity(lEntity);

	var lAddEditElement;
	var lRoot;
	var lRequest;
	//lAddEditElement = gCache.get(gCurrentEntity + "ADDEDIT");
	lAddEditElement = null;
	if (lAddEditElement == null)
	{
		var lAJAXInteraction = new AJAXInteraction(gCurrentAddEditTemplate, null, true);
		lRequest = lAJAXInteraction.doPost("LK=" + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lRoot = copyNodes(lRoot);
		lAddEditElement = lRoot.childNodes[1];
		lEntityConfig.addEditTemplate = lRegularAddEdit;
		//gCache.add(gCurrentEntity + "ADDEDIT", lAddEditElement);
	}
	clearDIV("AddEdit");
	lAddEdit = document.getElementById("AddEdit");
	lAddEdit.appendChild(lAddEditElement);
	submitForm(document.ReturnPG,lEntityConfig.URLForGatewayReturn, "POST", showView, gLoginKey, null);
}

function showGatewayReturnforOfflineGc()
{
	var lEntity='giftcertificates';
	var	lEntityConfig = eval("entityConfiguration." + lEntity);
	var lRegularAddEdit = lEntityConfig.addEditTemplate
	lEntityConfig.addEditTemplate=lEntityConfig.orderPlaceTemplate;
	showOnlyEntity(lEntity);

	var lAddEditElement;
	var lRoot;
	var lRequest;
	//lAddEditElement = gCache.get(gCurrentEntity + "ADDEDIT");
	lAddEditElement = null;
	if (lAddEditElement == null)
	{
		var lAJAXInteraction = new AJAXInteraction(gCurrentAddEditTemplate, null, true);
		lRequest = lAJAXInteraction.doPost("LK=" + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lRoot = copyNodes(lRoot);
		lAddEditElement = lRoot.childNodes[1];
		lEntityConfig.addEditTemplate = lRegularAddEdit;
		//gCache.add(gCurrentEntity + "ADDEDIT", lAddEditElement);
	}
	clearDIV("AddEdit");
	lAddEdit = document.getElementById("AddEdit");
	lAddEdit.appendChild(lAddEditElement);
	submitForm(document.ReturnPG,lEntityConfig.URLForGatewayReturn, "POST", showView, gLoginKey, null);
}
function backFromAddressforGc()
{
	//displayforGc();
	getGcForm();
	document.getElementById('CartAddEdit').style.display = 'block';
}

function displayforGc()
{
	//alert("Inside display");
	clearDIV("AddEdit");
	clearDIV("Listing");
	var lEntity='giftcertificates';
	var	lEntityConfig = eval("entityConfiguration." + lEntity);
	showOnlyEntity(lEntity);
	showEntityViewGCert();
	submitForm(document.VIEWCART,lEntityConfig.URLForEntityCartSave, "POST", displayCartDetails, gLoginKey, null);
}
function showEntityViewGCert()
{
	//alert('inside ->showEntityAddEdit');
	var lAddEditElement;
	var lRoot;
	var lAddEditElement;
	var lRequest;
	//lAddEditElement = gCache.get(gCurrentEntity + "ADDEDIT");
	lAddEditElement = null;

	if (lAddEditElement == null)
	{
		//alert("inide showEntityViewCart "+gCurrentViewTemplate);
		var lAJAXInteraction = new AJAXInteraction(gCurrentViewTemplate, null, true);
		lRequest = lAJAXInteraction.doPost("LK=" + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lRoot = copyNodes(lRoot);
		lAddEditElement = lRoot.childNodes[1];
		//gCache.add(gCurrentEntity + "ADDEDIT", lAddEditElement);
	}
	//alert("itemID 1: " + document.VIEWCART.itemID);
	clearDIV("CartAddEdit");
	//alert("itemID 2: " + document.VIEWCART.itemID);
	lAddEdit = document.getElementById("CartAddEdit");
	lAddEdit.appendChild(lAddEditElement);
}

function shipDisable(chkShip)
{
	//alert("Inside shipDisable() ");
	if(document.all)
	{
		//alert(chkShip.checked);
		if(chkShip.checked)
		{
			document.getElementById("shipBill").value=1;
			document.getElementById("shipAddDiv").style.display="none";
		}
		else
		{
			document.getElementById("shipBill").value=0;
			document.getElementById("shipAddDiv").style.display="block";
		}
		//alert(document.getElementById("shipBill").value);
		/*document.getElementById("Prefix").disabled=chkShip.checked;
		document.getElementById("Fname").disabled=chkShip.checked;
		document.getElementById("Mname").disabled=chkShip.checked;
		document.getElementById("Lname").disabled=chkShip.checked;
		document.getElementById("Contact").disabled=chkShip.checked;
		document.getElementById("Add1").disabled=chkShip.checked;
		document.getElementById("Add2").disabled=chkShip.checked;
		document.getElementById("City").disabled=chkShip.checked;
		document.getElementById("State").disabled=chkShip.checked;
		document.getElementById("Country").disabled=chkShip.checked;
		document.getElementById("ZipC").disabled=chkShip.checked;*/
		
	}else
	{

		if(document.getElementById("shipToBill").checked)
		{
			document.getElementById("shipBill").value=1;
			document.getElementById("shipAddDiv").style.display="none";
		}
		else
		{
			document.getElementById("shipBill").value=0;
			document.getElementById("shipAddDiv").style.display="block";
		}
	//alert(document.getElementById("shipBill").value);
	


		/*document.getElementById("Prefix").disabled=document.getElementById("shipToBill").checked;
		document.getElementById("Fname").disabled=document.getElementById("shipToBill").checked;
		document.getElementById("Mname").disabled=document.getElementById("shipToBill").checked;
		document.getElementById("Lname").disabled=document.getElementById("shipToBill").checked;
		document.getElementById("Contact").disabled=document.getElementById("shipToBill").checked;
		document.getElementById("Add1").disabled=document.getElementById("shipToBill").checked;
		document.getElementById("Add2").disabled=document.getElementById("shipToBill").checked;
		document.getElementById("City").disabled=document.getElementById("shipToBill").checked;
		document.getElementById("State").disabled=document.getElementById("shipToBill").checked;
		document.getElementById("Country").disabled=document.getElementById("shipToBill").checked;
		document.getElementById("ZipC").disabled=document.getElementById("shipToBill").checked;*/
	
	}
}

function disableCtrlKeyCombination(e)
{
        //list all CTRL + key combinations you want to disable
        var forbiddenKeys = new Array('a', 'n', 'c', 'x', 'v', 'j');
        var key;
        var isCtrl;

        if(window.event)
        {
                key = window.event.keyCode;     //IE
                if(window.event.ctrlKey)
                        isCtrl = true;
                else
                        isCtrl = false;
        }
        else
        {
                key = e.which;     //firefox
                if(e.ctrlKey)
                        isCtrl = true;
                else
                        isCtrl = false;
        }

        //if ctrl is pressed check if other key is in forbidenKeys array
        if(isCtrl)
        {
                for(i=0; i<forbiddenKeys.length; i++)
                {
                        //case-insensitive comparation
                        if(forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase())
                        {
                                alert('Key combination CTRL + '
                                        +String.fromCharCode(key)
                                        +' has been disabled.');
                                return false;
                        }
                }
        }
        return true;
}

function ShowCourier()
{

	var lEntity='giftcertificates';
	var	lEntityConfig = eval("entityConfiguration." + lEntity);	
	
	showOnlyEntity(lEntity);
	lEntityConfig.URLForEntitySave =lEntityConfig.URLForEntityCourierSave;
	//alert("itemID: " + document.VIEWCART.itemID.value);
//	showEntityAddEdit();
	//alert("itemID: " + document.VIEWCART.itemID);
	//showEntityCourier();
	submitForm(document.AddEdit,lEntityConfig.URLForEntitySave, "POST", displayStaticCouriers, gLoginKey, null);
	
}


function displayStaticCouriers(pXMLObject)
{
	informationXMLObject = pXMLObject;

	 openWindow = window.open('/dotcom/oxford/GiftCertificates/jsp/information.html','openWindow2','height=600,width=800,left=70,top=70,resizable=yes,scrollbars=yes,status=yes');
//   alert(openWindow.document);
   timer = window.setTimeout('popUpInformationListing()', 1000);
		
}
function popUpInformationListing()
{

		gCartXMLObject = informationXMLObject;
		lXMLResponse = informationXMLObject.responseXML;
		lRoot = lXMLResponse.documentElement;
		var responseDoc = informationXMLObject.responseXML; 	
		var root = responseDoc.documentElement;		
		var docs = responseDoc.getElementsByTagName("DOMESTIC");
		var getTD = openWindow.document.getElementById("CourierTR");
		//alert(getTD);
		var mainDIV = openWindow.document.createElement("DIV");
		mainDIV.className = "minwidth";

		var outerTable = openWindow.document.createElement("TABLE");
		var outerTbody = openWindow.document.createElement("TBODY");
		outerTable.setAttribute("border",0);
		outerTable.setAttribute("width","100%");
		outerTable.setAttribute("cellSpacing","0");
		outerTable.setAttribute("cellPadding","0");
		outerTable.className = "popup_borderthreesides";
		
		var trOuter = openWindow.document.createElement("TR");
		var tdOuter = openWindow.document.createElement("TD");
		var headerTable = openWindow.document.createElement("TABLE");
		var headerTbody = openWindow.document.createElement("TBODY");
		headerTable.setAttribute("border",0);
		headerTable.setAttribute("width","100%");
		headerTable.setAttribute("cellSpacing","0");
		headerTable.setAttribute("cellPadding","0");
		headerTable.setAttribute("height","26");
		headerTable.className = "sc_headerbg";
		var trHeader = openWindow.document.createElement("TR");
		var td= openWindow.document.createElement("TD");
		td.className = "headertext";
		var text5 = openWindow.document.createTextNode(FIELD_SHIPPING_CHARGES);
		td.appendChild(text5);
		trHeader.appendChild(td);
		headerTbody.appendChild(trHeader);
		headerTable.appendChild(headerTbody);
		tdOuter.appendChild(headerTable);		
		trOuter.appendChild(tdOuter);	
		outerTbody.appendChild(trOuter);

		//alert(docs.length);
		if(docs.length && docs.length > 0)
			{
				var trOuter = openWindow.document.createElement("TR");
				var tdOuter = openWindow.document.createElement("TD");
				var headerTable = openWindow.document.createElement("TABLE");
				var headerTbody = openWindow.document.createElement("TBODY");
				headerTable.setAttribute("border",0);
				headerTable.setAttribute("width","96%");
				headerTable.setAttribute("cellSpacing","0");
				headerTable.setAttribute("cellPadding","0");
				headerTable.setAttribute("align","center");
				headerTable.className = "sc_subheading";
				var trHeader = openWindow.document.createElement("TR");
				var td= openWindow.document.createElement("TD");
				var text5 = openWindow.document.createTextNode(FIELD_DOM_SHIP_CHARGES);
				td.appendChild(text5);
				trHeader.appendChild(td);
				headerTbody.appendChild(trHeader);
				headerTable.appendChild(headerTbody);
				tdOuter.appendChild(headerTable);		
				trOuter.appendChild(tdOuter);	
				outerTbody.appendChild(trOuter);	
				
				//alert("No of Domestic couriers"+docs.length);
				var Name = new Array();
				var StartWeight = new Array();
				var StartAmt = new Array();
				var ExtraAmt = new Array();
				var ExtraWeight = new Array();
				
				//alert("getTD: " + getTD);
				var trOuter = openWindow.document.createElement("TR");
				var tdOuter = openWindow.document.createElement("TD");
				var mainTable = openWindow.document.createElement("TABLE");
				var mainTbody = openWindow.document.createElement("TBODY");
				mainTable.setAttribute("border",1);
				mainTable.setAttribute("width","96%");
				//mainTable.setAttribute("height","87");
				mainTable.setAttribute("align","center");
				mainTable.setAttribute("cellPadding","0");
				mainTable.setAttribute("cellSpacing","0");
				mainTable.setAttribute("borderColor","#cccccc");
				mainTable.className = "borderallsides";

				var trHead1 = openWindow.document.createElement("TR");
				trHead1.setAttribute("align","left");
				trHead1.setAttribute("height","26");
				trHead1.className = "sc_searchresultsheader";
				var td= openWindow.document.createElement("TD");
				td.setAttribute("align","center");
				var text5 = openWindow.document.createTextNode(FIELD_OPTION);
				td.appendChild(text5);
				trHead1.appendChild(td);

				var td= openWindow.document.createElement("TD");
				td.setAttribute("align","center");
				var text5 = openWindow.document.createTextNode(FIELD_START_WEIGHT);
				td.appendChild(text5);
				trHead1.appendChild(td);
				
				var td= openWindow.document.createElement("TD");
				td.setAttribute("align","center");
				var text5 = openWindow.document.createTextNode(FIELD_START_AMT);
				td.appendChild(text5);
				trHead1.appendChild(td);

				var td= openWindow.document.createElement("TD");
				td.setAttribute("align","center");
				var text5 = openWindow.document.createTextNode(FIELD_ADD_WEIGHT);
				td.appendChild(text5);
				trHead1.appendChild(td);

				var td= openWindow.document.createElement("TD");
				td.setAttribute("align","center");
				var text5 = openWindow.document.createTextNode(FIELD_ADD_AMT);
				td.appendChild(text5);
				trHead1.appendChild(td);

				mainTbody.appendChild(trHead1);				
				//getTD.appendChild(mainTable);

				fields = docs[0].getElementsByTagName("COURIER");
					//var table = document.getElementById("CourierTR");
					//table.setAttribute("BORDER",1);
					//	var ptr = document.createElement("TR");
				// var table = document.createElement("TABLE");
				for(fieldCount=0;fieldCount<fields.length;fieldCount++)
				{
					Name[fieldCount] = fields[fieldCount].getAttribute("Name");
					StartWeight[fieldCount] = fields[fieldCount].getAttribute("StartWeight");
					StartAmt[fieldCount] = fields[fieldCount].getAttribute("StartAmt");
					ExtraAmt[fieldCount] = fields[fieldCount].getAttribute("ExtraAmt");
					ExtraWeight[fieldCount] = fields[fieldCount].getAttribute("ExtraWeight");
				

					var tr0 =openWindow.document.createElement("TR");
					//alert(fieldCount%2);
					if(fieldCount%2 == 0)
						tr0.className="sc_oddrow"
					else
						tr0.className="sc_evenrow"
					var tdName = openWindow.document.createElement("TD");
					tdName.setAttribute("align","center");
					var thName = openWindow.document.createTextNode(Name[fieldCount]);
					tdName.appendChild(thName);
					tr0.appendChild(tdName);

					var tdSWeight = openWindow.document.createElement("TD");
					tdSWeight.setAttribute("align","center");
					var thSWeight = openWindow.document.createTextNode(StartWeight[fieldCount]);
					tdSWeight.appendChild(thSWeight);
					tr0.appendChild(tdSWeight);

					var tdSAmt = openWindow.document.createElement("TD");
					tdSAmt.setAttribute("align","center");
					var thSAmt = openWindow.document.createTextNode(StartAmt[fieldCount]);
					tdSAmt.appendChild(thSAmt);
					tr0.appendChild(tdSAmt);

					var tdEWeight = openWindow.document.createElement("TD");
					tdEWeight.setAttribute("align","center");
					var thEWeight = openWindow.document.createTextNode(ExtraWeight[fieldCount]);
					tdEWeight.appendChild(thEWeight);
					tr0.appendChild(tdEWeight);

					var tdEAmt = openWindow.document.createElement("TD");
					tdEAmt.setAttribute("align","center");
					var thEAmt = openWindow.document.createTextNode(ExtraAmt[fieldCount]);
					tdEAmt.appendChild(thEAmt);
					tr0.appendChild(tdEAmt);

					mainTbody.appendChild(tr0);

				}				
				
				mainTable.appendChild(mainTbody);
				tdOuter.appendChild(mainTable);		
				trOuter.appendChild(tdOuter);	
				outerTbody.appendChild(trOuter);	
			}

			var trOuter = openWindow.document.createElement("TR");
			var tdOuter = openWindow.document.createElement("TD");
			var text =  openWindow.document.createElement("BR");
			tdOuter.appendChild(text);	
			trOuter.appendChild(tdOuter);	
			outerTbody.appendChild(trOuter);


			var docIntern = responseDoc.getElementsByTagName("INTERNATIONAL");
			if(docIntern.length && docIntern.length > 0)
			{
				var trOuter = openWindow.document.createElement("TR");
				var tdOuter = openWindow.document.createElement("TD");
				var headerTable = openWindow.document.createElement("TABLE");
				var headerTbody = openWindow.document.createElement("TBODY");
				headerTable.setAttribute("border",0);
				headerTable.setAttribute("width","96%");
				headerTable.setAttribute("cellSpacing","0");
				headerTable.setAttribute("cellPadding","0");
				headerTable.setAttribute("align","center");
				headerTable.className = "sc_subheading";
				var trHeader = openWindow.document.createElement("TR");
				var td= openWindow.document.createElement("TD");
				var text5 = openWindow.document.createTextNode(FIELD_IN_SHIP_CHARGES);
				td.appendChild(text5);
				trHeader.appendChild(td);
				headerTbody.appendChild(trHeader);
				headerTable.appendChild(headerTbody);
				tdOuter.appendChild(headerTable);		
				trOuter.appendChild(tdOuter);	
				outerTbody.appendChild(trOuter);	

				//alert("No of Domestic couriers"+docs.length);
				var Name = new Array();
				var StartWeight = new Array();
				var StartAmt = new Array();
				var ExtraAmt = new Array();
				var ExtraWeight = new Array();

				var trOuter = openWindow.document.createElement("TR");
				var tdOuter = openWindow.document.createElement("TD");
				var courierTable = openWindow.document.createElement("TABLE");
				var courierTBody = openWindow.document.createElement("TBODY");
				courierTable.setAttribute("border",1);
				courierTable.setAttribute("width","96%");
				//courierTable.setAttribute("height","87");
				courierTable.setAttribute("align","center");
				courierTable.setAttribute("cellPadding","0");
				courierTable.setAttribute("cellSpacing","0");
				courierTable.setAttribute("borderColor","#cccccc");
				courierTable.className = "borderallsides";

				var trHead1 = openWindow.document.createElement("TR");
				trHead1.setAttribute("align","left");
				trHead1.setAttribute("height","26");
				trHead1.className = "sc_searchresultsheader";
				var td= openWindow.document.createElement("TD");
				td.setAttribute("align","center");
				var text5 = openWindow.document.createTextNode(FIELD_OPTION);
				td.appendChild(text5);
				trHead1.appendChild(td);

				var td= openWindow.document.createElement("TD");
				td.setAttribute("align","center");
				var text5 = openWindow.document.createTextNode(FIELD_ZONE);
				td.appendChild(text5);
				trHead1.appendChild(td);

				var td= openWindow.document.createElement("TD");
				td.setAttribute("align","center");
				var text5 = openWindow.document.createTextNode(FIELD_START_WEIGHT);
				td.appendChild(text5);
				trHead1.appendChild(td);
				
				var td= openWindow.document.createElement("TD");
				td.setAttribute("align","center");
				var text5 = openWindow.document.createTextNode(FIELD_START_AMT);
				td.appendChild(text5);
				trHead1.appendChild(td);

				var td= openWindow.document.createElement("TD");
				td.setAttribute("align","center");
				var text5 = openWindow.document.createTextNode(FIELD_ADD_WEIGHT);
				td.appendChild(text5);
				trHead1.appendChild(td);

				var td= openWindow.document.createElement("TD");
				td.setAttribute("align","center");
				var text5 = openWindow.document.createTextNode(FIELD_ADD_AMT);
				td.appendChild(text5);
				trHead1.appendChild(td);

				courierTBody.appendChild(trHead1);

				var docCouriers = docIntern[0].getElementsByTagName("COURIER");
				var noOfCouriers = docCouriers.length;
				var lineCount = 0;
				for(count=0;count<noOfCouriers;count++)
				{
					fields = docCouriers[count].getElementsByTagName("ZONE");
					var noOfCourierZones = fields.length;
					for(var fieldCount=0;fieldCount<noOfCourierZones;fieldCount++)
					{
						lineCount++;
						Name[fieldCount] = fields[fieldCount].getAttribute("Name");
						StartWeight[fieldCount] = fields[fieldCount].getAttribute("StartWeight");
						StartAmt[fieldCount] = fields[fieldCount].getAttribute("StartAmt");
						ExtraAmt[fieldCount] = fields[fieldCount].getAttribute("ExtraAmt");
						ExtraWeight[fieldCount] = fields[fieldCount].getAttribute("ExtraWeight");					

						var tr0 =openWindow.document.createElement("TR");
						if(lineCount%2 == 0)
							tr0.className="sc_evenrow";
						else
							tr0.className="sc_oddrow";

						var tdService = openWindow.document.createElement("TD");
						tdService.setAttribute("align","center");
						var thService = openWindow.document.createTextNode(docCouriers[count].getAttribute("Name"));
						tdService.appendChild(thService);
						tr0.appendChild(tdService);

						var tdName = openWindow.document.createElement("TD");
						tdName.setAttribute("align","center");
						var text=openWindow.document.createTextNode(Name[fieldCount]);
						tdName.appendChild(text);
						tr0.appendChild(tdName);

						var tdSWeight = openWindow.document.createElement("TD");
						tdSWeight.setAttribute("align","center");
						var thSWeight = openWindow.document.createTextNode(StartWeight[fieldCount]);
						tdSWeight.appendChild(thSWeight);
						tr0.appendChild(tdSWeight);

						var tdSAmt = openWindow.document.createElement("TD");
						tdSAmt.setAttribute("align","center");
						var thSAmt = openWindow.document.createTextNode(StartAmt[fieldCount]);
						tdSAmt.appendChild(thSAmt);
						tr0.appendChild(tdSAmt);

						var tdEWeight = openWindow.document.createElement("TD");
						tdEWeight.setAttribute("align","center");
						var thEWeight = openWindow.document.createTextNode(ExtraWeight[fieldCount]);
						tdEWeight.appendChild(thEWeight);
						tr0.appendChild(tdEWeight);

						var tdEAmt = openWindow.document.createElement("TD");
						tdEAmt.setAttribute("align","center");
						var thEAmt = openWindow.document.createTextNode(ExtraAmt[fieldCount]);
						tdEAmt.appendChild(thEAmt);
						tr0.appendChild(tdEAmt);

						courierTBody.appendChild(tr0);

					}				
				}
				courierTable.appendChild(courierTBody);
				tdOuter.appendChild(courierTable);		
				trOuter.appendChild(tdOuter);	
				outerTbody.appendChild(trOuter);	
				
				
			}
			var trOuter = openWindow.document.createElement("TR");
			var tdOuter = openWindow.document.createElement("TD");
			var text =  openWindow.document.createElement("BR");
			tdOuter.appendChild(text);	
			trOuter.appendChild(tdOuter);	
			outerTbody.appendChild(trOuter);

//				for(i=0;i<20;i++)
//					{
//						var text =  openWindow.document.createElement("BR");
//						getTD.appendChild(text);
//					}

//for countries

			var docCountries = responseDoc.getElementsByTagName("COUNTRIES");
			if(docCountries.length && docCountries.length > 0)
			{	
				var trOuter = openWindow.document.createElement("TR");
				var tdOuter = openWindow.document.createElement("TD");
				var headerTable = openWindow.document.createElement("TABLE");
				var headerTbody = openWindow.document.createElement("TBODY");
				headerTable.setAttribute("border",0);
				headerTable.setAttribute("width","96%");
				headerTable.setAttribute("cellSpacing","0");
				headerTable.setAttribute("cellPadding","0");
				headerTable.setAttribute("align","center");
				headerTable.className = "sc_subheading";
				var trHeader = openWindow.document.createElement("TR");
				var td= openWindow.document.createElement("TD");
				var text5 = openWindow.document.createTextNode(FIELD_ZONE_DETAILS);
				td.appendChild(text5);
				trHeader.appendChild(td);
				headerTbody.appendChild(trHeader);
				headerTable.appendChild(headerTbody);
				tdOuter.appendChild(headerTable);		
				trOuter.appendChild(tdOuter);	
				outerTbody.appendChild(trOuter);
				
				var trOuter = openWindow.document.createElement("TR");
				var tdOuter = openWindow.document.createElement("TD");
				var zoneTable = openWindow.document.createElement("TABLE");
				var zoneTBody = openWindow.document.createElement("TBODY");
				zoneTable.setAttribute("border",1);
				zoneTable.setAttribute("width","96%");
				//courierTable.setAttribute("height","87");
				zoneTable.setAttribute("align","center");
				zoneTable.setAttribute("cellPadding","0");
				zoneTable.setAttribute("cellSpacing","0");
				zoneTable.setAttribute("borderColor","#cccccc");
				zoneTable.className = "borderallsides";

				var trHead1 = openWindow.document.createElement("TR");
				trHead1.setAttribute("align","left");
				trHead1.setAttribute("height","26");
				trHead1.className = "sc_searchresultsheader";
				var td= openWindow.document.createElement("TD");
				td.setAttribute("align","center");
				var text5 = openWindow.document.createTextNode(FIELD_ZONE);
				td.appendChild(text5);
				trHead1.appendChild(td);

				var td= openWindow.document.createElement("TD");
				td.setAttribute("align","center");
				var text5 = openWindow.document.createTextNode(FIELD_COUNTRIES);
				td.appendChild(text5);
				trHead1.appendChild(td);

				zoneTBody.appendChild(trHead1);

		
				fields = docCountries[0].getElementsByTagName("ZONE");
				noOfDocuments = fields.length;
				for(count=0;count<noOfDocuments;count++)
				{
					var tr0 =openWindow.document.createElement("TR");
					if(count%2 == 0)
						tr0.className="sc_oddrow";
					else
						tr0.className="sc_evenrow";
					var td= openWindow.document.createElement("TD");
					td.setAttribute("align","center");
					td.setAttribute("width","30%");
					//var tName = openWindow.document.createElement("a");
					//tName.setAttribute("name","ZONE "+fields[count].getAttribute("Name"));
					var text5 = openWindow.document.createTextNode(fields[count].getAttribute("Name"));
					td.appendChild(text5);
					tr0.appendChild(td);	

					var td= openWindow.document.createElement("TD");
					td.setAttribute("align","center");
					td.setAttribute("width","70%");
					var countries = "";

					var docCountry = fields[count].getElementsByTagName("COUNTRY");
					var noOfCountries = docCountry.length;
					for(fieldCount=0;fieldCount<noOfCountries;fieldCount++)
					{
						//if(docCountry[fieldCount].getAttribute("Name").substring(0,1) == 'V')
							//alert(docCountry[fieldCount].getAttribute("Name"));
						var fieldName = Url.decode(docCountry[fieldCount].getAttribute("Name"));
						//if(docCountry[fieldCount].getAttribute("Name").substring(0,1) == 'V')
							//alert(fieldName);
						countries += fieldName;
						if(fieldCount < noOfCountries-1) countries += ", ";

					}
					var text5 = openWindow.document.createTextNode(countries);
					td.appendChild(text5);
					tr0.appendChild(td);	
					
					zoneTBody.appendChild(tr0);				
				}
				zoneTable.appendChild(zoneTBody);
				tdOuter.appendChild(zoneTable);		
				trOuter.appendChild(tdOuter);	
				outerTbody.appendChild(trOuter);			

			}

			var trOuter = openWindow.document.createElement("TR");
			var tdOuter = openWindow.document.createElement("TD");
			var text =  openWindow.document.createElement("BR");
			tdOuter.appendChild(text);	
			trOuter.appendChild(tdOuter);	
			outerTbody.appendChild(trOuter);

			outerTable.appendChild(outerTbody);
			mainDIV.appendChild(outerTable);
			getTD.appendChild(mainDIV);
		

}
