var ie4 = (document.all) ? true : false;
var ie5 = ( navigator.appVersion.indexOf("MSIE 5") != -1 );
var ns4 = (document.layers) ? true : false;
var mac = (navigator.userAgent.indexOf("Mac") != -1) ? true : false;
var ns6 = ( (navigator.appName.indexOf("Netscape") != -1) && parseInt(navigator.appVersion) >= 5 );

if (ns4) { window.onresize=fixMe; }
if (ns4) { origWidth = innerWidth; origHeight = innerHeight; }
function fixMe() { if (innerWidth != origWidth || innerHeight != origHeight) self.location.reload(); }

var previousLine = 2;
var lines = [ "tag0", "tag1", "tag2" ];
var home = false;

function rotate() {
	if (previousLine < lines.length-1) {
		Show(lines[previousLine+1]);
		Hide(lines[previousLine]);
		previousLine++;
		setTimeout("rotate()", 3000);
	}
	else {
		Show(lines[0]);
		Hide(lines[lines.length-1]);
		previousLine = 0;
		setTimeout("rotate()", 3000);
	}
}

var onLine      = (location.hostname.indexOf('renotex.') != -1);
var localPath   = "/Macintosh%20HD/Desktop%20Folder/Samrod/www/Samgod/renotex/";
var currentPage = (onLine) ? location.pathname.replace(/\.html/, '') : location.pathname.replace(localPath, '').replace(/\.html/, '');
var globPath	= (onLine) ? "/" : localPath;
var currentPath = currentPage.split('/');
var currentSect = currentPath[1];
var active = false, header;

var linkTemplate = '\n		<tr><td class="subLinks"' + ( (ns4) ? '>&nbsp; &nbsp;' : ' nowrap="nowrap">' ) + '<a href="' + globPath + '@@HREF@@">@@TEXT@@</a></td></tr>';
var actvTemplate = '\n		<tr><td class="subLinks"' + ( (ns4) ? '>&nbsp; &nbsp;' : ' nowrap="nowrap">' ) + '@@TEXT@@</td></tr>';
var headTemplate = '\n		<tr><td class="h4"><a href="' + globPath + '@@HREF@@">@@TEXT@@</a></td></tr>';
var actvHeadTmpl = '\n		<tr><td class="h4">@@TEXT@@</td></tr>';
var blackLine = '\n		<tr><td bgcolor="black"><img src="' + globPath + 'img/casper.gif" alt="" width="1" height="1" /></td></tr>' + ( (ns4) ? '\n		<tr><td><img src="' + globPath + 'img/casper.gif" alt="" width="1" height="5" /></td></tr>' : '' );


function navLink(title, href, template, kids) {
	this.title = title;
	this.href  = href;
	this.template = (template) ? template : linkTemplate;
	this.kids = (kids);
}

var preOut = '', postOut = '', leftOut = '';
var navLinks = [
	 new navLink('About Us',					'AboutUs/Profile.html',			headTemplate,	true)
	,new navLink('Company Profile',				'AboutUs/Profile.html')
	,new navLink('Staff',						'AboutUs/Staff.html')

	,new navLink('Services',					'Services/Carpet.html',			headTemplate,	true)
	,new navLink('Carpet Cleaning',				'Services/Carpet.html')
	,new navLink('Oriental &amp; Area Rugs',	'Services/Oriental.html')
	,new navLink('Furniture Cleaning',			'Services/Furniture.html')
	,new navLink('Fabric Wall &amp; Partition Cleaning',	'Services/Fabric.html')
	,new navLink('Spot Cleaning',				'Services/Spot.html')
	,new navLink('Power Pile Brushing',			'Services/Power.html')
	,new navLink('Wood Polishing',				'Services/Wood.html')
	,new navLink('Treatments',					'Services/Treatments.html')
	,new navLink('Hard Surface Floors',			'Services/Hard.html')

	,new navLink('Cleaning Methods',			'CleaningMethods/index.html',	headTemplate,	true)
	,new navLink('Rotary Shampoo',				'CleaningMethods/index.html#Rotary')
	,new navLink('Hot Water Extraction (Steam)','CleaningMethods/index.html#Steam')
	,new navLink('Dry',							'CleaningMethods/index.html#Dry')
	,new navLink('Bonnet/Absorbent Pad',		'CleaningMethods/index.html#Other')
	,new navLink('Dry Foam',					'CleaningMethods/index.html#Other')

	,new navLink('Commercial',					'Commercial/Maintenance.html',	headTemplate,	true)
	,new navLink('Maintenance',					'Commercial/Maintenance.html')
	,new navLink('Q &amp; A',					'Commercial/Q.html')

	,new navLink('Residential',					'Residential/',					headTemplate)
	,new navLink('Affiliations',				'Affiliations/',				headTemplate)
	,new navLink('Contact Us',					'ContactUs/',					headTemplate)
];

