function Products(setName) {
        
        this.name=setName;//Set Object Name
        
        this.x10price=0; //Default Price

        this.x10warranty=0;//Default Warranty

        this.x10shipping="$5.90";//Default Shipping

        this.x10rebate=0; // change to zero to make tab go away

        this.x10qty=1;//Default Qauntity

        this.x10itemnum=0;// Item Number

        this.x10WarrantyNumber=0;// Default Warrenty ItemNumber

        this.ADdelay=10000;        
}
Products.prototype.expandOpt = function ( id ) {
        
        var div = document.getElementById( id );
        
        if( div.style.display != "block" ) {
        
                div.style.display = "block";
                
        } else {
        
                div.style.display = "none";
                
        }
        
}
Products.prototype.changeWarranty = function ( price, itemnum ) {
                
        this.x10warranty = price;
        
        this.x10WarrantyNumber = itemnum;
        
        this.ChangeText( 'curwarranty', null, "$"+this.x10warranty );
                
        this.recalPrice();
        
        this.expandOpt( "warranties" );
}
Products.prototype.totalPricing = function ( ) {
 
        if( document.warrantyform ) {
                
                if( document.warrantyform[1].value ) {
                        
                        document.warrantyform[1].checked = true;
                        
                        var str = document.warrantyform[1].value.split( "|" );
                        
                        if( ! isNaN( str[0] ) ) {
                                
                                this.x10warranty = parseFloat( str[0] );
                                
                        } else {
                                
                                this.x10warranty = 0.00;
                                
                        }
                        
                        if( ! isNaN( str[1] ) ) {
                                
                                this.x10WarrantyNumber = str[1];
                                
                        } else {
                                
                                this.x10WarrantyNumber = 0;
                                
                        }
                        
                        this.ChangeText( 'curwarranty', null, "$"+this.x10warranty );
                        
                } else {

                        this.x10warranty = 0.00;
        
                        this.x10WarrantyNumber = 0;

                }
        
        }
        
        this.recalPrice();
}
Products.prototype.changeQty = function ( form ) {
        
        var qty = parseInt( form.qty.value );
        
        if( qty <= 0 ) { qty = 1; }
        
        this.x10qty = qty;
        
        this.ChangeText( 'curquantity', null, "x " + this.x10qty );
                
        this.recalPrice();
        
        this.expandOpt( "quantity" );
        
}
Products.prototype.recalPrice = function () {

        var shipping = 0;
        
        price = new Number();
        
        price = this.x10price * this.x10qty;
        
        if ( ( this.x10shipping != "Free" ) && ( price < 49.99 ) ) {
        
                shipping = parseFloat(this.x10shipping);
                
                this.ChangeText( 'ShipCost', null, "$" + this.currenyFormat( shipping ) );
                
        } else {
        
                this.ChangeText( 'ShipCost', null, "Free" );
                
        }
        
        price =  ( price + this.x10warranty + shipping + this.x10rebate  ) * 100;
        
        price = Math.round ( price ) / 100;
        
        this.ChangeText( 'gTotal', null, "$"+ this.currenyFormat( price ) );
        
}
Products.prototype.submitOrder = function () {

        var itemnum = "";
        
        if( this.x10qty > 1) {

                itemnum = this.x10qty + ":" + this.x10itemnum;
        
        } else {
        
                itemnum = this.x10itemnum;
                
        }
        
        if( this.x10WarrantyNumber != 0 ) {

                itemnum = itemnum + "," + this.x10WarrantyNumber;
                
        }

        document.location.href="http://store.x10.com/cgi-bin/sb/order.cgi?storeid=x10merchant&dbname=products&itemnum="+itemnum+"&function=add";
        
}
Products.prototype.ChangeText = function (TextArea,nestLyr,Text) {
                                                                                
        if(document.layers) {
                                                                                
                var docLyr = (nestLyr)? eval('document.'+nestLyr+'.document.'+TextArea+'.document') : document.layers[TextArea].document;
                                                                                
                docLyr.open();
                docLyr.write(Text);
                docLyr.close();
                                                                                
                                                                                
        } else if( document.getElementById ) {
        
                var docLyr = document.getElementById( TextArea );
                
                docLyr.innerHTML = Text;
                                                                                
        }
                 
}
Products.prototype.currenyFormat = function ( num ) {

        var tmp = num.toString();

        var array = tmp.split( "." );
        
        var whole = array[0];
        
        var remander = array[1];
        
        //For dropped zero
        if( remander.length == 1 ) {
        
                remander = remander + "0";
                
        }
        
        var wtmp = "";
        
        if( whole.length > 3 ) {
        
                var splt = whole.split( "" );
                
                splt = splt.reverse();
                
                for( x = 0; x < splt.length; x += 3) {
                
                        if( ( splt.length - x ) > 3 ) {
                        
                                wtmp += splt[ x ] + "" + splt[ x + 1 ] + "" + splt[ x + 2 ] + ",";
                                
                        } else {
                        
                                for( y = 0 ; y < ( splt.length - x ); y++ ) {
                                
                                        wtmp += splt[ x + y ];
                                
                                }

                        }
                        
                }
                
                var splt = wtmp.split("");
                
                splt = splt.reverse();
                
                whole = splt.join( "" );
        }
                
        var formatted = whole + "." + remander;

        return formatted;
        
}
Products.prototype.switchPage = function () {
	
	document.getElementById( 'mainbody' ).style.display = "block";
	
	document.getElementById( 'adbody' ).style.display = "none";	

}
Products.prototype.init = function () {

        if( this.ADdelay > 0 ) {
                
                TimerID=setTimeout( this.name + '.switchPage()', this.ADdelay );
        
        }
        
}

