﻿// Various Javascript functions used through smart/ice
var aQSParm = new Array();
function loadQSArray() {
	var query = window.location.search.substring(1);
	var parms = query.split('&');
	for (var i=0; i<parms.length; i++) {
		var pos = parms[i].indexOf('=');
		if (pos > 0) {
			var key = parms[i].substring(0,pos);
			var val = parms[i].substring(pos+1);
			aQSParm[key] = val;
		}
	}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features)
{
    window.open(theURL,winName,features);
}
        
function ClearTextBox(id, sValue)
{
    if(document.getElementById(id).value == sValue)
        document.getElementById(id).value = "";
}

function FillTextBox(id, sValue)
{
    if(document.getElementById(id).value == "")
        document.getElementById(id).value = sValue;
}

function SubmitTextBox(ButtonID, e)
{
    var KeyID = (window.event) ? event.keyCode : e.keyCode;
    if (KeyID == 13)
    {
        document.getElementById(ButtonID).focus();
        document.getElementById(ButtonID).click();
    }
}

// Opacity for fading
function opacity(id, opacStart, opacEnd, millisec) 
{ 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

function changeOpac(opacity, id) 
{ 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ", FinishOpacity=100, Style=1, StartX=0,  FinishX=0, StartY=0, FinishY=100)";
}

function countWords(this_field, show_word_count, show_char_count) 
{
    if (show_word_count == null)
    {
        show_word_count = true;
    }
    if (show_char_count == null) 
    {
        show_char_count = false;
    }
    
    var char_count;
    var fullStr;
    
    if(this_field.getHTML())
    {
        fullStr = this_field.getHTML();
    }
    else 
    {
        fullStr = this_field.value;
    }
    char_count = fullStr.length; 
    //Strip HTML
	fullStr = this.stripHTML(fullStr);
	//Remove Smart Quotes
	fullStr = this.removeSmartQuotes(fullStr);
    //Most accented characters lie from 192 to 382. This would let them through but keep punctuation out.
	var non_alphanumerics_rExp = rExp = new RegExp("[^-A-Za-z0-9#,/'()\"\?\." + String.fromCharCode(192) + "-" + String.fromCharCode(382) + "]+", "gi");
    var cleanedStr = fullStr.replace(non_alphanumerics_rExp, " ");
    cleanedStr = cleanedStr.trim();
    var splitString = cleanedStr.split(" ");
    var word_count = splitString.length;
    
    if (fullStr.length <2) 
    {
        word_count = 0;
    }
    if (word_count == 1) 
    {
        wordOrWords = " word";
    }
    else 
    {
        wordOrWords = " words";
    }
    if (char_count == 1)
    {
        charOrChars = " character";
    } 
    else 
    {
        charOrChars = " characters";
    }
    if (show_word_count & show_char_count) 
    {
        alert ("Word Count:\n" + "    " + word_count + wordOrWords + "\n" + "    " + char_count + charOrChars);
    }
    else 
    {
        if (show_word_count) 
        {
            alert ("Word Count:  " + word_count + wordOrWords);
        }
        else 
        {
            if (show_char_count) 
            {
                alert ("Character Count:  " + char_count + charOrChars);
            }
        }
    }
    return word_count;
}

function clearWords(textBox)
{
//	if (FTB_API != null)
//	{
//		objFTBControl = FTB_API[textBox.id];
//		if (objFTBControl) 
//		{
//			objFTBControl.SetHtml("");
//		}
//	}
//	else
//	{
	    textBox.setHTML("");
//	}
}

function stripHTML(string) 
{
	var s = string;		    
    var re = /<[^>]*>/g;
	//initial cleanup
	s = this.stripHTML2(s);
	//secondary cleanup
	s = s.replace(re, "");
	//dump any other characters that may have slipped through
	s = s.replace(/\&nbsp;/g," ");
	s = s.replace(/\&lt;/g,"");
	s = s.replace(/\&gt;/g,"");
	
	return this.normalizeWhiteSpace(s);
}

function stripHTML2(string)
{
    var re = /<\S[^><]*>/g;
    string = string.replace(re, "");
    return string;
}

function removeSmartQuotes(str)
{
    //Quotes: Replace smart double quotes with straight double quotes.
    //ANSI version for use with 8-bit regex engines and the Windows code page 1252.
    var rExp_SmartDoubleQuotes1 = new RegExp("[\x84\x93\x94]+", "gi");
    str = str.replace(rExp_SmartDoubleQuotes1, "");

    //Quotes: Replace smart double quotes with straight double quotes.
    //Unicode version for use with Unicode regex engines.
    var rExp_SmartDoubleQuotes2 = new RegExp("[\u201C\u201D\u201E\u201F\u2033\u2036]+", "gi");
    str = str.replace(rExp_SmartDoubleQuotes2, "");

    //Quotes: Replace smart single quotes and apostrophes with straight single quotes.
    //Unicode version for use with Unicode regex engines.
    var rExp_SmartSingleQuote1 = new RegExp("[\u2018\u2019\u201A\u201B\u2032\u2035]+", "gi");
    str = str.replace(rExp_SmartSingleQuote1, "");
    
    //Quotes: Replace smart single quotes and apostrophes with straight single quotes.
    //ANSI version for use with 8-bit regex engines and the Windows code page 1252.
    var rExp_SmartSingleQuote2 = new RegExp("[\x82\x91\x92\xB4]+", "gi");
    str = str.replace(rExp_SmartSingleQuote2, "");

    //Quotes:  Replace smart double quotes
    var rExp_SmartDoubleQuotes3 = new RegExp("[“”“”]+", "gi");
    str = str.replace(rExp_SmartDoubleQuotes3, "");
    
    //Quotes: Replace smart single quotes
    var rExp_SmartSingleQuote3 = new RegExp("[‘’]+", "gi");
    str = str.replace(rExp_SmartSingleQuote3, "");      
    
    return str;
}

//Replaces all whitespace characters with spaces then replaces consecutive spaces into one space.
function normalizeWhiteSpace(str) 
{
	if (str == null) return str;
	var output = str.replace(/\s/, " ");
	while (output.indexOf("  ") >= 0) {
		output = output.replace("  ", " ");
	}
	//Remove leading space if it exists
	if (output.charAt(0) == " ") output = output.substring(1, output.length-1);
	//Remove trailing space if it exists
	if (output.charAt(output.length-1) == " ") output = output.substring(0, output.length-1);
	return output;
}

function previewContent(strDocName) 
{	
	if (strDocName != "") {
		var w = openCenterWindow('/SMART/Content/View.aspx?DocName=' + strDocName,'',600,500);						
	}	
}

function openCenterWindow(URL,theTarget,wide,high)
{
	var leftPos = (screen.width) ? (screen.width-wide)/2 : 0; topPos = (screen.height) ? (screen.height-high)/2 : 0;
	return window.open(URL,'','height='+high+',width='+wide+',left='+leftPos+',top='+topPos+',status=yes,toolbar=0,menubar=0,location=0,resizable=1,border=0,scrollbars=1',true);
}

function DownloadPrinterFriendly(strDocName, strContribPreview) 
{
	var strPrintFriendlyURL;
	
	strPrintFriendlyURL = "/SMART/Content/PrintContentPopup.aspx?DocName=" + strDocName;
	
	Window_PrintLink = window.open(strPrintFriendlyURL,"PrinterFriendly",
			"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,copyhistory=0,width=545,height=245,top=25,left=300");
	Window_PrintLink.focus();
}

function RecommendContent(strDocName) 
{
	var strRecommendURL;
	
	strRecommendURL = "/SMART/Content/RecommendPopup.aspx?DocNames=" + strDocName;
	
	Window_RecommendLink = window.open(strRecommendURL,"Recommend",
			"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,copyhistory=0,width=432,height=425,top=25,left=300");
	Window_RecommendLink.focus();
}

function SaveContent(strDocName) 
{
	var strSaveURL;
	
	strSaveURL = "/SMART/Content/SavePopup.aspx?DocNames=" + strDocName;
	
	Window_SaveLink = window.open(strSaveURL,"Save",
			"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,copyhistory=0,width=422,height=386,top=25,left=300");
	Window_SaveLink.focus();
}

function RemoveContent(strDocName, strProjectID) 
{
	var strSaveURL;
	
	strSaveURL = "/SMART/Content/RemovePopup.aspx?ProjectID=" + strProjectID + "&DocNames=" + strDocName;
	
	Window_SaveLink = window.open(strSaveURL,"Save",
			"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,copyhistory=0,width=422,height=386,top=25,left=300");
	Window_SaveLink.focus();
}

function GetQueryStringParameter(name)
{
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+name.toLowerCase()+"=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href.toLowerCase());
    if (results == null)
    {
        return "";
    }
    else
    {
        return results[1];
    }
}

function FormatICELinks()
{    
    var anchors = document.links;
    for (i=0; i<anchors.length; i++) 
    {        
        if(anchors[i].toString().indexOf('cphLeftNav') > -1)
        {            
            anchors[i].setAttribute("class", "menu");            
        }
	}
	if(document.URL.toString().toLowerCase().indexOf('/smart/contribution/content/') > -1)
	{
	    var originalURL = document.URL.toString().toLowerCase();
	    var myURL = originalURL;
	    
	    myURL = myURL.substring(myURL.indexOf('/smart/contribution/content/'));
	    myURL = myURL.substring(28);
	    myURL = myURL.substring(0,myURL.indexOf('.aspx'));	  
	    
	    switch(myURL)
	    {
	        case 'announcementcontent':
	            SetBoldStyle('lbContentTypeURL');
	            break;
	        case 'associatecontent':
	            SetBoldStyle('lbAssociateContent');
	            SetBoldStyle('lbTrendSeeAlso');
	            break;
            case 'associatemedia':
			    SetBoldStyle('lbMedia');
			    SetBoldStyle('lbTrendAssociatedMedia');
	            break;
	        case 'audiocontent':
	            SetBoldStyle('lbContentTypeURL');
	            break;
	        case 'authorcontributor':
	            SetBoldStyle('lbAuthorContributor');
	            SetBoldStyle('lbTrendAuthors');        
	            break;
            case 'content':
                SetBoldStyle('lbContentAdmin');
	            break;
	        case 'cz_executivesummarycontent':	             
	            SetBoldStyle('lbContentTypeURL');
	            break;
	        case 'exit':
	            SetBoldStyle('lbExit');
	            break;
	        case 'globalmarketfactcontent':
	            SetBoldStyle('lbContentTypeURL');
	            break;
	        case 'marketfactcontent':
	            SetBoldStyle('lbMFContentType');
	            break;
	        case 'globalobservationcontent':
	            SetBoldStyle('lbContentTypeURL');
	            break;
	        case 'globalpulsecontent':
	            SetBoldStyle('lbContentTypeURL');
	            break;
	        case 'supertrendcontent':
	            SetBoldStyle('lbContentTypeURL');
	            break;
	        case 'globaltrendcontent':
	            SetBoldStyle('lbContentTypeURL');
	            break;
	        case 'history':
	            //nothing happens
	            break;
	        case 'iconoscopecontent':
	            SetBoldStyle('lbContentTypeURL');
	            break;
	        case 'iconoscopecontentsection':
	            //check the querysting sectionid
	            var SectionID = GetQueryStringParameter('SectionID');
	            switch(SectionID)
	            {
	                case '1':
	                    SetBoldStyle('lbSection1');
	                    break;
	                case '2':
	                    SetBoldStyle('lbSection2');
	                    break;
	                case '3':
	                    SetBoldStyle('lbSection3');
	                    break;
	                default:
	                    alert('An error has occured trying to set the current page\'s style in Iconoscope.');
	                    break;
	            }
	            break;           
	        case 'imagecontent':
	            SetBoldStyle('lbContentTypeURL');
	            break;
	        case 'observationcontent':
	            SetBoldStyle('lbTrendContentType');
	            break;
	        case 'podcastcontent':
	            SetBoldStyle('lbContentTypeURL');
	            break;
	        case 'preview':
	            SetBoldStyle('lbPreview');
	            break;
	        case 'publishcontent':
	            alert('how did you get here?');
	            break;	    
	        case 'globalfocuscontent':
	            SetBoldStyle('lbContentTypeURL');
	            break;	    
	        case 'steepreportcontent':
	            SetBoldStyle('lbContentTypeURL');
	            break;
	        case 'strategicconversion':
	            SetBoldStyle('lbContentTypeURL');
	            break;	   
	        case 'trendcontent':
	            SetBoldStyle('lbTrendContentType');
	            break;
	        case 'cz_topiccontent':
	            SetBoldStyle('lbContentTypeURL');
	            break;
	        case 'videocontent':
	            SetBoldStyle('lbContentTypeURL');
	            break;
	        default:
	            if(myURL.indexOf('researchagendareport') > -1)
	            {
	                var mySubURL = myURL.substring(21);	                	            	            
	                switch(mySubURL)
	                {
	                    case 'bestpractices':
	                       SetBoldStyle('lbBestPractices');
	                       break; 
	                    case 'introduction':
	                        SetBoldStyle('lbIntroduction');
	                        break;
	                    case 'marketingimplications':
	                        SetBoldStyle('lbMarketingImplications');
	                        break;
	                    case 'networknotes':
	                        SetBoldStyle('lbNetworkNotes');
	                        break;
	                    case 'researchagendareportcontent':
	                        SetBoldStyle('lbContentTypeURL');
	                        break;
	                    case 'visualization':
	                        SetBoldStyle('lbVisualization');
	                        break;
	                    default:
	                        alert('An error has occured trying to set the current page\'s style in ResearchAgendaReport.');
	                        break;
	                }
	            }
	            else if(myURL.indexOf('cz_fullreport') > -1)
	            {
	                var mySubURL = myURL.substring(14);	                	            	            
	                switch(mySubURL)
	                {
	                    case 'analysis':
	                        SetBoldStyle('lbCZFullReport_Analysis');
	                        break; 
	                    case 'countertrend':
	                        SetBoldStyle('lbCZFullReport_Countertrend');
	                        break;
	                    case 'implicationsandopportunities':
	                        SetBoldStyle('lbCZFullReport_ImplicationsAndOpportunities');
	                        break;
	                    case 'visualization':
	                        SetBoldStyle('lbCZFullReport_Visualization');
	                        break;
	                    default:
	                        alert('An error has occured trying to set the current page\'s style in CZ_FullReport.');
	                        break;
	                }
	            }
	            else if (myURL.indexOf('taxonomy') > -1)
	            {
	                var mySubURL = myURL.substring(9);
	                switch(mySubURL)
	                {
	                    case 'agerange':
	                        SetBoldStyle('lbAgeRange');
	                        break;
	                    case 'category':
	                        SetBoldStyle('lbCategory');
	                        break;
	                    case 'demographics':
	                        SetBoldStyle('lbDemographics');
	                        break;
	                    case 'macrotrendvalue':
	                        SetBoldStyle('lbMacrotrendValue');
	                        break;
	                    case 'metatrend':
	                        SetBoldStyle('lbMetatrend');
	                        break;
	                    case 'region':
	                        SetBoldStyle('lbRegion');
	                        break;
	                    case 'tags':
	                        SetBoldStyle('lbTags');
	                        break;
	                    default:
                            alert('An error has occured trying to set the current page\'s style in Taxonomy.');
                            break;	                    
	                }
	                
	                //Categories
	                if (originalURL.indexOf('&tagsetids=1,36') > -1)
	                {
	                    SetBoldStyle('lbMFCategories');
	                    SetBoldStyle('lbTrendCategories');
	                }
	                //Macrotrends/Values
	                else if (originalURL.indexOf('&tagsetids=11,10,45') > -1)
	                {
	                    SetBoldStyle('lbTrendMacrotrends');
	                }
	                //Demographics
	                else if (originalURL.indexOf('&tagsetids=3,18,19,20,21,23,4,5,6,7,8,2') > -1)
	                {
	                    SetBoldStyle('lbTrendDemographics');
	                    SetBoldStyle('lbMFDemographics');
	                }
	                //Regions
	                else if (originalURL.indexOf('&tagsetids=9,49') > -1)
	                {
	                    SetBoldStyle('lbTrendRegions');
	                }
	                //All Tags
	                else if (originalURL.indexOf('&tagsetids=11,10,3,18,19,20,21,23,4,5,6,7,8,35,2,9,49,45,1,36') > -1)
	                {
	                    SetBoldStyle('lbTrendAllTags');
	                }
	            }
	            else
	            {
	                //alert('An error has occured trying to set the current page\'s style.');
	            }
	            break;	        
	    }
	}
}

function SetBoldStyle(id)
{    
    var anchors = document.links;    
    for (i=0; i<anchors.length; i++) 
    {
        var strCurrentAnchor = anchors[i].toString().toLowerCase();
        if(strCurrentAnchor.indexOf('cphleftnav') > -1)
        {            
            if(strCurrentAnchor.indexOf(id.toLowerCase()) > -1)
            {
                anchors[i].style.fontWeight = 'bold';
            }            
        }
	}
}

function checkSimpleSearchSubmit(e, btnId) {
	var keyCode;
	
	if(window.event) // IE
	{
	keyCode = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
	keyCode = e.which;
	}
	
	if (keyCode == 13) {
		document.getElementById(btnId).click();
		e.returnValue = false;
		e.cancel = true;
	} //End ENTER Key Check

} //End Function

function selectRelatedContent(strContentTypeElementID, strDocNameElementID, strLimitDocumentTypes, intMaxElements)
{		
	var w = openCenterWindow('/SMART/Contribution/Content/EmbedContent.aspx'
		+ '?ContentTypeElementID=' + strContentTypeElementID + '&DocNameElementID=' + strDocNameElementID
		+ '&LimitDocumentTypes=' + strLimitDocumentTypes + '&ItemLimit=' + intMaxElements,'',1000,750);
}

function selectRelatedProjectFolderContent(strDocNameElementID, strLimitDocumentTypes, intMaxElements, intProjectID)
{		
	var w = openCenterWindow('/SMART/Contribution/Search/SearchResults.aspx'
		+ '?DocNameElementID=' + strDocNameElementID
		+ '&LimitDocumentTypes=' + strLimitDocumentTypes 
		+ '&ProjectID=' + intProjectID
		+ '&ItemLimit=' + intMaxElements,'',1000,750);
}

function updateRelatedContent(strDocNameElementID, strDocNameValue, strContentTypeElementID, strContentTypeValue) {
    //Update DocName
    var objDocName;
    objDocName = document.getElementById(strDocNameElementID);

    objDocName.value = strDocNameValue;

    //Update ContentType (if one was passed)
    var objContentType;
    if (strContentTypeElementID != null && strContentTypeElementID != "") {
	    objContentType = document.getElementById(strContentTypeElementID);

	    if (objContentType != null) {
		    objContentType.value = strContentTypeValue;
	    }
    }
}

function updateRelatedContent(strDocNameElementID, strDocNameValue, strContentTypeElementID) {
    //Update DocName
    var objDocName;
    objDocName = document.getElementById(strDocNameElementID);

    objDocName.value = strDocNameValue;

    //Update ContentType (if one was passed)
    var objContentType;
    if (strContentTypeElementID != null && strContentTypeElementID != "") {
	    objContentType = document.getElementById(strContentTypeElementID);

	    if (objContentType != null) {
		    objContentType.value = getContentType(strDocNameValue);
	    }
    }
}

function updateRelatedContentCookie(strDocNameElementID,strContentTypeElementID) {
	var strContentIds = readCookie('PublisherMultiSelect').replace('CotentItemIds=','');
	var objDocName= document.getElementById(strDocNameElementID);

    //Update DocName
    objDocName.value = strContentIds;

    //Update ContentType (if one was passed)
    var objContentType;
    if (strContentTypeElementID != null && strContentTypeElementID != "") {
	    objContentType = document.getElementById(strContentTypeElementID);
	    if (objContentType != null)
		    objContentType.value = getContentType(strDocNameElementID);
    }
}//end function

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function getContentType(strContentName)
{
	var strContentType;
	switch (strContentName.substring(0,3))
	{
		case "ab_":
			strContentType="Advisory Brief";
		    break;
		case "an_":
			strContentType="Announcement";
		    break;
		case "au_":
			strContentType="Audio";
		    break;
		case "co_":
			strContentType="Consumer Outlook";
		    break;
		case "es_":
		    strContentType="Cultural Zeitgeist Executive Summary";
		    break;
		case "fr_":
		    strContentType="Cultural Zeitgeist Full Report";
		    break;
		case "gm_":
			strContentType="Global Market Fact";
		    break;
		case "go_":
			strContentType="Global Observation";
		    break;
		case "gp_":
			strContentType="Cultural Viewpoints";
		    break;
		case "gt_":
			strContentType="Global Trend";
		    break;
		case "ic_":
			strContentType="Iconoscope";
		    break;
		case "iw_":
			strContentType="Iconowatch";
		    break;
		case "im_":
			strContentType="Image";
		    break;
		case "in_":
			strContentType="Insight";
		    break;
		case "mf_":
			strContentType="Market Fact";
		    break;
		case "oa_":
			strContentType="Observation";
		    break;
		case "pc_":
		    strContentType="Podcast";
		    break;
		case "pv_":
			strContentType="Point Of View";
		    break;
		case "ra_":
			strContentType="Research Agenda Report";
		    break;
		case "sr_":
			strContentType="STEEP Report";
		    break;
		case "sc_":
			strContentType="Strategic Conversation";
		    break;
		case "st_":
		    strContentType="Super Trend";
		    break;
		case "ta_":
			strContentType="Trend";
		    break;
		case "ti":
		    strContentType="Cultural Zeitgeist Topic";
		    break;
		case "vi_":
			strContentType="Video";
		    break;
		case "wc_":
			strContentType="Webcast";
		    break;
		default:
			strContentType="";
		    break;
	}

	return strContentType;
}

function previewContentByControlID(strControlID)
{
    if(strControlID != "")
    {
        var thisControl = document.getElementById(strControlID);
        
        if (thisControl.value != "")
        {
            previewContent(thisControl.value);
        }
        else
        {
            alert('Please specify a doc name.');
        }
    }
}

function addSectionItem(strSectionPrefix) 
{            
	var iElementIndex = 1;
	var bSectionFound = false;
	var objSection;				
	var strSectionName;
                                  
	strSectionName =  strSectionPrefix + iElementIndex;
	objSection = document.getElementById(strSectionName);
	
	while (!bSectionFound && objSection != null) 
	{
		if (objSection.style.display == "none") 
		{
			objSection.style.display = "";
			//SetFTBFocus(objSection);
			bSectionFound = true;
		}

		iElementIndex++;
		objSection = document.getElementById(strSectionPrefix + iElementIndex);
	}			
}

// Hides or Displays an HTML Element
function setDisplay(id, value)
{   
    document.getElementById(id).style.display=value;		    
}

// Selects the button related to the active textbox when enter is pressed,
// overrides default button behavior
function activeTextboxButton(e, buttonid){ 

      var evt = e ? e : window.event;
      var bt = document.getElementById(buttonid);
      if (bt){ 
          if (evt.keyCode == 13){ 
                bt.click(); 
                return false; 
                } 
        } 
}
// Displays the Email A Friend form for the specified content
function emailAFriend(strDocName) 
{
	Window_Send = window.open("/SMART/Email/EmailAFriend.aspx?DocName=" + strDocName, "EmailAFriend", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=850,height=760,top=5,left=200"); 
	Window_Send.focus();
}

String.prototype.trim = function()
{
	return this.replace(/^\s+|\s+$/g,'');
}