
rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function msg(sBuf)
{
	alert(sBuf);
}

function rnd()
{
	rnd.seed = (rnd.seed * 9301 + 49297) % 233280;
	return rnd.seed / (233280.0);
}

function rand(number)
{
	return Math.ceil(rnd() * number);
}

function GetQueryStringParam(sName,bTop)
{
    var sSearch;
    
    if (bTop)
    {
        sSearch = top.location.search;
    }
    else
    {
        sSearch = location.search;
    }
        
    var p1;
    p1 = sSearch.indexOf('?' + sName + '=');
    if (p1 < 0)
    {
        p1 = sSearch.indexOf('&' + sName + '=');
    }
    if (p1 < 0)
    {
        return "";
    }
        
    p1 += sName.length + 2;
    
    var p2 = sSearch.indexOf('&',p1);
    if (p2 >= 0)
    {
        return sSearch.substring(p1,p2);
    }
    else
    {
        return sSearch.substring(p1);
    }
}

function Set_Cookie(name, value, expires, path, domain, secure)
{
	document.cookie = name + '=' + escape(value) +
		((expires) ? ';expires=' + expires.toGMTString() : '') +
		((path) ? ';path=' + path : '') + 
		((domain) ? ';domain=' + domain : '') +
		((secure) ? ';secure' : '');
}

function Get_Cookie(name)
{
	var start = document.cookie.indexOf(name+"=");
	var len = start+name.length+1;
	
	if ((!start) && (name != document.cookie.substring(0, name.length))) return '';
	if (start == -1) return '';
	
	var end = document.cookie.indexOf(";",len);
	
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len,end));
}