function floatInWider( setName ) {
	
	this.name = setName;
        
        this.delay = 3000;
        
        this.icontime = 30000;
	
	this.url = "http://images.x10.com/all/kgjuno6.gif";
	
	this.icon = "http://www.x10.com/images/lgo4.gif";
	
	this.documentHeight=0;
	
	this.documentWidth=0;
        
        this.move = 0;
        
        this.X = 0;
        
        this.Y = 0;
        
}

floatInWider.prototype.init = function(){
	
	var ns=(document.layers);
	
	var ie=(document.all);
	
	var w3=(document.getElementById && !ie);
        
	if (ie){
	
		this.documentWidth = this.truebody().offsetWidth;
	
		this.documentHeight = this.truebody().offsetHeight;
	
	} else if (ns){
	
		this.documentWidth = window.innerWidth;
	
		this.documentHeight = window.innerHeight;
	
	} else if (w3){
	
		this.documentWidth = self.innerWidth;
	
		this.documentHeight = self.innerHeight;

	} 
	
	this.buildWindow();

        if( document.getElementById("TextBody") ) {
                
                setTimeout( this.name+'.showBody()', ( this.delay - 3000 ) );
                
        }
        
	setTimeout( this.name+'.slideWindow()', this.delay );
	
        if( this.icontime > 0 ) {
                
                setTimeout( this.name+'.iconify()', ( this.delay + this.icontime ) );
                
        }
        
        document.onmousemove=flIW.MoveWin;
        
}
floatInWider.prototype.showBody = function(){
                
        document.getElementById("TextBody").style.visibility = "visible";
        
}
floatInWider.prototype.buildWindow = function(){
	
	document.writeln("<div id=\"fIcon\" style=\"position:absolute;top:0;left:0;width:72;height:62;visibility:hidden\"><a href=\"javascript:"+this.name+".deiconify();\"><img src=\""+this.icon+"\" border=\"0\" width=\"72\" height=\"62\"></a></div>\n");
	
        document.writeln("<div id=\"fWin\" style=\"position:absolute;top:0;left:0;width:261;height:281;z-index:80\"><table cellpadding=1 cellspacing=0 border=2><tr><td align=\"right\" onmousedown=\""+this.name+".MoveWinOn(event);\" onmouseup=\""+this.name+".MoveWinOff(event);\" bgcolor=\"#5372a9\"><a href=\"javascript:"+this.name+".iconify();\"><img src=\"http://graphics.x10.com/images/floating_window_min_button.gif\" border=0></a><a href=\"javascript:"+this.name+".close();\"><img src=\"http://graphics.x10.com/images/floating_window_exit_button.gif\" border=0></a></td></tr><tr><td bgcolor=\"#000000\"><iframe name=\"IFWN\" id=\"IFWN\" src=\""+this.url+"\" frameborder=\"0\" scrolling=\"no\" width=\"250\" height=\"250\" marginwidth=\"0\" marginheight=\"0\" hspace=\"0\" vspace=\"0\"></iframe></td></tr></table></div>\n");
        
	document.getElementById("fWin").style.top = ( this.documentHeight / 2 ) - ( 281 / 2 ); 
	
	document.getElementById("fWin").style.left = -261;
	
}
floatInWider.prototype.slideWindow = function(){
	
	var position = -261;
	
	var position2 = ( position + 6 );
	
	var pause = 0;
	
	var i = 0;
	
	var movement = ( ( this.documentWidth / 2 ) + ( 261 / 2 ) ) / 80;
	
	for ( i=0; i < 80; i++ ){
		
		pause=i*15;
		
		position = ( position + movement );
		
		position2 = ( position + 6 );
                
                setTimeout('document.getElementById("fWin").style.left='+position2+';', pause);
	}

}
floatInWider.prototype.close = function(){
	
	document.getElementById("fWin").style.visibility = "hidden";
			
}
floatInWider.prototype.iconify = function(){
	
	document.getElementById("fWin").style.visibility = "hidden";
	
	document.getElementById("fIcon").style.top = ( this.documentHeight - 72 );
	
	document.getElementById("fIcon").style.visibility = "visible";

}
floatInWider.prototype.deiconify = function(){
	
	document.getElementById("fWin").style.visibility = "visible";

	document.getElementById("fIcon").style.visibility = "hidden";
	
}
floatInWider.prototype.truebody = function(){
	
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
	
}
floatInWider.prototype.MoveWinOn = function(e){
        
        this.move = 1
        
        this.X = e.clientX - parseInt( document.getElementById("fWin").style.left );
        
        this.Y = e.clientY - parseInt( document.getElementById("fWin").style.top );

        return false;
	
}
floatInWider.prototype.MoveWinOff = function(e){
	
        this.move = 0;
        
        return false;
        
}
floatInWider.prototype.MoveWin = function(e){
        var ie=(document.all);
        
        if( flIW.move ) {
                        
                if( document.getElementById && !ie) {
        
                        document.getElementById("fWin").style.top = e.clientY - flIW.Y; 
	
                        document.getElementById("fWin").style.left = e.clientX - flIW.X;
                 
                } else { 

                        document.getElementById("fWin").style.top = event.clientY - flIW.Y; 
	
                        document.getElementById("fWin").style.left = event.clientX - flIW.X;
                        
                }
                
        }
        
}
