
/*************
	widget 
*************/

function swapImg(newImg)
{
	var src="document.getElementById('main').innerHTML=document.getElementById('main').innerText=imgs."+newImg;
	eval(src);
}

function warp()
{
	window.location=gotolink	
}
/*********************************
	popup for newsletter archives 
**********************************/
function popUp(page)
{ 
	window.open('/about/newsletter/'+page,'mywindow','width=680,height=500,toolbar=no,location=1,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes'); 
	
} 

function sellIt() {
	reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
	if (!reZip.test(document.sellIt.zip.value)) {
		document.getElementById('paaEr').style.display = 'block';
		document.getElementById('zp').className = 'red';
	} else {
		document.sellIt.submit();
	}
}
/************************************
	IE Flicker
************************************/
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

/*************************************
 Forced Column Height Equality Script 
**************************************/
var ddequalcolumns=new Object()
ddequalcolumns.columnswatch=["lrgLft", "lrgLft2","smlRt","smlrLftSrch","lyoutMidSrch","smlRtSrch","lyoutCntr","bigLft","smlrRt","bigRt","smlLft","lyoutMid","smlrLft","smlLeftCol"]//Input IDs (id attr) of columns to equalize
ddequalcolumns.setHeights=function(reset){
	var tallest=0
	var resetit=(typeof reset=="string")? true : false
	for (var i=0; i<this.columnswatch.length; i++){
		if (document.getElementById(this.columnswatch[i])!=null){
			if (resetit)
				document.getElementById(this.columnswatch[i]).style.height="auto"
			if (document.getElementById(this.columnswatch[i]).offsetHeight>tallest)
				tallest=document.getElementById(this.columnswatch[i]).offsetHeight
		}
	}
	if (tallest>0){
		for (var i=0; i<this.columnswatch.length; i++){
			if (document.getElementById(this.columnswatch[i])!=null)
				document.getElementById(this.columnswatch[i]).style.height=tallest+"px"
		}
	}
}
ddequalcolumns.resetHeights=function(){
	this.setHeights("reset")
}
ddequalcolumns.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref)
}
ddequalcolumns.dotask(window, function(){ddequalcolumns.setHeights()}, "load")
ddequalcolumns.dotask(window, function(){if (typeof ddequalcolumns.timer!="undefined") clearTimeout(ddequalcolumns.timer); ddequalcolumns.timer=setTimeout("ddequalcolumns.resetHeights()", 200)}, "resize")

function anchr(drc, val) {

	if(drc=='on') { document.getElementById(val).className ='msout';} 
	if(drc=='off') { document.getElementById(val).className ='';}
}

function resetHt() {
ddequalcolumns.resetHeights();
}



function hdDrops(drpNam){
	if(document.getElementById(drpNam) != null){document.getElementById(drpNam).style.visibility = 'hidden';}
}
function shwDrops(drpNam){
	if(document.getElementById(drpNam) != null){document.getElementById(drpNam).style.visibility = 'visible';}
}
// dealer services js functions
function mobiletour() {
	var flashpage = "http://images.traderonline.com/img/design/imt/flash/SMS-demo-v2-1.swf";
	window.open(flashpage,"flashdemo","width=400,height=450,resizeable=no,status=no,toolbar=no,location=no,menubar=no,scrollbars=no,left=150,top=150")
}
function tourWndw() {
 	var imtTour=window.open("http://images.traderonline.com/img/design/imt/ITM-flashtour.htm","tourwindow","status=1,width=800,height=570");
}
function changesite()
{
	login1.action="";
	login1.submit();
}
function submitLoginsites()
{
	var sErrors ='';
	if(login1.HANDLE_ID.value.length == 0)
	{
		sErrors +='Please Enter Your User Name \r\n';
	}
	if(login1.PASSWORD.value.length == 0)
	{
		sErrors +='Please Enter Your Password';
	}
	if(sErrors!= '')
	{
		alert(sErrors);
	}else{
		login1.submit();
	}
		
}