function leftbar() {
	var leftOut = '';
	if (!home) {
		leftOut = '\n	<table border="0" cellpadding="0" cellspacing="0" width="100%">';
		for (var x=0; x < navLinks.length; x++) {
			var thisLink = navLinks[x];

			active = ( '/' + thisLink.href.replace(/\.html/, '') == currentPage && !thisLink.kids ) ? true : false;

			if (thisLink.template == headTemplate) {
				header = thisLink.href.split('/')[0];
				if (active) thisLink.template = actvHeadTmpl;
				leftOut += thisLink.template.replace(/\@\@HREF\@\@/g, thisLink.href).replace(/\@\@TEXT\@\@/g, thisLink.title);
			}
			else if (header == currentSect) {
				if (active) thisLink.template = actvTemplate;
				leftOut += thisLink.template.replace(/\@\@HREF\@\@/g, thisLink.href).replace(/\@\@TEXT\@\@/g, thisLink.title);
			}
			if (active) leftOut += blackLine;
		}
		leftOut += '</td></tr>\n	</table><br />\n	<img src="' + globPath + 'img/titles/' + currentSect + '.gif" alt="" /><br /><br />';
	}
//	Debug(leftOut, true);
	return leftOut;
}

function footer() {
	var footOut = '<div id="Footer"><nobr>&nbsp; <span class="menuLinks"><a href="' + globPath + '">Home</a>&nbsp; |&nbsp; </span>',
		separator = '&nbsp; |&nbsp; </span>';
	for (var f=0; f < navLinks.length; f++) {
		var thisLink = navLinks[f],
			head = (thisLink.href.split('/')[0] != currentSect) ? thisLink.href.split('/')[0] : thisLink.href.split('/')[0]+'0';
		if (f == navLinks.length-1) separator = '</span></nobr></div>';
		if (thisLink.href.indexOf(".html") == -1 || thisLink.template == headTemplate ) footOut += '\n	<span id="' + head + '"><span class="menuLinks"><a href="' + globPath + thisLink.href + '">' + thisLink.title + '</a></span>' + separator;
	}
	return footOut;
}

function getPre(page) {
	preOut +=
			'\n<table border="0" cellpadding="0" cellspacing="0" width="100%">'
		+	'\n<tr><td width="20" rowspan="3"><img src="' + globPath + 'img/casper.gif" alt="" width="20" height="475" /></td>'
		+	'\n	<td valign="top" rowspan="3" width="125" id="' + currentSect + '">'
		+	( (!home)
		?	'\n		<table border="0" cellpadding="0" cellspacing="0" width="125">'
		+	'\n			<td background="' + globPath + 'img/microscope.gif" class="menuLinks" align="center"' + ( (ns4)
		?	' valign="middle"><img src="' + globPath + 'img/casper.gif" width="125" height="1" border="0" /><br /><a href="' + globPath + '"><font color="black">h &nbsp; o &nbsp; m &nbsp; e</font></a></td>'
		+	'\n			<td><img src="' + globPath + 'img/casper.gif" width="1" height="126" /></td>' : '>'
		+	'\n				<a href="' + globPath + '"><img src="' + globPath + 'img/casper.gif" width="125" height="58" border="0" /><br />'
		+	'\n				<span style="color:black;">h &nbsp; o &nbsp; m &nbsp; e</span><br />'
		+	'\n				<img src="' + globPath + 'img/casper.gif" width="125" height="54" border="0" /></a> </td>') + ''
		+	'\n		</table>'
		:	'<img src="' + globPath + 'img/microscope.gif" alt="" width="125" height="126" />' ) + '<br />' + leftbar() + '</td>'
		+	'\n	<td><img src="' + globPath + 'img/casper.gif" alt="" width="15" height="20" /></td>'
		+	'\n	<td><img src="' + globPath + 'img/logo.gif" width="460" height="50" alt="renotex corporation, 229 tenth avenue, new york, ny, 10011" /><br />'
		+	'\n		<img src="' + globPath + 'img/casper.gif" alt="" width="100" height="10" /></td>'
		+	'\n</tr>'
		
		+	'\n<tr><td width="15"><img src="' + globPath + 'img/casper.gif" alt="" width="15" height="400" /></td>'
		+	'\n	<td valign="top" id="SandBox"><img src="' + globPath + 'img/casper.gif" alt="" width="200" height="5" /><br />'
		if (!home) {
			preOut +=	'\n		<table border="0" cellpadding="0" cellspacing="0" height="100%">'
					+	'\n		<td bgcolor="black" width="1"><img src="' + globPath + 'img/black.gif" alt="" width="1" height="500=" /></td>'
					+	'\n		<td bgcolor="white" valign="top">';
		}
	document.write( preOut );
//	Debug( preOut, true );
}

