
// for 'you are leaving ...'	
addOnClick();

var vEditPanel = document.getElementById("EditPanelTable");

if (vEditPanel == null)
{// not in edit mode    AttachmentPorcess();
    CustomerStoryProcess();
}
else
{// in edit mode
    //alert("Edit Panel is not null");
    CorrectExpiryText();
}

function CorrectExpiryText()
{// for PublishingExpirationDate bug
	var dt = document.getElementById("Publishing_Expiration_Date_TD");
	if (dt != null)
	{    
	    var regExp = />Immediately</g;
	    var oldStr = dt.innerHTML;
	    var newStr = oldStr.replace(regExp, ">Never<");
	    dt.innerHTML = newStr;
	}
}

// for view document section, i.e. attachment
/*
var lblDesc = "<br ><b>Note:</b> There may be links contained within this document which will transfer you from the AusIndustry website. AusIndustry does not have responsibility for these external websites nor does linking constitute any form of endorsement.<br /><br /><b>Note:</b> You need Adobe Acrobat Reader 3.0 or above to view PDF files. You can download a free copy from the <a href=\"http://www.adobe.com/products/acrobat/readstep2.html\">Adobe web site.</a>";
var lblTitle = "<b>VIEW DOCUMENT:</b> to view the complete version of this document, you can:";
var bShow = false;
           

var vOSLabel = document.getElementById("divAttachDocsLabel");
var vOSLabelDesc = document.getElementById("divAttachDocDescription");

if (vOSLabel != null &&  vOSLabelDesc)	
{
	for (var i=1; i<=5; i++)
	{          
	  var vCtrl = document.getElementById("AttachDocsControl" + i).innerText;
	   
	  var regExp2 = / /g;
	  var regExp1 = /&nbsp;/g;
	   
	  if (vCtrl != null && vCtrl != "")
	  {
	      vCtrl = vCtrl.replace(regExp1, "");
	      vCtrl = vCtrl.replace(regExp2, "");
	  }
	  
	  if (vCtrl != null && vCtrl != "")
	  { 
	      bShow = true;
	      //break;
	  } 
	  else
	  {
	      document.getElementById("AttachDocsControl" + i).innerText = vCtrl;
	  }
	}
	   	        
	if (bShow == true)
	{   
	  vOSLabel.innerHTML = lblTitle;
	  vOSLabelDesc.innerHTML = lblDesc;
	  document.getElementById("divAttachDocsLabel").style.background = '#C0C0C0';
	  document.getElementById("divAttachDocsLabel").style.width = '100%';
	  document.getElementById("divAttachDocsLabel").style.height= '21px';
	  document.getElementById("divAttachDocsLabel").style.paddingTop = '5px';
	}
	else
	{   
	  vOSLabel.innerHTML = "";
	  vOSLabelDesc.innerHTML = "";
	  document.getElementById("divAttachDocsLabel").style.display='none';

	}
}
*/

function AttachmentPorcess()
{ // for view document section, i.e. attachment
	var bShow = false;
	var vDivAttachDocs= document.getElementById("divAttachDocs");
	var isNav = (navigator.appName.indexOf("Netscape") != -1);
	
	if (vDivAttachDocs != null)	
	{
		for (var i=1; i<=5; i++)
		{ 
		  var vCtrl;
		  var bNavHref;
		  
	      if (isNav == true)
	      {
	          vCtrl = document.getElementById("AttachDocsControl" + i).innerHTML;
	          bNavHref = (vCtrl.indexOf("<a href") > 0);
	      }
	      else
	      {
	          vCtrl = document.getElementById("AttachDocsControl" + i).innerText;
	      }
		   
		  var regExp2 = / /g; // for space 
		  var regExp1 = /&nbsp;/g; // &nbsp; 
		  	   
		  if (vCtrl != null && vCtrl != "")
		  {
		      vCtrl = vCtrl.replace(regExp1, "");
		      vCtrl = vCtrl.replace(regExp2, "");
		  }
		  
		  if (isNav == false)
		  {
			  if (vCtrl != null && vCtrl != "")
			  { 
			      bShow = true;	
			  } 
			  else
			  {
			      document.getElementById("AttachDocsControl" + i).style.display='none';
			  }
		  }
		  else
		  {
		      if (bNavHref == true)
			  {
			      bShow = true;
			  }
			  else
			  {	      
			      document.getElementById("AttachDocsControl" + i).style.display='none'; 
			  }
		  }
		} 
		  	   	        
		if (bShow == false)
		{   
		    document.getElementById("divAttachDocs").style.display = 'none';
		}
		else
		{
		    document.getElementById("divAttachDocs").style.display = 'block';
		}
	}
}

function CustomerStoryProcess()
{/* for customer stories, i.e. story title and program contact     *************/

	var _regExp2 = / /g; /* for space */
	var _regExp1 = /&nbsp;/g; /* &nbsp; */
	
	var vStoryTitle = document.getElementById("story_title_id");
	
	if (vStoryTitle != null)	
	{	   
	  var titleControl = document.getElementById("story_title_id").innerText;
	  
	  var titleControl = vStoryTitle.innerText;
	  
	  titleControl = titleControl.replace(_regExp1, "");
	  titleControl = titleControl.replace(_regExp2, "");
	  
	  if (titleControl == null ||  titleControl == "")
	  { 
	     document.getElementById("story_title_id").style.display = 'none';	
	  } 	
	}
	
	var vProgramContent = document.getElementById("divProgramContent");
	
	if ( vProgramContent != null)	
	{	 
	  var programContent = document.getElementById("divProgramContent").innerText;
	  
	  //alert(" programContent == " +  programContent);  
	  programContent = programContent.replace(_regExp1, "");
	  programContent = programContent.replace(_regExp2, "");
	  
	  if (programContent == null || programContent == "")
	  { 
	     document.getElementById("story_right_id").style.display = 'none'; 
	  } 	
	}
}

/******************************************************************************/