//Realmedia.js

	// Instantiate the real media variables 
	var oas='http://ads.traderonline.com/RealMedia/ads/';
	var RN = new String (Math.random());
	var RNS = RN.substring (2,11);
	var _version = 40;

	// Function to create an "oldstyle" realmedia ad
	function DisplayAds(page, sitepage, category, location, keywords, position, width, height) {
		var oaspage = sitepage + page + '/1' + RNS + '@' + position + '?' + category + location + keywords;
		if ( _version < 11 ) {
			document.write ('<a href="' + oas + 'adstream_nx.ads/' + oaspage + '" target="_top"><img src="' + oas + 'adstream_nx.ads/' + oaspage + '" border="0" width="' + width + ' height="' + height + '"></a>');
		} else {
			document.write ('<script language="JavaScript1.1" src="' + oas + 'adstream_jx.ads/' + oaspage + '">');
			document.write ('\<\!-- --\>');
			document.write ('\<\/script\>');
			document.write ('\<\!-- --\>');
		}
	}
	
	// Function to create an MJX style realmedia ad
	function DisplayAdsMJX(page, sitepage, poslist, pos, keywords, width, height) {
	
	
	// Render the Real Media Ad using OAS_RICH or OAS_NORMAL
	function OAS_AD(pos)
	{
    	if (OAS_version >= 11 && typeof OAS_RICH != 'undefined')
	  		OAS_RICH(pos);
		else
			OAS_NORMAL(pos);
	}

	//OAS_NORMAL : plugged in from Real Media code.
	function OAS_NORMAL(pos) 
		{
  			document.write('<A HREF="' + oas + 'click_nx.ads/' + sitepage + '/1' + RNS + '@' + poslist + '!' + pos + '?' + keywords + '" target="_top">');
  			document.write('<IMG SRC="' + oas + 'adstream_nx.ads/' + sitepage + '/1' + RNS + '@' + poslist + '!' + pos + '?' + keywords + '" BORDER="0" width="' + width + ' height="' + height + '"></A>');
		}
		
	
	//Set this variable to build the MJX tag
	// Since OAS_RICH is currently not defined. We call the constructor
	// and initialize the vars needed only once
	if (pos == 'Constructor')	
	{
		OAS_listpos = poslist;
		
		//test
		OAS_query = keywords;
		
		// Set version to 11 to render rich media ads 
		OAS_version = 11;
		
		// Real Media code (plugged in as provided)
		if ((navigator.userAgent.indexOf('Mozilla/3') != -1) || (navigator.userAgent.indexOf('Mozilla/4.0 WebTV') != -1))
		  OAS_version = 10;
		
		// Real Media code (plugged in as provided)
		if (OAS_version >= 11)
		 document.write('<SCR' + 'IPT LANGUAGE=JavaScript1.1 SRC="' + oas + 'adstream_mjx.ads/' + sitepage + '/' + page + '/1' + RNS + '@' + poslist + '!' + pos +  '?' + keywords + '"><\/SCRIPT>');//-->
	}
	else
		// Necessary variables should already exist, now we need to render 
		// the individual position
		OAS_AD(pos)

}


function shwNode(idVal){

	document.getElementById(idVal).style.display='block';
	//resetHt();
}

function hidNode(idVal) {
	document.getElementById(idVal).style.display='none';
	//resetHt();
}


 window.onload = function()
 {
	topRVNav();
        //Run CycleTraderStuff() if exist. Usually cycletrader niche must include this in beginning.
	if(typeof CycleTraderStuff == 'function') 
         CycleTraderStuff();
	if(typeof photoViewerWindow == 'function') 
         photoViewerWindow();
 }
 
 function topRVNav() {
	if (document.all && document.getElementById) {
		navRoot = document.getElementById("subTabs");
		if( navRoot )
		{
			for (i=0; i< navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				for (j=0; j< node.childNodes.length; j++) {
					setnode = node.childNodes[j];
					if (setnode.nodeName=="LI") {
						setnode.onmouseover=function() {
							this.className+=" over";
						}
						setnode.onmouseout=function() {
							this.className=this.className.replace(" over", "");
						}
					}
				}
			}// End if navRoot
		}
	}
}