function getPost() {
	if (!home) {
		postOut += '<br clear="all"></td>'
				+	'\n		</table>';
	}
	postOut += '</td>'
		+	'\n</tr>'
		+	'\n<tr><td colspan="4" bgcolor="black"><img src="' + globPath + 'img/casper.gif" alt="" width="200" height="1" /></td></tr>'
		+	'\n<tr><td colspan="3" valign="top" class="fine" nowrap="nowrap">&nbsp;&copy; 2006 Renotex Services LLC.</td>'
		+	'\n	<td valign="top" '+ ( (home) ? 'class="h3">' : '>' + footer() ) + '</td>'
		+	'\n</tr>'
		+	'\n</table>'
		+	'\n<div align="center"><hr style="width: 100%;" />'
		+	'\n<font size="-1">Carpet Cleaning NYC,Westchester,NJ,Conn - RENOTEX - SPECIALTY CLEANERS SERVING THE TRI-STATE AREA.<br />'
		+	'\nSpecialists in carpet, upholstered &amp; leather furniture, and fabric wall/partition cleaning since 1945.&nbsp; Centrally located in Bronx serving NYC,Riverdale,Westchester,NJ,CT - carpet cleaning New York City</font></div>';

	document.write( postOut );
}

function Show(y) {
	if (ns4) document.layers[y].document.ids[y+'Links'].visibility = "show";
	else document.getElementById(y+"Links").style.visibility = "visible";
}
function Hide(y) {
	if (ns4) document.layers[y].document.ids[y+'Links'].visibility = "hidden";
	else document.getElementById(y+"Links").style.visibility = "hidden";
}

function Position(layer,t,l) {
	if (!ns6) {
		if(t) eval( d + layer + s + "top = " + t );
		if(l) eval( d + layer + s + "left = " + l );
	}
	else {
		document.getElementById(layer).style.top = t;
		document.getElementById(layer).style.left = l;
	}
}

function Clip(layer,t,r,b,l) {
	if (document.all) {
		document.all[layer].style.clip = "rect(" + t + "," + r + "," + b + "," + l + ")";
	}
	else {
		document.layers[layer].clip.top		= t;
		document.layers[layer].clip.right	= r;
		document.layers[layer].clip.bottom	= b;
		document.layers[layer].clip.left	= l;
	}
}

function Debug(str,code) {
	str_debug = "";
	if ( code ) { str_debug += "<plaintext>"; }
	str_debug += "<body marginheight=0 marginwidth=0>\n\n";
	str_debug += str + "\n\n</body>";
	win_debug = window.open();
	win_debug.document.write(str_debug);
}

function BreakString( string, maxlength, replacethis, withthis ) {
	if ( string.length > maxlength ) string = string.replace( replacethis, withthis );
	document.write( string );
}

// innerHTML functionality for ns4
function NSinnerHTML() {	
	this.document.open();	
	this.document.write(arguments[2]);	
	this.document.close();	
	return arguments[2];	
//	document.layers["myDivName"].innerHTML = "";	
//	document.layers["myDivName"].watch("innerHTML",NSinnerHTML);	
}

function DoNothing() { return true; }