//////////////////////////////////////////////////////////////////////////////
//  Tlwoods.com Script
//  Copyright 2001-09 by Birdsoft (Brian Heilman)
//
//  This code can only be used under license. Any unauthorized use is strictly
//  prohibited. This is not Freeware or Shareware!!! 
//


function GetCookie (name) 
{  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) 
	{
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
			return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) 
			break;   
	}  
	return null;
}

function SetCookie (name, value) 
{  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) 
{  
//	SetCookie (name,null);
	var exp = new Date();  
	exp.setTime (exp.getTime() - 100);   
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function getCookieVal(offset) 
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}


//Formatting to 0.00 form

function formatCurrency(num) 
{

	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num)) num = "0";
		cents = Math.floor((num*100+0.5)%100);
//		cents = Math.floor((num*10+0.5)%10);

	num = Math.floor((num*100+0.5)/100).toString();
//	num = Math.floor((num*100+0.5)/10).toString();

	if(cents < 10) 
		cents = "0" + cents;

	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));

	return (num + '.' + cents);
}




//Writes name for next time to cookie
function setPersonalizedName(value)
{
	var expIs = new Date(); 
	expIs.setTime(expIs.getTime() + (60*24*60*60*1000));//60 days

	SetCookie('PzdNameTLW',value ,expIs)
}

//Reads name outta the cookie, to personalize the page
function GetPersonalizedName()
{
	var result = GetCookie('PzdNameTLW')	
    if(result == null) 
	{
		return null;
	}
	else
	{
		return result;
	}

}

function setPersonalize(value)
{
	var expIs = new Date(); 
	expIs.setTime(expIs.getTime() + (60*24*60*60*1000));//10 days

	SetCookie('PersonalTLW',value ,expIs)
}

function getPersonalize()
{
    var result = GetCookie('PersonalTLW')	
    if(result == null) 
	{
		return null;
	}
	else
	{
		return result;
	}
}

function NewPerson()
{
	DeleteCookie('PersonalTLW');
	
	pbu = getPersonalize();
	
//	alert("in this god foresaken place its " + pbu);
	window.history.go(0);

}

function setPersonalizePW(value)
{
	var expIs = new Date(); 
	expIs.setTime(expIs.getTime() + (30*24*60*60*1000));//30 days

	SetCookie('PW',value ,expIs)
}

function getPersonalizePW()
{
    var result = GetCookie('PW')	
    if(result == null) 
	{
		return null;
	}
	else
	{
		return result;
	}
}


function personalize()
{
	var name = document.pzd.pname.value;
	setPersonalizedName(name);


	//just setting to a value!!
	setPersonalize("Dog");




	//verifying matched password
//        if(document.pzd.pword.value != document.pzd.pword2.value)
//	{
           //alert("The passwords you entered do not match, please retype!");
	   //document.pzd.pword.focus();
	   //return;
//	}
//	var pw = document.pzd.pword.value;
//	setPersonalizePW(pw);

	window.history.go(0);
}


function DrawPersonalize()
{
	//Need to fill in blanks from previous results if ya can

	if(navigator.cookieEnabled != true)
	  {
	  return;
	  }
	   
	var DrawData;

	var theRet = getPersonalize();
//	alert(" in here its value is:" + theRet);

	if(theRet == null)
	{
		puname = GetPersonalizedName();
		if(puname == null)
			puname = "";
		//<!-- Lil Personalize Box -->
		DrawData ="<BR><BR><BR><BR><BR><BR>";
		DrawData += "<center><table border=1 bordercolor='#D3D3D3' bgcolor='#A9A9A9' width='90%'><tr><td><form name='pzd'>";
		DrawData += "<center><font size='-2' color='#FFFFFF'>Personalize</font><br></center>"; 
		DrawData += "<font size='-3' color='#FFFFFF'>Name:</font><br><input type='text' size=10 name='pname' value='" + puname + "'>";
		
		DrawData += "<br><br><center><input type=Image src='images//submitbtn.gif'  width='58' height='20' onclick='javascript:personalize()'></center>";
		DrawData += "</form></td></tr></table></center>";
	}
	else
	{	
		DrawData ="<BR><BR><BR><BR><BR><BR>";
		DrawData += "&nbsp; <img name='ptimg100' src='images//silverpt.gif' width='9' height='10'><a href='javascript:NewPerson();' onmouseover='ShowLinkImg(100)' onmouseout='HideLinkImg(100)'><font size='2' color='#DCDCDC'>Personalize</font></a></font><br>";
	}

	document.write(DrawData);

}





function ShowLinkImg(image)
{
var name = "ptimg" + image;

document.images[name].src = "images//hotpt.gif";
}