function Delete_Cookie(name, path, domain)
{
	if (Get_Cookie(name)) document.cookie = name + "=" +
		((path) ? ";path=" + path : "") +
		((domain) ? ";domain=" + domain : "") +
		";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function Set_Sub_Cookie(bigCookieName, subCookieName, value, expires, path, domain, secure)
{
	sBuf = Get_Cookie(bigCookieName);

	iLoc = sBuf.indexOf(subCookieName + '=');	
	
	if (iLoc > -1) {
		iEnd = sBuf.indexOf(';', iLoc) + 1;
		sBuf = sBuf.substr(0, iLoc) + sBuf.substr(iEnd);
	}

	sBuf += subCookieName + '=' + escape(value) + ';';
	

	Set_Cookie(bigCookieName, sBuf, expires, path, domain, secure);
}

function Set_Main_Cookie(name, value, expires, path, domain, secure)
{
	Set_Sub_Cookie('main', name, value, '', '/', '', '');
}

function Delete_Main_Cookie(name, expires, path, domain, source)
{
	Delete_Sub_Cookie('main', name, expires, path, domain, source);
}

function Delete_Sub_Cookie(bigCookieName, subCookieName, expires, path, domain, secure)
{
	sBuf = Get_Cookie(bigCookieName);    
	iLoc = sBuf.indexOf(subCookieName + '=');  	      
	if (iLoc > -1)   // find cookie and delete it
	{
		iEnd = sBuf.indexOf(';', iLoc) + 1;
		sBuf = sBuf.substr(0, iLoc) + sBuf.substr(iEnd);
		if (sBuf.length > 0)
		{
			Set_Cookie(bigCookieName, sBuf, expires, path, domain, secure);
		}
		else 
		{
			Delete_Cookie(bigCookieName, path, domain);
		}
	}
}

function Get_Sub_Cookie(bigCookieName, subCookieName)
{
	sBuf = Get_Cookie(bigCookieName);

	iLoc = sBuf.indexOf(subCookieName + '=');

	if (iLoc > -1) {
		iLoc = iLoc + subCookieName.length + 1;
		return unescape(sBuf.substr(iLoc, sBuf.indexOf(';', iLoc) - iLoc));
	}
	
	return '';
}

function Get_Main_Cookie(name)
{
	return Get_Sub_Cookie('main', name);
}

function Set_Category_Cookie(name, value, expires, path, domain, secure)
{
       	Set_Sub_Cookie('category', name, value, '', '/', '', '');
}


function Get_Category_Cookie(name)
{	
       	return Get_Sub_Cookie('category', name);
}


function Add_Category_Cookie(value)
{
	// Do not exceed max allowed categories per site.
	number_selected = Get_Category_Cookie('num_cats_selected');
	
	// Replace all spaces with _ before storing in the cookie.
	// Multi-word categories are stored in cookies(so 
	// duplicates can be found) & in site.xml with
	// '_' replacing spaces.  This is required so that HTDig seach engine, 
	// which uses spaces as category delimiters, will treat 
	// the group of words as one category.
        value = replace(value,' ','_');
        value = replace(value,'%20','_');  // Netscape encodes spaces 
	
	if( number_selected <  Get_Category_Cookie('cat-max_per_site'))
	{
		// Do not allow duplicate category names.
                sBuf = Get_Cookie('category');
		iLoc = sBuf.indexOf(value); 
                if (iLoc > -1) {
			alert('ERROR: You have already selected this category, please make another selection.');
                }
		else{
			// add the category
		       	Add_Cookie_Now(value);
		
			// refresh right frame
			parent.fCategoryView.location.href="/trellix/sitebuilder/cats_selected.jsp";
		}
	}
	else
	{
		alert('ERROR: You have exceeded the number of categories allowed.  You may delete a category in the right window to make room for a new category.');
	}
}

function Add_Cookie_Now(value)
{
	// The category name are cat1, cat2, etc 
	// up to the max categories allowed per site.
	// Get the last number used and increment it.
	
	// check for trailing comma present when category obtained from site object
	iLoc = value.indexOf(',');
	if (iLoc > -1) {
		// strip off trailing comma
		value = value.substr(0, iLoc);
        }
	// Replace all spaces with _ before storing in the cookie.
	// Multi-word categories are stored in cookies(so 
	// duplicates can be found) & in site.xml with
	// _ replacing spaces.  This is so that HTDig seach engine, 
	// which uses spaces as category delimiters, will treat 
	// the group as one category.
        value = replace(value,' ','_');
	number_selected = Get_Category_Cookie('num_cats_selected');
	number_selected++;
	var cat_name = 'cat' +  number_selected;
	Set_Category_Cookie(cat_name, value, '', '/', ''); 
	Set_Category_Cookie('num_cats_selected',  number_selected, '', '/', ''); 
}


function Initialize_Category_Cookie(num_max, num_req)
{	
	var cat_init = Get_Category_Cookie('cat_cookie_init');
       
        if(Get_Category_Cookie('cat_cookie_init') != 'yes'){
		Set_Category_Cookie('cat-max_per_site', num_max);
		Set_Category_Cookie('cat-req_per_site', num_req);
                Set_Category_Cookie('cat_cookie_init', 'yes');
		Set_Cookie('help_page', 'categories', '', '/', ''); 
	}
}

function Delete_Selected_Category(del_number)
{      
    // If the user selected the delete button next to an empty category, 
    // just refresh the page.
    num_selected = Get_Category_Cookie('num_cats_selected');
    if(del_number <= num_selected){
	// delete the category from the cookie 
	sBuf = Get_Cookie('category');
        var cat_name = 'cat' + del_number;
        iLoc = sBuf.indexOf(cat_name + '=');  
	// find cookie and delete it      
        if (iLoc > -1) {
		iEnd = sBuf.indexOf(';', iLoc) + 1;
		sBuf = sBuf.substr(0, iLoc) + sBuf.substr(iEnd);
		Set_Cookie('category', sBuf, '', '/', '', '');
        }
	
	// If the category being deleted is other than
	// the bottom of the list, move the categories up in the 
	// list to fill in the gap
	if(del_number < num_selected ){
                for(i = del_number; i < num_selected ; ){
			name_plus = 'cat' + (i+1);
			next_value = Get_Category_Cookie(name_plus);
                        Set_Category_Cookie(cat_name,next_value);
			i++;
			cat_name = 'cat' + (i);
			if(i == num_selected){
				// set to blank
				Set_Category_Cookie(cat_name,"");
                        }
                } // end for
	} // end if 
	// decrement the category counter
      	Set_Category_Cookie('num_cats_selected', num_selected - 1, '', '/', '');
    } // end del_number < num_selected   
    // refresh right frame
    parent.fCategoryView.location.href="/trellix/sitebuilder/cats_selected.jsp";

}

function Delete_Category_Cookie()
{
	Delete_Cookie('category', '/', '');

}

function ProcessCategoryDoneButton(cmdForm)
{      
	//If the required number of categories have not been selected, 
	//force the user back to the category page
	
        num_required = Get_Category_Cookie('cat-req_per_site'); 
	num_selected = Get_Category_Cookie('num_cats_selected'); 
     	if(num_required > num_selected ){
		if(num_required == 1){
			alert('ERROR: You are required to select at least (' + num_required + ') category for your site.');
		}
		else{
			alert('ERROR: You are required to select at least (' + num_required + ') categories for your site.');
		
		}
		parent.fCategoryView.location.href="/trellix/sitebuilder/cats_selected.jsp";
	}
	else{   // done
		// save categories to site.xml file and go to the next url
                Delete_Category_Cookie();
                cmdForm.submit();
	}
}

function ProcessCategoryCancelButton()
{
	Delete_Category_Cookie();

	// determine next screen 
	if (Get_Cookie('mode') == 'site_organizer') { 
		top.location.href="/trellix/sitebuilder/f_site_organizer.html";
	}
	else{
		top.location.href="/trellix/sitebuilder/f_edit_page.html";    
	}  
}

function ProcessWPMCancelButton()
{
	// Return to page - based on mode. 
	 
	// Note: returning from a call from the upload page is not consistent.  If upload is called
	// from "all_my_site/picture_gallery/upload, then the user is returned to upload page as expected.
	// But if the user calls upload from the edit/picture gallery or add/picture gallery, then 
	// the user is returned to picture gallery.  This is for 2 reasons: the mode cannot be set in
	// f_upload_picture which is used by both edit & add.  The edit and add code depends on the
	// mode set before f_upload_picture.  To set a mode in f_upload_picture breaks the code in 
	// major ways. 	Also, in the edit and add cases, the user wants to be returned to picture gallery so 
	// that he can choose the photo just uploaded.
	
         
	var retMode = Get_Cookie('mode');
	switch(retMode){
	case 'all_my_sites':   // from all my sites
		top.location.href="/trellix/sitebuilder/f_all_my_sites.html";
		break;
	case 'picture_gallery':	  // from "all my sites/picture gallery"
		top.location.href="/trellix/sitebuilder/f_picture_gallery.html";
		break;
	case 'upload_picture_gallery': // from "all my sites/picture gallery/upload"
		top.location.href="/trellix/sitebuilder/f_upload_picture_gallery.html"; 
		break;

	case 'edit_picture_list':    // from edit/picturegallery and edit/picture gallery/upload
		top.location.href="/trellix/sitebuilder/f_edit_picture_list.html"; 
		break;
	case 'edit_picture':	   // from edit/upload
		top.location.href="/trellix/sitebuilder/f_edit_picture.html"; 
		break;

        case 'add_picture':       // from add picture/picture gallery and add picture/picture gallery/upload
                top.location.href="/trellix/sitebuilder/f_add_picture.html"; 
		break;

	default:
	      top.location.href="/trellix/sitebuilder/f_all_my_sites.html";
	      break;
	}
}


function makeArray()
{
	for (i=0; i < makeArray.arguments.length; i++)
		this[i + 1] = makeArray.arguments[i];
}

/* commented out * commented out
function WriteDate()
{
	var months = new makeArray('January', 'February', 'March',
		'April', 'May', 'June', 'July', 'August', 'September',
		'October', 'November', 'December');

	var date = new Date();
	var day  = date.getDate();
	var month = date.getMonth() + 1;
	var yy = date.getYear();
	var year = (yy < 1000) ? yy + 1900 : yy;

	return (months[month] + " " + day + ", " + year);
}
*/

function SetDebug(val)
{
	Set_Cookie('debug', val, '', '/', '', '');
}

function SetPartner(name)
{
	Set_Cookie('partner', name, '', '/', '', '');
}

function DebugMsg(msg)
{
	alert('Debug Level: ' + Get_Cookie('debug') + '\n\n' + msg);
}

function AddQueryStringParameter(url, paramname, paramvalue)
{
    var rval = url;
    var pos1;
    var pos2;
    
    if (paramname == '')
        return rval;
        
    pos1 = url.indexOf("?");
    if (pos1 < 0)
    {
        rval += "?" + paramname + "=" + escape(paramvalue);
    }
    else
    {
        pos1 = url.indexOf(paramname+"=",pos1);
        if (pos1 >= 0)
        {
            pos1 += paramname.length() + 1;
            pos2 = url.indexOf("&",pos1);
            if (pos2 >= 0)
            {
                rval = url.substring(0,pos1) + escape(paramvalue) + url.substring(pos2);
            }
            else
            {
                rval = url.substring(0,pos1) + escape(paramvalue);
            }
        }
        else
        {
            rval += "&" + paramname + "=" + escape(paramvalue);
        }
    }
        
    return rval;
}

function modifyUrl(url,randParam,randVal)
{
    var rval = url;
    if (randParam != '')
    {
        rval = AddQueryStringParameter(rval,randParam,randVal);
    }
    return rval;
}

function writeSponsorFrameSet2(mainPage,toolbar,urlTop,topHeight,urlRight,rightWidth,rightScrolling,randParam)
{
    var randVal = Math.random();
    randVal = Math.floor(randVal * 32768);


    document.write('<frameset rows="' + topHeight + ', *" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    document.write('<frame name="fSpTop" src="' + modifyUrl(urlTop,randParam,randVal) + '" frameborder="0" scrolling="no" noresize="yes" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('<frameset cols="*, ' + rightWidth + '" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    if (toolbar == 'm_all_my_sites.html' 
        || toolbar == 'm_add_picture.html')
    {
        document.write('<frameset rows="*, 60" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    }
    else
    {
        document.write('<frameset rows="*, 52" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    }
    document.write('<frame src="' + mainPage + '" name="fBody" frameborder="0" scrolling="auto" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('<frame src="' + toolbar + '" name="fBottom" frameborder="0" scrolling="no" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('</frameset>\r\n');
    
    document.write('<frame name="fSpRight" src="' + modifyUrl(urlRight,randParam,randVal) + '" frameborder="0" scrolling="' + rightScrolling + '" noresize="yes" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('</frameset>\r\n');
    document.write('</frameset>\r\n');

    
}

function writeSponsorFrameSet3(mainPage,toolbar,urlTop,topHeight,urlLeft,leftWidth,urlRight,rightWidth,rightScrolling,urlBottom,bottomHeight,bottomScrolling,randParam)
{
    var randVal = Math.random();
    randVal = Math.floor(randVal * 32768);


    document.write('<frameset rows="' + topHeight + ', *" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    document.write('<frame name="fSpTop" src="' + modifyUrl(urlTop,randParam,randVal) + '" frameborder="0" scrolling="no" noresize="yes" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('<frameset cols="' + leftWidth + ', *, ' + rightWidth + '" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    document.write('<frame name="fSpLeft" src="' + modifyUrl(urlLeft,randParam,randVal) + '" frameborder="0" scrolling="no" noresize="yes" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('<frameset rows="*, ' + bottomHeight + '" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    if (toolbar == 'm_all_my_sites.html' 
        || toolbar == 'm_add_picture.html')
    {
        document.write('<frameset rows="*, 60" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    }
    else
    {
        document.write('<frameset rows="*, 52" framespacing="0" frameborder="0" border="0" noresize="yes" marginwidth="0" marginheight="0">\r\n');
    }
    document.write('<frame src="' + mainPage + '" name="fBody" frameborder="0" scrolling="auto" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('<frame src="' + toolbar + '" name="fBottom" frameborder="0" scrolling="no" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('</frameset>\r\n');
    
    document.write('<frame name="fSpBottom" src="' + modifyUrl(urlBottom,randParam,randVal) + '" frameborder="0" scrolling="' + bottomScrolling + '" noresize="yes" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('</frameset>\r\n');
    document.write('<frame name="fSpRight" src="' + modifyUrl(urlRight,randParam,randVal) + '" frameborder="0" scrolling="' + rightScrolling + '" noresize="yes" marginwidth="0" marginheight="0" framespacing="0">\r\n');
    document.write('</frameset>\r\n');
    document.write('</frameset>\r\n');

    
}

function WriteFrameSet(top, middle, bottom, renderPage, mode, isGem, topHeight)
{
	if (renderPage == true) {
		middle =  '/servlet/SiteBuilderServlet?Command=RenderPage&PageNum=' + Get_Cookie('page_num') + '&Mode=' + mode + '&RenderError=/trellix/sitebuilder/f_error.jsp';
	}
	
	if (Get_Cookie('help_page') == '') {
		help_page = 'unavailable';
	}
	else {
		help_page = Get_Cookie('help_page');
	}
    
    if (topHeight == null || topHeight <= 0)
    {
        topHeight = '71';
    }
	
	if ((Get_Cookie('help') == '1') && (help_page != 'nohelp') && (Get_Cookie('map') == '1') && (isGem != '1')) {


		document.write('<FRAMESET ROWS="'+topHeight+', 20, *, 50, 60" FRAMESPACING="0" FRAMEBORDER="0" BORDER="0">');
	    document.write('<FRAME NAME="fTop" SRC="' + top + '" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="no" FRAMEBORDER="0">');

	    document.write('<FRAME NAME="fAd" SRC="/trellix/sitebuilder/ad_link.html" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="no" FRAMEBORDER="0">');


		document.write('<FRAMESET COLS="78%,*" FRAMESPACING="0" FRAMEBORDER="0">');
		document.write('<FRAME NAME="fBody" SRC="' + middle + '" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="auto" FRAMEBORDER="0">');
		document.write('<FRAMESET ROWS="52, *, 26" FRAMESPACING="0" FRAMEBORDER="0">');
		document.write('<FRAME SRC="/trellix/sitebuilder/help_bkgnd_top.html" FRAMEBORDER="0" SCROLLING="No" NORESIZE MARGINWIDTH="10" MARGINHEIGHT="10">');
		document.write('<FRAME NAME="fHelp" SRC="/trellix/sitebuilder/help/help_' + help_page + '.html" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="auto" FRAMEBORDER="0">');
		document.write('<FRAME SRC="/trellix/sitebuilder/help_bkgnd_bot.html" FRAMEBORDER="0" SCROLLING="No" NORESIZE MARGINWIDTH="10" MARGINHEIGHT="10">');
		document.write('</FRAMESET>');
		document.write('</FRAMESET>');
		document.write('<FRAME NAME="fMap" SRC="/trellix/sitebuilder/map.html" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="No" NORESIZE FRAMEBORDER="0">');		
		document.write('<FRAME SRC="' + bottom + '" NAME="fBottom" FRAMEBORDER="0" SCROLLING="No" MARGINWIDTH="0" MARGINHEIGHT="0" FRAMESPACING="0">');
		document.write('</FRAMESET>');

	}	
	else if ((Get_Cookie('help') == '1') && (help_page != 'nohelp') && (isGem != '1')) {

		document.write('<FRAMESET ROWS="71, 20, *, 60" FRAMESPACING="0" FRAMEBORDER="0" BORDER="0">');
	    document.write('<FRAME NAME="fTop" SRC="' + top + '" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="no" FRAMEBORDER="0">');

	    document.write('<FRAME NAME="fAd" SRC="/trellix/sitebuilder/ad_link.html" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="no" FRAMEBORDER="0">');


		document.write('<FRAMESET COLS="78%,*" FRAMESPACING="0" FRAMEBORDER="0">');
		document.write('<FRAME NAME="fBody" SRC="' + middle + '" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="auto" FRAMEBORDER="0">');
		document.write('<FRAMESET ROWS="52, *, 26" FRAMESPACING="0" FRAMEBORDER="0">');
		document.write('<FRAME SRC="/trellix/sitebuilder/help_bkgnd_top.html" FRAMEBORDER="0" SCROLLING="No" NORESIZE MARGINWIDTH="10" MARGINHEIGHT="10" FRAMESPACING="0">');
		document.write('<FRAME NAME="fHelp" SRC="/trellix/sitebuilder/help/help_' + help_page + '.html" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="auto" FRAMEBORDER="0">');
		document.write('<FRAME SRC="/trellix/sitebuilder/help_bkgnd_bot.html" FRAMEBORDER="0" SCROLLING="No" NORESIZE MARGINWIDTH="10" MARGINHEIGHT="10">');
		document.write('</FRAMESET>');
		document.write('</FRAMESET>');
		document.write('<FRAME SRC="' + bottom + '" NAME="fBottom" FRAMEBORDER="0" SCROLLING="No" MARGINWIDTH="0" MARGINHEIGHT="0" FRAMESPACING="0">');
		document.write('</FRAMESET>');

	}
	else if (Get_Cookie('map') == '1') {

		document.write('<FRAMESET ROWS="71, 20, *, 50, 60" FRAMESPACING="0" FRAMEBORDER="0" BORDER="0">');
	    document.write('<FRAME NAME="fTop" SRC="' + top + '" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="no" FRAMEBORDER="0">');

	    document.write('<FRAME NAME="fAd" SRC="/trellix/sitebuilder/ad_link.html" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="no" FRAMEBORDER="0">');

		document.write('<FRAME NAME="fBody" SRC="' + middle + '" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="auto" FRAMEBORDER="0">');
		document.write('<FRAME NAME="fMap" SRC="/trellix/sitebuilder/map.html" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="No" NORESIZE FRAMEBORDER="0">');
		document.write('<FRAME NAME="fBottom" SRC="' + bottom + '" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="No" NORESIZE FRAMEBORDER="0">');
		document.write('</FRAMESET>');

	}	
	else {

		document.write('<FRAMESET ROWS="71, 20, *, 60" FRAMESPACING="0" FRAMEBORDER="0" BORDER="0">');
	    document.write('<FRAME NAME="fTop" SRC="' + top + '" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="no" FRAMEBORDER="0">');

	    document.write('<FRAME NAME="fAd" SRC="/trellix/sitebuilder/ad_link.html" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="no" FRAMEBORDER="0">');

	    document.write('<FRAME SRC="' + middle + '" NAME="fBody" FRAMEBORDER="0" SCROLLING="Auto" MARGINWIDTH="0" MARGINHEIGHT="0" FRAMESPACING="0">');
		document.write('<FRAME SRC="' + bottom + '" NAME="fBottom" FRAMEBORDER="0" SCROLLING="No" MARGINWIDTH="0" MARGINHEIGHT="0" FRAMESPACING="0">');
		document.write('</FRAMESET>');	

	}	
}

function WriteAdFrameSet(adReqPage, middle, bottom, renderPage, mode, isGem)
{

    WriteFrameSet('/trellix/sitebuilder/ad_top_small.html', middle, bottom, renderPage, mode, isGem);
    
}

function WritePreviewFrameSet(middle, bottom, renderPage, mode)
{
	if (renderPage == true) {
		middle =  '/servlet/SiteBuilderServlet?Command=RenderPage&PageNum=' + Get_Cookie('page_num') + '&Mode=' + mode + '&RenderError=/trellix/sitebuilder/f_error.jsp';
	}
	
	if (Get_Cookie('help_page') == '') {
		help_page = 'unavailable';
	}
	else {
		help_page = Get_Cookie('help_page');
	}	

	if ((Get_Cookie('help') == '1') && (Get_Cookie('map') == '1')) {
		document.write('<FRAMESET ROWS="*, 50, 60" FRAMESPACING="0" FRAMEBORDER="0" BORDER="0">');
		document.write('<FRAMESET COLS="78%,*" FRAMESPACING="0" FRAMEBORDER="0" BORDER="0">');
		document.write('<FRAME NAME="fBody" SRC="' + middle + '" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="auto" FRAMEBORDER="0">');
		document.write('<FRAMESET ROWS="52, *, 26" FRAMESPACING="0" FRAMEBORDER="0" BORDER="0">');
		document.write('<FRAME SRC="/trellix/sitebuilder/help_bkgnd_top.html" FRAMEBORDER="0" SCROLLING="No" NORESIZE MARGINWIDTH="10" MARGINHEIGHT="10">');
		document.write('<FRAME NAME="fHelp" SRC="/trellix/sitebuilder/help/help_' + help_page + '.html" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="auto" FRAMEBORDER="0">');
		document.write('<FRAME SRC="/trellix/sitebuilder/help_bkgnd_bot.html" FRAMEBORDER="0" SCROLLING="No" NORESIZE MARGINWIDTH="10" MARGINHEIGHT="10">');
		document.write('</FRAMESET>');
		document.write('</FRAMESET>');
		document.write('<FRAME NAME="fMap" SRC="/trellix/sitebuilder/map.html" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="No" NORESIZE FRAMEBORDER="0">');		
		document.write('<FRAME SRC="' + bottom + '" NAME="fBottom" FRAMEBORDER="0" SCROLLING="No" MARGINWIDTH="0" MARGINHEIGHT="0" FRAMESPACING="0">');
		document.write('</FRAMESET>');	
	}	
	else if (Get_Cookie('help') == '1') {
		document.write('<FRAMESET ROWS="*, 60" FRAMESPACING="0" FRAMEBORDER="0" BORDER="0">');
		document.write('<FRAMESET COLS="78%,*" FRAMESPACING="0" FRAMEBORDER="0" BORDER="0">');
		document.write('<FRAME NAME="fBody" SRC="' + middle + '" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="auto" FRAMEBORDER="0">');
		document.write('<FRAMESET ROWS="52, *, 26" FRAMESPACING="0" FRAMEBORDER="0" BORDER="0">');
		document.write('<FRAME SRC="/trellix/sitebuilder/help_bkgnd_top.html" FRAMEBORDER="0" SCROLLING="No" NORESIZE MARGINWIDTH="10" MARGINHEIGHT="10">');
		document.write('<FRAME NAME="fHelp" SRC="/trellix/sitebuilder/help/help_' + help_page + '.html" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="auto" FRAMEBORDER="0">');
		document.write('<FRAME SRC="/trellix/sitebuilder/help_bkgnd_bot.html" FRAMEBORDER="0" SCROLLING="No" NORESIZE MARGINWIDTH="10" MARGINHEIGHT="10">');
		document.write('</FRAMESET>');
		document.write('</FRAMESET>');
		document.write('<FRAME SRC="' + bottom + '" NAME="fBottom" FRAMEBORDER="0" SCROLLING="No" MARGINWIDTH="0" MARGINHEIGHT="0" FRAMESPACING="0">');
		document.write('</FRAMESET>');
	}
	else if (Get_Cookie('map') == '1') {
		document.write('<FRAMESET  ROWS="*, 50, 60" FRAMESPACING="0" FRAMEBORDER="0" BORDER="0">');
		document.write('<FRAME NAME="fBody" SRC="' + middle + '" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="auto" FRAMEBORDER="0">');
		document.write('<FRAME NAME="fMap" SRC="/trellix/sitebuilder/map.html" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="No" NORESIZE FRAMEBORDER="0">');
		document.write('<FRAME NAME="fBottom" SRC="' + bottom + '" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="auto" FRAMEBORDER="0">');
		document.write('</FRAMESET>');
	}
	else {
		document.write('<FRAMESET ROWS="*, 60" FRAMESPACING="0" FRAMEBORDER="0" NORESIZE="YES" MARGINWIDTH="0" MARGINHEIGHT="0" BORDER="0">');
	    document.write('<FRAME SRC="' + middle + '" NAME="fBody" FRAMEBORDER="0" SCROLLING="Auto" MARGINWIDTH="0" MARGINHEIGHT="0" FRAMESPACING="0">');
		document.write('<FRAME SRC="' + bottom + '" NAME="fBottom" FRAMEBORDER="0" SCROLLING="No" MARGINWIDTH="0" MARGINHEIGHT="0" FRAMESPACING="0">');
		document.write('</FRAMESET>');	
	}	
}

function StripSpaces(buf)
{
	while (buf.substring(0,1) == ' ') buf = buf.substring(1);
	while (buf.substring(buf.length-1, buf.length) == ' ') buf = buf.substring(0, buf.length-1);
	return buf;
}

function WriteHelpButton(load, isTextIcon, level, wait, helpfn)
{
	var src = "";

	if (level) {
		for (i=0; i < level; i++) {
			src = src + '../';
		}
	}
	
	src += 'images';

	var helppfx = '<A HREF="javascript:';
	if( helpfn ) {
		helppfx = helppfx + helpfn + '(';
	} else {
		helppfx = helppfx + 'Help(';
	}
	
	var helpsuf = ')">';
	if( wait ) {
		helpsuf = ', true' + helpsuf;
	}

	document.write(helppfx + '\'' + load + '\'' + helpsuf);

	if (Get_Cookie('help') == '1') {
		if(isTextIcon){
			document.write('<IMG SRC="' + src + '/btn_tb_helpoff_text.gif" BORDER="0" ALT="Help Off" WIDTH="41" HEIGHT="20">');
		}
		else{
			document.write('<IMG SRC="' + src + '/btn_tb_helpoff.gif" BORDER="0" ALT="Help Off" WIDTH="41" HEIGHT="30">');
		}
	}
	else {
		if (isTextIcon) {
			document.write('<IMG SRC="' + src + '/btn_tb_helpon_text.gif" BORDER="0" ALT="Help On" WIDTH="41" HEIGHT="20">');
		}
		else{
			document.write('<IMG SRC="' + src + '/btn_tb_helpon.gif" BORDER="0" ALT="Help On" WIDTH="41" HEIGHT="30">');
		}
	}
	
	document.write('</A>');
}

function WriteMapButton(load)
{
	document.write('<A HREF="javascript:Map(\'' + load + '\')">');

	if (Get_Cookie('map') == '1') {
		document.write('<IMG SRC="images/btn_tb_mapoff.gif" BORDER="0" ALT="Map Off" WIDTH="50" HEIGHT="50">');
	}
	else {
		document.write('<IMG SRC="images/btn_tb_mapon.gif" BORDER="0" ALT="Map On" WIDTH="50" HEIGHT="50">');
	}
	
	document.write('</A>');
}

function NotAvailableMsg()
{
	alert('Not available.');
}

function UrlCheck(url)
{
	if ((url.indexOf('http://') == 0) || (url.indexOf('https://') == 0) || (url.indexOf('ftp://') == 0)) {
		return url;
	}
	else {
		return 'http://' + url;
	}
}

function isValidURLDirectoryName(string)
{
 	if (string.search(/^\w+((-\w+)|(\.\w+))*$/) != -1)
        return true;
    else
        return false;
}
     
function MailCheck(url)
{
	if (url.indexOf('mailto:') == 0) {
		return url;
	}
	else {
		return 'mailto:' + url;
	}
}

function MailToCheck(url)
{
	if (url.indexOf('mailto:') == 0) {
		return url;
	}
	else {
		return 'mailto:' + url;
	}
}

function SetImage(imgName, imgDesc, imgType)
{
	Set_Main_Cookie('clipart_image', imgName, '', '/', '');
	Set_Cookie('image_type', imgType, '', '/', '');
		
	if (Get_Cookie('mode') != 'edit_picture_list') {	
		Set_Main_Cookie('clipart_desc', imgDesc, '', '/', '');
	}
	
	parent.fImageView.location.href = '/trellix/sitebuilder/picture_view.jsp';
}

function ExecImage(imgName, form, imgType)
{
	if (Get_Cookie('mode') == 'add_picture') {
		AddImage(imgName, form, imgType);
	}
	else {
		SwitchPicture(imgName, form, imgType);
	}
	
	Delete_Cookie('clipart_image', '/', '');
	Delete_Cookie('clipart_desc', '/', '');
	Delete_Cookie('image_type', '/', '');
}	

function ExecLayoutDesign(mode)
{
	top.location.href = '/trellix/sitebuilder/f_layout_design_chooser.jsp?tlxReturnUrl=/trellix/sitebuilder/f_edit_page.html&tweCLsmode=0';
}

function ExecLayout(pageNum)
{
	Set_Cookie('page_num', pageNum, '', '/', '');
	top.location.href = '/trellix/sitebuilder/f_layout_design_chooser.jsp?tlxReturnUrl=/trellix/sitebuilder/f_site_organizer.html&tweCLsmode=3';
}

function ExecDesign(pageNum)
{
	Set_Cookie('page_num', pageNum, '', '/', '');
	top.location.href = '/trellix/sitebuilder/f_layout_design_chooser.jsp?tlxReturnUrl=/trellix/sitebuilder/f_site_organizer.html&tweCLsmode=1';
}

function ExecMovePage(pageNum)
{
	Set_Cookie('page_num', pageNum, '', '/', '');
	top.location.href = '/trellix/sitebuilder/f_page_move.html';	
}

function IsValidFileExt(file, ext)
{
	return ((file.indexOf(ext) != -1) && !(file.indexOf(ext) == 0) && (file.indexOf(ext) == strTest.length - ext.length));
}

function IsValidFileName(file)
{
	//chars = ' \\/:*?"<>|';
	chars = ' !"#$%&\'()*+,/:;<=>?@[\\]^`{|}~';  
    if (file.indexOf('.') == 0)
        return false;  
	for (i=0; i < chars.length; i++) {
		if (file.indexOf(chars.charAt(i)) > -1) {
			return false;
		}
	}
	
	return true;
}

function getErrorMessageInvalidFileName()
{
    return "Please enter a valid file name. The following characters are not valid  !\"#$%&'()*+,/:;<=>?@[\\]^`{|}~ and spaces. A period '.' cannot be used as a first character.";
}         
            
function isInteger(buf)
{   
	var i;

	for (i=0; i < buf.length; i++) {   
		var c = buf.charAt(i);
		if (!isDigit(c)) return false;
	}

	return true;
}

function isDigit(c)
{
	return ((c >= "0") && (c <= "9"));
}

function isLetter(c)
{
	return (((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")));
}

function isNotExtChar(c)
{
	return (((c >= ' ') && (c <= '~')));
}

function isLatin1(s)
{
	var i;

    for (i = 0; i < s.length; i++) {   
		var c = s.charAt(i);

		if (! (isLatin1Char(c)))
		    return false;
	}

	return true;
}
         
function isLatin1Char(c)
{
    var ci = c.charCodeAt(0);
	return (ci <= 255 && (ci >= 32 || (ci == 10) || (ci == 13) || (ci == 9)));
}

function getLatin1OnlyString(s)
{
	var i;
    var str = '';
    
    for (i = 0; i < s.length; i++) {   
		var c = s.charAt(i);

		if (isLatin1Char(c))
		    str = str + c;
	}

	return str;
}

function isAlphanumeric(s)
{
	var i;

    for (i = 0; i < s.length; i++) {   
		var c = s.charAt(i);

		if (! (isLetter(c) || isDigit(c) || c == ' '))
		return false;
	}

	return true;
}

function isNotExt(s)
{
	var i;

    for (i = 0; i < s.length; i++) {   
		var c = s.charAt(i);

		if (! (isNotExtChar(c)))
		return false;
	}

	return true;
}

function layoutNameLookup(layoutnum)
{
	var layoutNames = new Array();

    layoutNames[1] = "Home";

    layoutNames[2] = "1 column";

    layoutNames[3] = "2 column";

    layoutNames[4] = "2 column offset";

    layoutNames[5] = "3 column";

    layoutNames[6] = "Photo album";

    layoutNames[7] = "Main area 1 secondary";

    layoutNames[8] = "Main area 2 secondary";

	return layoutNames[layoutnum * 1];
}

function designNameLookup(design)
{
	var designFiles = new Array();
	var designNames = new Array();


    designFiles[0] = "000_angleblue";
    designNames[0] = "Angle Blue";

    designFiles[1] = "000_anglegreen";
    designNames[1] = "Angle Green";

    designFiles[2] = "000_anglegry";
    designNames[2] = "Angle Gray";

    designFiles[3] = "000_angleorange";
    designNames[3] = "Angle Orange";

    designFiles[4] = "000_anglepurp";
    designNames[4] = "Angle Purple";

    designFiles[5] = "000_blackhole";
    designNames[5] = "Black Hole";

    designFiles[6] = "000_borg";
    designNames[6] = "Borg";

    designFiles[7] = "000_boxes";
    designNames[7] = "Boxes Blue";

    designFiles[8] = "000_boxesbrown";
    designNames[8] = "Boxes Brown";

    designFiles[9] = "000_boxesgray";
    designNames[9] = "Boxes Gray";

    designFiles[10] = "000_boxesred";
    designNames[10] = "Boxes Red";

    designFiles[11] = "000_bubbles";
    designNames[11] = "Bubbles";

    designFiles[12] = "000_fadedblue";
    designNames[12] = "Faded Blue";

    designFiles[13] = "000_fadedgreen";
    designNames[13] = "Faded Green";

    designFiles[14] = "000_fadedorange";
    designNames[14] = "Faded Orange";

    designFiles[15] = "000_fadedpurp";
    designNames[15] = "Faded Purple";

    designFiles[16] = "000_fadedrose";
    designNames[16] = "Faded Rose";

    designFiles[17] = "000_funkypurp";
    designNames[17] = "Funky Purple";

    designFiles[18] = "000_goo";
    designNames[18] = "Goo Green";

    designFiles[19] = "000_goofushia";
    designNames[19] = "Goo Fuchsia";

    designFiles[20] = "000_gooorange";
    designNames[20] = "Goo Orange";

    designFiles[21] = "000_goopurp";
    designNames[21] = "Goo Purple";

    designFiles[22] = "000_nature";
    designNames[22] = "Nature";

    designFiles[23] = "000_spinning";
    designNames[23] = "Spinning";

    designFiles[24] = "000_springbreak";
    designNames[24] = "Spring Break";

    designFiles[25] = "000_surf";
    designNames[25] = "Surf";

    designFiles[26] = "001_cornacopia";
    designNames[26] = "Cornucopia";

    designFiles[27] = "001_cornucopia";
    designNames[27] = "Cornucopia";

    designFiles[28] = "001_halloween";
    designNames[28] = "Halloween";

    designFiles[29] = "002_dinnerrosegd";
    designNames[29] = "Dinner Rose Gold";

    designFiles[30] = "002_dock";
    designNames[30] = "Dock";

    designFiles[31] = "002_framedgreen";
    designNames[31] = "Framed Green";

    designFiles[32] = "002_framedred";
    designNames[32] = "Framed Red";

    designFiles[33] = "002_hanukah";
    designNames[33] = "Hanukah";

    designFiles[34] = "002_phase";
    designNames[34] = "Phase";

    designFiles[35] = "002_photoalbumteal";
    designNames[35] = "Photo Album";

    designFiles[36] = "002_slidesgr";
    designNames[36] = "Slides Orange";

    designFiles[37] = "002_slidesgreen";
    designNames[37] = "Slides Green";

    designFiles[38] = "002_slidesred";
    designNames[38] = "Slides Red";

    designFiles[39] = "002_timeoff";
    designNames[39] = "Time Off";

    designFiles[40] = "002_toysoldiers";
    designNames[40] = "Toy Soldiers";

    designFiles[41] = "003_autumn";
    designNames[41] = "Autumn";

    designFiles[42] = "003_batikblue";
    designNames[42] = "Batik Blue";

    designFiles[43] = "003_blueprint";
    designNames[43] = "Blueprint";

    designFiles[44] = "003_celebration";
    designNames[44] = "Celebration";

    designFiles[45] = "003_chips";
    designNames[45] = "Chips";

    designFiles[46] = "003_crossroads";
    designNames[46] = "Crossroads";

    designFiles[47] = "003_desert";
    designNames[47] = "Desert";

    designFiles[48] = "003_evergreen";
    designNames[48] = "Evergreen";

    designFiles[49] = "003_filmstrip";
    designNames[49] = "Film Strip";

    designFiles[50] = "003_flyingboxes";
    designNames[50] = "Flying Boxes";

    designFiles[51] = "003_graduation";
    designNames[51] = "Graduation";

    designFiles[52] = "003_group";
    designNames[52] = "Group";

    designFiles[53] = "003_g_aqua";
    designNames[53] = "Aqua";

    designFiles[54] = "003_g_bluependulum";
    designNames[54] = "Pendulum Blue";

    designFiles[55] = "003_g_concentric";
    designNames[55] = "Concentric";

    designFiles[56] = "003_g_cornerblue";
    designNames[56] = "Corner Blue";

    designFiles[57] = "003_g_cornergold";
    designNames[57] = "Corner Gold";

    designFiles[58] = "003_g_finance";
    designNames[58] = "Batik Blue";

    designFiles[59] = "003_g_greenrectangle";
    designNames[59] = "Rectangle Green";

    designFiles[60] = "003_g_indigoblue";
    designNames[60] = "Indigo Blue";

    designFiles[61] = "003_g_lawyer";
    designNames[61] = "Lawyer";

    designFiles[62] = "003_g_realestate";
    designNames[62] = "Real Estate";

    designFiles[63] = "003_g_rectanglegreen";
    designNames[63] = "Rectangle Green";

    designFiles[64] = "003_g_softpink";
    designNames[64] = "Soft Pink";

    designFiles[65] = "003_g_summerblue";
    designNames[65] = "Summer Blue";

    designFiles[66] = "003_g_summerorange";
    designNames[66] = "Summer Orange";

    designFiles[67] = "003_g_technodots";
    designNames[67] = "Technodots";

    designFiles[68] = "003_handprint";
    designNames[68] = "Handprint";

    designFiles[69] = "003_houses";
    designNames[69] = "Houses";

    designFiles[70] = "003_lipstick";
    designNames[70] = "Lipstick";

    designFiles[71] = "003_lonestar";
    designNames[71] = "Lonestar";

    designFiles[72] = "003_miami";
    designNames[72] = "Miami";

    designFiles[73] = "003_musical";
    designNames[73] = "Musical";

    designFiles[74] = "003_mustard";
    designNames[74] = "Mustard";

    designFiles[75] = "003_mycraft";
    designNames[75] = "My Craft";

    designFiles[76] = "003_odyssey";
    designNames[76] = "Odyssey";

    designFiles[77] = "003_olive";
    designNames[77] = "Olive";

    designFiles[78] = "003_party";
    designNames[78] = "Party";

    designFiles[79] = "003_pencil";
    designNames[79] = "Pencil";

    designFiles[80] = "003_photonotebook";
    designNames[80] = "Photo Notebook";

    designFiles[81] = "003_pinball";
    designNames[81] = "Pinball";

    designFiles[82] = "003_playground";
    designNames[82] = "Playground";

    designFiles[83] = "003_simpleolive";
    designNames[83] = "Simple Olive";

    designFiles[84] = "003_simpleteal";
    designNames[84] = "Simple Teal";

    designFiles[85] = "003_spoons";
    designNames[85] = "Spoons";

    designFiles[86] = "003_star1";
    designNames[86] = "Star One";

    designFiles[87] = "003_star2";
    designNames[87] = "Star Two";

    designFiles[88] = "003_sunnybubble";
    designNames[88] = "Sunny Bubble";

    designFiles[89] = "003_tabs";
    designNames[89] = "Tabs";

    designFiles[90] = "003_teamred";
    designNames[90] = "Team Red";

    designFiles[91] = "003_testpattern";
    designNames[91] = "Test Pattern";

    designFiles[92] = "003_vinyl";
    designNames[92] = "Vinyl";

    designFiles[93] = "003_wag";
    designNames[93] = "Wag";

    designFiles[94] = "003_weddingblue";
    designNames[94] = "Wedding Blue";

    designFiles[95] = "003_zigzaggreen";
    designNames[95] = "Zig Zag Green";

    designFiles[96] = "004_g_basic_tan";
    designNames[96] = "Basic Tan";

    designFiles[97] = "004_g_beehive";
    designNames[97] = "Beehive";

    designFiles[98] = "004_g_caffeine";
    designNames[98] = "Caffeine";

    designFiles[99] = "004_g_checkers";
    designNames[99] = "Checkers";

    designFiles[100] = "004_g_chess";
    designNames[100] = "Chess";

    designFiles[101] = "004_g_citypink";
    designNames[101] = "City Pink";

    designFiles[102] = "004_g_diamondgreen";
    designNames[102] = "Diamond Green";

    designFiles[103] = "004_g_eventhorizon";
    designNames[103] = "Event Horizon";

    designFiles[104] = "004_g_festiveswirl";
    designNames[104] = "Festive Swirl";

    designFiles[105] = "004_g_formalnavy";
    designNames[105] = "Formal Navy";

    designFiles[106] = "004_g_fullmoon";
    designNames[106] = "Full Moon";

    designFiles[107] = "004_g_golfcourse";
    designNames[107] = "Golf Course";

    designFiles[108] = "004_g_kindergarden";
    designNames[108] = "Kindergarten";

    designFiles[109] = "004_g_nightgreen";
    designNames[109] = "Night Green";

    designFiles[110] = "004_g_outerspace";
    designNames[110] = "Outer Space";

    designFiles[111] = "004_g_stainedglass_b";
    designNames[111] = "Stained Glass Blue";

    designFiles[112] = "004_g_stripesblue";
    designNames[112] = "Stripes Blue";

    designFiles[113] = "004_g_stripesyellow";
    designNames[113] = "Stripes Yellow";

    designFiles[114] = "004_se_child_xmas";
    designNames[114] = "Child's Christmas";

    designFiles[115] = "004_se_clover";
    designNames[115] = "Clover";

    designFiles[116] = "004_se_easteregg";
    designNames[116] = "Easter Egg";

    designFiles[117] = "004_se_fireworks";
    designNames[117] = "Fireworks";

    designFiles[118] = "004_se_thanksgiving";
    designNames[118] = "Thanksgiving";

    designFiles[119] = "004_tvshow";
    designNames[119] = "TV Show";

    designFiles[120] = "004_veggiegarden";
    designNames[120] = "Veggie Garden";

    designFiles[121] = "006_basicplainblack";
    designNames[121] = "Plain Black";

    designFiles[122] = "006_basicplainwhite";
    designNames[122] = "Plain White";


    for (i = 0; i < designFiles.length; i++)
    {
        if ( designFiles[i] == design )
        {
            return designNames[i];
        }
    }
    return design;
}

function designHasTwiddles(design)
{
	var designFiles = new Array();


    designFiles[0] = "004_g_basic_tan";

    designFiles[1] = "004_g_chess";

    designFiles[2] = "004_g_outerspace";

    designFiles[3] = "004_g_stripesblue";


    for (i = 0; i < designFiles.length; i++)
    {
        if ( designFiles[i] == design )
        {
			return 1;
        }
    }
    return 0;
}

function templateNameLookup(template)
{
	var templateFiles = new Array();
	var templateNames = new Array();


    templateFiles[0] = "anniversarycard.xml";
    templateNames[0] = "Anniversary Card";

    templateFiles[1] = "artsevent.xml";
    templateNames[1] = "Arts Event";

    templateFiles[2] = "autoracingfan.xml";
    templateNames[2] = "Auto Racing Fan Site";

    templateFiles[3] = "autorepair.xml";
    templateNames[3] = "Automobile Sales and Service";

    templateFiles[4] = "babyannouncement.xml";
    templateNames[4] = "Baby Announcement";

    templateFiles[5] = "birthdaycard.xml";
    templateNames[5] = "Birthday Card";

    templateFiles[6] = "blank.xml";
    templateNames[6] = "Blank (Start From Scratch)";

    templateFiles[7] = "campaigning.xml";
    templateNames[7] = "Campaigning and Government";

    templateFiles[8] = "club.xml";
    templateNames[8] = "About My Club";

    templateFiles[9] = "collector.xml";
    templateNames[9] = "Collector and Trading Site";

    templateFiles[10] = "computerservices.xml";
    templateNames[10] = "Computer Services";

    templateFiles[11] = "const_arch.xml";
    templateNames[11] = "Construction and Architecture";

    templateFiles[12] = "consulting.xml";
    templateNames[12] = "Consulting";

    templateFiles[13] = "daycare.xml";
    templateNames[13] = "Daycare";

    templateFiles[14] = "education.xml";
    templateNames[14] = "Education";

    templateFiles[15] = "entertain_rec.xml";
    templateNames[15] = "Entertainment and Recreation";

    templateFiles[16] = "ezine.xml";
    templateNames[16] = "E-Zine (Online Magazine)";

    templateFiles[17] = "faithandbelief.xml";
    templateNames[17] = "My Faith and Belief Site";

    templateFiles[18] = "familytree.xml";
    templateNames[18] = "Family Tree (Genealogy Site)";

    templateFiles[19] = "favoriteband.xml";
    templateNames[19] = "Favorite Band or Musician";

    templateFiles[20] = "favoritestar.xml";
    templateNames[20] = "Favorite Star";

    templateFiles[21] = "favoriteteam.xml";
    templateNames[21] = "Favorite Sports Team";

    templateFiles[22] = "favoritetvshow.xml";
    templateNames[22] = "Favorite TV Show";

    templateFiles[23] = "financial_serv.xml";
    templateNames[23] = "Financial Services";

    templateFiles[24] = "fitnessandbeauty.xml";
    templateNames[24] = "Fitness and Beauty";

    templateFiles[25] = "gamers.xml";
    templateNames[25] = "Gamer's How-To";

    templateFiles[26] = "gardening.xml";
    templateNames[26] = "My Gardening Site";

    templateFiles[27] = "general_service.xml";
    templateNames[27] = "General Services";

    templateFiles[28] = "giftwishlist.xml";
    templateNames[28] = "Gift Wish List";

    templateFiles[29] = "graduation.xml";
    templateNames[29] = "Graduation Album";

    templateFiles[30] = "healthcare.xml";
    templateNames[30] = "Healthcare";

    templateFiles[31] = "hobby.xml";
    templateNames[31] = "Hobby and How-To";

    templateFiles[32] = "insurance.xml";
    templateNames[32] = "Insurance";

    templateFiles[33] = "legal.xml";
    templateNames[33] = "Legal Services";

    templateFiles[34] = "lodging.xml";
    templateNames[34] = "Lodging";

    templateFiles[35] = "main_test_template.xml";
    templateNames[35] = "Main Test Template";

    templateFiles[36] = "manufacturing.xml";
    templateNames[36] = "Manufacturing";

    templateFiles[37] = "membershiporganization.xml";
    templateNames[37] = "Membership Organization";

    templateFiles[38] = "memorial.xml";
    templateNames[38] = "Memorial Site";

    templateFiles[39] = "myclass.xml";
    templateNames[39] = "About My Class";

    templateFiles[40] = "myteam.xml";
    templateNames[40] = "About My Team";

    templateFiles[41] = "newbaby.xml";
    templateNames[41] = "New Baby Album";

    templateFiles[42] = "newhouse.xml";
    templateNames[42] = "New House Album";

    templateFiles[43] = "nonprofit.xml";
    templateNames[43] = "Nonprofit Agency Site";

    templateFiles[44] = "ourfamily.xml";
    templateNames[44] = "Family Photo Album";

    templateFiles[45] = "parenting.xml";
    templateNames[45] = "My Parenting Site";

    templateFiles[46] = "partyinvitation.xml";
    templateNames[46] = "Party Invitation";

    templateFiles[47] = "personal.xml";
    templateNames[47] = "My Personal Site";

    templateFiles[48] = "personalserv.xml";
    templateNames[48] = "Personal Services";

    templateFiles[49] = "pets.xml";
    templateNames[49] = "My Pets";

    templateFiles[50] = "photo_album.xml";
    templateNames[50] = "General Photo Album";

    templateFiles[51] = "promalbum.xml";
    templateNames[51] = "Prom Photo Album";

    templateFiles[52] = "realestate.xml";
    templateNames[52] = "Real Estate";

    templateFiles[53] = "recipes.xml";
    templateNames[53] = "My Recipes";

    templateFiles[54] = "religiousorganization.xml";
    templateNames[54] = "Religious Organization";

    templateFiles[55] = "restaurant.xml";
    templateNames[55] = "Restaurant";

    templateFiles[56] = "resume.xml";
    templateNames[56] = "Online Resume";

    templateFiles[57] = "smallbusiness.xml";
    templateNames[57] = "Small Business";

    templateFiles[58] = "teenparty.xml";
    templateNames[58] = "Party Photo Album";

    templateFiles[59] = "teenpersonal.xml";
    templateNames[59] = "Cool Personal Site";

    templateFiles[60] = "telecommunications.xml";
    templateNames[60] = "Telecommunications";

    templateFiles[61] = "trade.xml";
    templateNames[61] = "Trade Contractors";

    templateFiles[62] = "transportation.xml";
    templateNames[62] = "Transportation";

    templateFiles[63] = "vacation.xml";
    templateNames[63] = "Vacation Album";

    templateFiles[64] = "weblog.xml";
    templateNames[64] = "Weblog (Online Diary)";

    templateFiles[65] = "wedding.xml";
    templateNames[65] = "Wedding Album";

    templateFiles[66] = "wiz_aboutme.xml";
    templateNames[66] = "About Me";

    templateFiles[67] = "wiz_aboutmybusiness.xml";
    templateNames[67] = "About My Business";

    templateFiles[68] = "wiz_aboutmyorganization.xml";
    templateNames[68] = "About My Organization";

    templateFiles[69] = "wiz_babyannouncement.xml";
    templateNames[69] = "Baby Announcement";

    templateFiles[70] = "wiz_birthday.xml";
    templateNames[70] = "Birthday Card";

    templateFiles[71] = "wiz_businesscard.xml";
    templateNames[71] = "Business Card";

    templateFiles[72] = "wiz_faveband.xml";
    templateNames[72] = "Favorite Band or Musician";

    templateFiles[73] = "wiz_forsale.xml";
    templateNames[73] = "Items for Sale";

    templateFiles[74] = "wiz_partyinvite.xml";
    templateNames[74] = "Party Invitation";

    templateFiles[75] = "wiz_photoalbum.xml";
    templateNames[75] = "Photo Album";

    templateFiles[76] = "wiz_vacationpostcard.xml";
    templateNames[76] = "Vacation Postcard";

    templateFiles[77] = "wiz_weddingfactsheet.xml";
    templateNames[77] = "Wedding Fact Sheet";


    for (i = 0; i < templateFiles.length; i++)
    {
        if ( templateFiles[i] == template )
        {
            return templateNames[i];
        }
    }
    return template;
}

function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function isNameAllLowercase(str)
{
	for (i = 0; i < str.length; i++) {   
	  var c = str.charAt(i);
	  if (isUppercase(c))
		  return false;
	}
	return true;
}   

function isUppercase(c){
	return ('A' <= c && c <= 'Z');
}


function isSiteExist(sites, publishName, index){
	for (i = 0; i < index; i++) {
		if (sites[i] == publishName) {
			return true;
		}
	}
	return false;
}

function logPageView(action,layout,refresh)
{
    // load blank.gif logging image
    var randVal;
    randVal = Math.random();
    randVal = Math.floor(randVal * 32768);
    var logimg = new Image();
    var pg = top.location.href;
    var pos = pg.lastIndexOf('/');
    if (pos >= 0) pg = pg.substring(pos+1);
    pos = pg.indexOf('?');
    if (pos >= 0) pg = pg.substring(0,pos);
    logimg.src = '/trellix/sitebuilder/images/blank.gif?log=1&page='+pg+'&action='+action+'&layout='+layout+'&refresh='+refresh+'&r='+randVal;
}

function OpenNewWin(loc, wd, ht, winname)
{
    var xloc = (screen.width - wd) / 2;
    var yloc = (screen.height - ht) / 2;
    if (winname == null || winname == '')
        winname = 'popUp';
    var winHelp = window.open(loc, winname,'width='+wd+',height='+ht+'innerwidth='+wd+',innerheight='+ht+',left='+xloc+',top='+yloc+',resizeable=no');
    if (!winHelp.focus()) {
        winHelp.focus();
    }	



}