function HideLinkImg(image)
{
var name = "ptimg" + image;

document.images[name].src = "images//silverpt.gif";
}

function drawNavLinks()
{
    var string = "";

    string += "&nbsp; <img name='ptimg1' src='images//silverpt.gif' width= 9 height=10><a href='index.htm' onmouseover='ShowLinkImg(1)' onmouseout='HideLinkImg(1)'><font size='2' color='#DCDCDC'>Home</font></a><br><br>";    
    string += "&nbsp; <img name='ptimg2' src='images//silverpt.gif' width= 9 height=10><a href='test1.htm' onmouseover='ShowLinkImg(2)' onmouseout='HideLinkImg(2)'><font size='2' color='#DCDCDC'>Products</font></a><br>";    
    string += "&nbsp; <img name='ptimg3' src='images//silverpt.gif' width= 9 height=10><a href='test1.htm' onmouseover='ShowLinkImg(3)' onmouseout='HideLinkImg(3)'><font size='2' color='#DCDCDC'>About&nbsp;Us</font></a><br>";    
    string += "&nbsp; <img name='ptimg5' src='images//silverpt.gif' width= 9 height=10><a href='test1.htm' onmouseover='ShowLinkImg(5)' onmouseout='HideLinkImg(5)'><font size='2' color='#DCDCDC'>Whatever??</font></a><br><br>";    

//    string += "&nbsp; <img src='images//silverpt.gif' width= 9 height=10><a href='chat.htm' onmouseover='ShowLinkImg(11)' onmouseout='HideLinkImg(11)'><font size='2' color='#DCDCDC'>Chat</font></a><br>";    
    string += "&nbsp; <img name='ptimg12' src='images//silverpt.gif' width= 9 height=10><a href='#' onClick='openFreeChat()' onmouseover='ShowLinkImg(12)' onmouseout='HideLinkImg(12)'><font size='2' color='#DCDCDC'>Chat</font></a><br><br>";    

    string += "&nbsp; <img name='ptimg4' src='images//silverpt.gif' width= 9 height=10><a href='mailto:tlwoods@tlwoods.com' onmouseover='ShowLinkImg(4)' onmouseout='HideLinkImg(4)'><font size='2' color='#DCDCDC'>Contact&nbsp;Us</font></a><br>";    
    

   string += "<br><br><br><br><br><br><br><br>";

    document.write(string);

}

function drawNavLinks2()
{
    var string = "";

    string += "&nbsp;&nbsp;&nbsp; <img name='ptimg1' src='images//silverpt.gif' width= 9 height=10><a href='home.htm' onmouseover='ShowLinkImg(1)' onmouseout='HideLinkImg(1)'>Home</a><br>";    
    string += "&nbsp;&nbsp;&nbsp; <img name='ptimg7' src='images//silverpt.gif' width= 9 height=10><a href='about.htm' onmouseover='ShowLinkImg(7)' onmouseout='HideLinkImg(7)'>About&nbsp;Us</a><br>";    
    string += "&nbsp;&nbsp;&nbsp; <img name='ptimg8' src='images//silverpt.gif' width= 9 height=10><a href='mailto:tlwoods@tlwoods.com' onmouseover='ShowLinkImg(8)' onmouseout='HideLinkImg(8)'>Contact&nbsp;Us</a><br><br>";    
    string += "&nbsp;<b>Semi</b><br>";
    string += "&nbsp;&nbsp;&nbsp; <img name='ptimg2' src='images//silverpt.gif' width= 9 height=10><a href='cabinet.htm' onmouseover='ShowLinkImg(2)' onmouseout='HideLinkImg(2)'>Cabinets</a><br>";    
    string += "&nbsp;&nbsp;&nbsp; <img name='ptimg3' src='images//silverpt.gif' width= 9 height=10><a href='rack.htm' onmouseover='ShowLinkImg(3)' onmouseout='HideLinkImg(3)'>Headache Racks</a><br>";    
    string += "&nbsp;&nbsp;&nbsp; <img name='ptimg4' src='images//silverpt.gif' width= 9 height=10><a href='toolbox.htm' onmouseover='ShowLinkImg(4)' onmouseout='HideLinkImg(4)'>Tool Boxes</a><br>";    
    string += "&nbsp;&nbsp;&nbsp; <img name='ptimg5' src='images//silverpt.gif' width= 9 height=10><a href='access.htm' onmouseover='ShowLinkImg(5)' onmouseout='HideLinkImg(5)'>Accessories</a><br>";    
//    string += "&nbsp;&nbsp;&nbsp; <img name='ptimg6' src='images//silverpt.gif' width= 9 height=10><a href='examples.htm' onmouseover='ShowLinkImg(6)' onmouseout='HideLinkImg(6)'>Examples</a><br><br>";    


    string += "&nbsp;<b>Truck</b><br>";
    string += "&nbsp;&nbsp;&nbsp; <img name='ptimg9' src='images//silverpt.gif' width= 9 height=10><a href='flatbed.htm' onmouseover='ShowLinkImg(9)' onmouseout='HideLinkImg(9)'>Flatbeds</a><br>";    
    string += "&nbsp;&nbsp;&nbsp; <img name='ptimg19' src='images//silverpt.gif' width= 9 height=10><a href='haulerbody.htm' onmouseover='ShowLinkImg(19)' onmouseout='HideLinkImg(19)'>Hauler Bodies</a><br>";    
    string += "&nbsp;&nbsp;&nbsp; <img name='ptimg13' src='images//silverpt.gif' width= 9 height=10><a href='servicebody.htm' onmouseover='ShowLinkImg(13)' onmouseout='HideLinkImg(13)'>Service Bodies</a><br>";    
    string += "&nbsp;&nbsp;&nbsp; <img name='ptimg14' src='images//silverpt.gif' width= 9 height=10><a href='topper.htm' onmouseover='ShowLinkImg(14)' onmouseout='HideLinkImg(14)'>Toppers</a><br>";    
    string += "&nbsp;&nbsp;&nbsp; <img name='ptimg15' src='images//silverpt.gif' width= 9 height=10><a href='fueltank.htm' onmouseover='ShowLinkImg(15)' onmouseout='HideLinkImg(15)'>Fuel Tanks</a><br>";    
    string += "&nbsp;&nbsp;&nbsp; <img name='ptimg10' src='images//silverpt.gif' width= 9 height=10><a href='trucktoolbox.htm' onmouseover='ShowLinkImg(10)' onmouseout='HideLinkImg(10)'>Tool Boxes</a><br>";    
    string += "&nbsp;&nbsp;&nbsp; <img name='ptimg12' src='images//silverpt.gif' width= 9 height=10><a href='truckcabbox.htm' onmouseover='ShowLinkImg(12)' onmouseout='HideLinkImg(12)'>Cab Box/Back Pack</a><br>";    
    string += "&nbsp;&nbsp;&nbsp; <img name='ptimg16' src='images//silverpt.gif' width= 9 height=10><a href='truckaccess.htm' onmouseover='ShowLinkImg(16)' onmouseout='HideLinkImg(16)'>Accessories</a><br>";    
//    string += "&nbsp;&nbsp;&nbsp; <img name='ptimg11' src='images//silverpt.gif' width= 9 height=10><a href='truckex.htm' onmouseover='ShowLinkImg(11)' onmouseout='HideLinkImg(11)'>Examples</a><br><br>";    


//    string += "&nbsp; <img src='images//silverpt.gif' width= 9 height=10><a href='chat.htm' onmouseover='ShowLinkImg(11)' onmouseout='HideLinkImg(11)'><font size='2' color='#DCDCDC'>Chat</font></a><br>";    
//    string += "&nbsp; <img name='ptimg12' src='images//silverpt.gif' width= 9 height=10><a href='#' onClick='openFreeChat()' onmouseover='ShowLinkImg(12)' onmouseout='HideLinkImg(12)'>Chat</a><br><br>";    

    

//   string += "<br><br><br><br><br><br><br><br>";
   string += "<br><br><br><br>";

    document.write(string);

}
function titleBar()
{
    var string
    string = "<table width='100%' cellpadding=3 cellspacing=0 border=0><tr><td align='left' valign='bottom'><img src='images//tlwoodsR.gif' border=0 width=155 height=47 alt='TLWoods'>";
    string += "</td><td align='right' valign='top'>";
    document.write(string);


    string = "</td></tr></table>";
    document.write(string);
}

function drawTopNavBar()
{
	var string = "";

	string += "<table width='100%' cellpadding=0 cellspacing=0 border=0>";
	string += "<tr><td valign='top'><IMG SRC=images//curve2.gif ALIGN=top WIDTH=11 HEIGHT=11 border=0></td>";
	string += "<td><center><font color='#DCDCDC'>Since 1976</font></td></tr></table>";

    document.write(string);

}

function drawCopyright()
{
   var string = "";
   string += "<font size=-3 color='#696969'>Copyright © 2009 - TLWoods.com<br> Website design by <a HREF='http://www.birdsoft.biz'> Birdsoft</a></font>";


   document.write(string);
}


function greetings()
{
var string = "&nbsp;<font size='-1' color='#696969'>";

var result = GetPersonalizedName();
if(result == null)
  string += "Welcome to T.L.Woods";
else
  string += "Welcome " + result;

string += "</font>";

document.write(string);
}


function openFreeChat() 
{
window.open("chatsingle.htm","_blank","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0,width=510,height=400,screenX=0,screenY=0,left=0,top=0");
}

function CloseWindow() 

{

window.close();  

return true;

}



function drawChat()
{
var string = "";

string += "<center><applet archive='http://chat.planetz.net:8000/java/cr.zip' codebase='http://chat.planetz.net:8000/java/' code='ConferenceRoom.class' width='500' height='340' name='QuickChat'>";
string += "<param name='cabbase' value='http://chat.planetz.net:8000/java/cr.cab'><param name='channel' value='#tlwoods'><param name='simple' value='true'><param name='bg' value='FFFFFF'>";
string += "<param name='fg' value='000000'><param name='font' value='helvetica'><param name='size' value='12'><param name='tickershadow' value='false'>";
string += "<param name='ticker' value='This chat powered by QuickChat by Planet Z Networks - http://www.quickchat.org, visit their site to add QuickChat to your site!!'>";
string += "<param name='colorpanel' value='true'><param name='roomsWidth' value='0'>";
var theName = GetPersonalizedName();
if(theName == null)
  theName = "Guest";
string += "<param name='nick' value='" + theName +"'>";
string += "<param name='user' value='quickchat'><param name='port' value='7000'><param name='showwindowbuttons' value='false'><param name='info' value='Planet Z QuickChat'><param name='showticker' value='true'></applet>";
document.write(string);
}

function drawRightSpecialWindow()
{
	var string = "";
	string += "<table border='0' cellpadding='0' cellspacing='0' > <tr cellpadding='0' cellspacing='0'><td cellpadding='0' cellspacing='0' COLSPAN=3 ><img src='images//btTop.gif' border='0' height=22 width=147></td></tr>";
	string += "<tr COLSPAN=3 height=175 cellpadding='0' cellspacing='0'><td width=12 cellpadding='0' cellspacing='0'>";
        string += "<img src='images//btLeft.gif' border='0' height=175 width=12></td><td cellpadding=0 cellspacing='0' width=120 margin=0 valign=top ><font size = '-3'> ";
	string += "<font size=-1 color='#FF0000'>Specials</font><br><br><font color='#696969'>";
	string += "Your specials could go here, and the similar little Shopping cart window will pop up above this, if they have put anything in it";
	string += "<br><br>";
	string += "<center><img src='images//wrenchsp.gif' height='70' width='81'></center>";

	string += "</font></td><td width=12 Align='right'> <img src='images//btRight.gif' border='0' height=175 width=12 align='right'></td></tr>";
	string += "<tr cellpadding=0 cellspacing='0' > <td  cellpadding=0 COLSPAN=3 width=147 hieght=14><img src='images//btBot.gif' border='0' height=14 width=147></td></tr></table>";

	document.write(string);
}

function drawRightMessage()
{
	var string = "";
	string += "<center>Aluminum Truck Accessories by T.L.Wood's since 1976.  Custom designs and sizes available.";
	string += "<br><br><b>1-800-533-7541</b></center>";

	document.write(string);

}

function showInstalled() 
{
window.open("330ins.htm","_blank","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0,width=250,height=280,screenX=0,screenY=0,left=0,top=0");
}

function showlboxInstalled() 
{
window.open("lboxins.htm","_blank","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0,width=230,height=270,screenX=0,screenY=0,left=0,top=0");
}
function showxboxInstalled() 
{
window.open("xboxins.htm","_blank","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0,width=290,height=305,screenX=0,screenY=0,left=0,top=0");
}

function changename(html)
{
  //alert("im here");
  prodname.innerHTML=html;
}

function changetype(html)
{
  //alert("im here");
  prodtype.innerHTML=html;
}
function changedimensions(html)
{
  //alert("im here");
  dimensions.innerHTML=html;
}

function changedesc(html)
{
  //alert("im here");
  desc.innerHTML=html;
}

function ShowProductImg(image)
{
var name = "BigOne";


if(image == "tlw315b")
	{
	document.images[name].src = "images//tlw315b.jpg";
	changename("TLW315");
	changedesc("This rack is lightweight and very strong. A window may be placed in rack for more visibility.");
	changetype("Plain Headache Rack");
	changedimensions('84" Wide x 63" High');
	}
if(image == "tlw350b")
	{
	document.images[name].src = "images//tlw350b.jpg";
	changename("TLW350");
	changetype("Space Saver");
	changedesc("This rack is designed for better trailer turning radius with shorter wheel base trucks.");
	changedimensions('84" Wide x 63" High');
	}
}

function HideProductImg()
{
var name = "BigOne";

document.images[name].src = "clear.gif";
changename("&nbsp;");
changedesc("&nbsp;");
changetype("&nbsp;");
changedimensions("&nbsp;");

}

