/*****************************************************
* ypSlideOutMenu
* 3/04/2001
*
* a nice little script to create exclusive, slide-out
* menus for ns4, ns6, mozilla, opera, ie4, ie5 on 
* mac and win32. I've got no linux or unix to test on but 
* it should(?) work... 
*
* Revised:
* - 08/29/2002 : added .hideAll()
* - 04/15/2004 : added .writeCSS() to support more 
*                than 30 menus.
*
* --youngpup--
*****************************************************/
ypSlideOutMenu.Registry = []
ypSlideOutMenu.aniLen = 250
ypSlideOutMenu.hideDelay = 1000
ypSlideOutMenu.minCPUResolution = 10
// constructor
function ypSlideOutMenu(id, dir, left, top, width, height)
{
this.ie = document.all ? 1 : 0
this.ns4 = document.layers ? 1 : 0
this.dom = document.getElementById ? 1 : 0
if (this.ie || this.ns4 || this.dom) {
this.id = id
this.dir = dir
this.orientation = dir == "left" || dir == "right" ? "h" : "v"
this.dirType = dir == "right" || dir == "down" ? "-" : "+"
this.dim = this.orientation == "h" ? width : height
this.hideTimer = false
this.aniTimer = false
this.open = false
this.over = false
this.startTime = 0
this.gRef = "ypSlideOutMenu_"+id
eval(this.gRef+"=this")
ypSlideOutMenu.Registry[id] = this
var d = document
var strCSS = "";
strCSS += '#' + this.id + 'Container { visibility:hidden; '
strCSS += 'left:' + left + 'px; '
strCSS += 'top:' + top + 'px; '
strCSS += 'overflow:hidden; z-index:10000; }'
strCSS += '#' + this.id + 'Container, #' + this.id + 'Content { position:absolute; '
strCSS += 'width:' + width + 'px; '
strCSS += 'height:' + height + 'px; '
strCSS += 'clip:rect(0 ' + width + ' ' + height + ' 0); '
strCSS += '}'
this.css = strCSS;
this.load()
}
}
ypSlideOutMenu.writeCSS = function() {
document.writeln('<style type="text/css">');
for (var id in ypSlideOutMenu.Registry) {
document.writeln(ypSlideOutMenu.Registry[id].css);
}
document.writeln('</style>');
}
ypSlideOutMenu.prototype.load = function() {
var d = document
var lyrId1 = this.id + "Container"
var lyrId2 = this.id + "Content"
var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1]
if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
var temp
if (!obj1 || !obj2) window.setTimeout(this.gRef + ".load()", 100)
else {
this.container = obj1
this.menu = obj2
this.style = this.ns4 ? this.menu : this.menu.style
this.homePos = eval("0" + this.dirType + this.dim)
this.outPos = 0
this.accelConst = (this.outPos - this.homePos) / ypSlideOutMenu.aniLen / ypSlideOutMenu.aniLen 
// set event handlers.
if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
this.menu.onmouseover = new Function("ypSlideOutMenu.showMenu('" + this.id + "')")
this.menu.onmouseout = new Function("ypSlideOutMenu.hideMenu('" + this.id + "')")
//set initial state
this.endSlide()
}
}
ypSlideOutMenu.showMenu = function(id)
{
var reg = ypSlideOutMenu.Registry
var obj = ypSlideOutMenu.Registry[id]
if (obj.container) {
obj.over = true
for (menu in reg) if (id != menu) ypSlideOutMenu.hide(menu)
if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }
if (!obj.open && !obj.aniTimer) reg[id].startSlide(true)
}
}
ypSlideOutMenu.hideMenu = function(id)
{
var obj = ypSlideOutMenu.Registry[id]
if (obj.container) {
if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
obj.hideTimer = window.setTimeout("ypSlideOutMenu.hide('" + id + "')", ypSlideOutMenu.hideDelay);
}
}
ypSlideOutMenu.hideAll = function()
{
var reg = ypSlideOutMenu.Registry
for (menu in reg) {
ypSlideOutMenu.hide(menu);
if (menu.hideTimer) window.clearTimeout(menu.hideTimer);
}
}
ypSlideOutMenu.hide = function(id)
{
var obj = ypSlideOutMenu.Registry[id]
obj.over = false
if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
obj.hideTimer = 0
if (obj.open && !obj.aniTimer) obj.startSlide(false)
}
ypSlideOutMenu.prototype.startSlide = function(open) {
this[open ? "onactivate" : "ondeactivate"]()
this.open = open
if (open) this.setVisibility(true)
this.startTime = (new Date()).getTime() 
this.aniTimer = window.setInterval(this.gRef + ".slide()", ypSlideOutMenu.minCPUResolution)
}
ypSlideOutMenu.prototype.slide = function() {
var elapsed = (new Date()).getTime() - this.startTime
if (elapsed > ypSlideOutMenu.aniLen) this.endSlide()
else {
var d = Math.round(Math.pow(ypSlideOutMenu.aniLen-elapsed, 2) * this.accelConst)
if (this.open && this.dirType == "-") d = -d
else if (this.open && this.dirType == "+") d = -d
else if (!this.open && this.dirType == "-") d = -this.dim + d
else d = this.dim + d
this.moveTo(d)
}
}
ypSlideOutMenu.prototype.endSlide = function() {
this.aniTimer = window.clearTimeout(this.aniTimer)
this.moveTo(this.open ? this.outPos : this.homePos)
if (!this.open) this.setVisibility(false)
if ((this.open && !this.over) || (!this.open && this.over)) {
this.startSlide(this.over)
}
}
ypSlideOutMenu.prototype.setVisibility = function(bShow) { 
var s = this.ns4 ? this.container : this.container.style
s.visibility = bShow ? "visible" : "hidden"
}
ypSlideOutMenu.prototype.moveTo = function(p) { 
this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : p + "px"
}
ypSlideOutMenu.prototype.getPos = function(c) {
return parseInt(this.style[c])
}
ypSlideOutMenu.prototype.onactivate = function() { }
ypSlideOutMenu.prototype.ondeactivate = function() { }

var leftimage=new Array();
var rightimage=new Array();
var blurb=new Array();
var price=new Array();
var link=new Array();
leftimage[1-1]="/cars/2012_1.jpg";
rightimage[1-1]="/cars/2012_2.jpg";
blurb[1-1]="<B>YAMAHA YZF-R1 LTD. EDITION </B><BR>Introducing the spectaclar Crossplane Crankshaft 2012 YZF-R1 ....from only £11999.- including 6 x way Traction control straight from the World beating Moto-GP M1... Moto GP inspired Top Yoke ...Redesigned Fairing....Stubby Cans etc OR for £12999.- you can ride one of these Ltd. Edition 50th Anniversary Replicas !!! Stunning !!! Order Now to avoid dissapointment !! ";
price[1-1]="<B STYLE='font-size: 10pt; color: red;'>&nbsp;</B><BR>&pound;12,999";
link[1-1]="/cgi-bin/details.pl?v_vin=1220";
leftimage[2-1]="/cars/2012FZ8_1.jpg";
rightimage[2-1]="/cars/2012FZ8_2.jpg";
blurb[2-1]="<B>YAMAHA FZ 50TH ANNIVERSARY LTD EDITION</B><BR>Yamaha FZ8 now form only £6999 - however you can own one of these iconic 50th Anniversary Ltd Editions for only an additional £500. But you must be quick .... numbers are limited !! Order Now To Avoid Disappointment !!";
price[2-1]="<B STYLE='font-size: 10pt; color: red;'>&nbsp;</B><BR>&pound;7,499";
link[2-1]="/cgi-bin/details.pl?v_vin=12FZ820";
leftimage[3-1]="/cars/2012R125_1.jpg";
rightimage[3-1]="/cars/2012R125_2.jpg";
blurb[3-1]="<B>YAMAHA YZF -R125 50TH ANNIVERSASY LTD. EDITION</B><BR>This is your chance to own a chunk of history !! This Limited Edition machine was designed to celebrate Yamaha's 50 years in World Championship Racing at the top level ... and it utilises the Iconic Yamaha Speedblock design used by many of their World Champion Riders ....It is Stunning ...but be quick ..it is a very Limited Edition !!   ";
price[3-1]="<B STYLE='font-size: 10pt; color: red;'>&nbsp;</B><BR>&pound;4,499";
link[3-1]="/cgi-bin/details.pl?v_vin=12R12520";
leftimage[4-1]="/cars/2012R6_1.jpg";
rightimage[4-1]="/cars/2012R6_2.jpg";
blurb[4-1]="<B>YAMAHA YZF-R6 50TH  ANNIVERSARY LTD. EDITION</B><BR>The Latest and the Greatest ... Yamaha's Spectacular 2012 YZF-R6 Ltd. Edition 50th Anniversary GP Replica ...This Must Be The Most Stunning 600 Supersport Bike on the Planet !!! Order now to avaid dissappointment !! Non Replica Colours only £8999.- !!";
price[4-1]="<B STYLE='font-size: 10pt; color: red;'>&nbsp;</B><BR>&pound;9,499";
link[4-1]="/cgi-bin/details.pl?v_vin=12R620";
leftimage[5-1]="/cars/SWAN1_4.jpg";
rightimage[5-1]="/cars/SWAN1_5.jpg";
blurb[5-1]="<B>YAMAHA YZF-R1 SWAN YAMAHA REPLICA</B><BR>This is the actual Swan Team promotional YZF-R1 as commishioned by Sean Muir to promote or welcome guests to the Teams Hospitality unit to meet new British Champion Tommy Hill and team mate Michael Laverty this is The genuine Team replica !! Your chance to own a bit of history !!n( beautiful paint job curtisy of DREAM MACHINE )";
price[5-1]="<B STYLE='font-size: 10pt; color: red;'>&nbsp;</B><BR>&pound;10,999";
link[5-1]="/cgi-bin/details.pl?v_vin=AN1SW";
	var carnum=Math.floor(Math.random() * (leftimage.length));
	var version=0;
	getBrowser();

	var myMenu1 = new ypSlideOutMenu("sales", "up", 0, -315, 160, 285)
	var myMenu2 = new ypSlideOutMenu("company", "up", 0, -265, 160, 205)
	var myMenu3 = new ypSlideOutMenu("contact", "up", 0, -180, 160, 150)
	var myMenu4 = new ypSlideOutMenu("location", "up", 0, -100, 160, 70)
	/*
	var myMenu1 = new ypSlideOutMenu("sales", "up", 0, -260, 160, 275)
	var myMenu2 = new ypSlideOutMenu("company", "up", 0, -210, 160, 195)
	var myMenu3 = new ypSlideOutMenu("contact", "up", 0, -125, 160, 140)
	var myMenu4 = new ypSlideOutMenu("location", "up", 0, -45, 160, 60)
	*/

	ypSlideOutMenu.writeCSS();

sales_off=new Image(100,100)
sales_off.src="/graphics/dealer/sales.png"
sales_on=new Image(100,100)
sales_on.src="/graphics/dealer/sales_on.png"
company_off=new Image(100,100)
company_off.src="/graphics/dealer/company.png"
company_on=new Image(100,100)
company_on.src="/graphics/dealer/company_on.png"
contact_off=new Image(100,100)
contact_off.src="/graphics/dealer/contact.png"
contact_on=new Image(100,100)
contact_on.src="/graphics/dealer/contact_on.png"
location_off=new Image(100,100)
location_off.src="/graphics/dealer/location.png"
location_on=new Image(100,100)
location_on.src="/graphics/dealer/location_on.png"

function filter(imagename,objectsrc){
// alert("filter(" +imagename+ "," +objectsrc+ ")" );
if (document.images)
document.images[imagename].src=eval(objectsrc+".src")
}

function picrotate(){
    if(carnum!=999){
        if(version){
            document.picleft.filters["blendTrans"].apply();
            document.picleft.src=leftimage[carnum];
            document.picleft.filters["blendTrans"].play();
            document.picright.filters["blendTrans"].apply();
			document.getElementById("plref").href=link[carnum];
            document.picright.src=rightimage[carnum];
            document.picright.filters["blendTrans"].play();
			document.getElementById("prref").href=link[carnum];
            document.getElementById("blurb").innerHTML=blurb[carnum];
            document.getElementById("price").innerHTML=price[carnum];
        }else{
            document.picleft.src=leftimage[carnum];
			document.getElementById("plref").href=link[carnum];
            document.picright.src=rightimage[carnum];
			document.getElementById("prref").href=link[carnum];
            document.getElementById("blurb").innerHTML=blurb[carnum];
            document.getElementById("price").innerHTML=price[carnum];
        }
        carnum++;
        if(carnum==leftimage.length){
            carnum=0;
        }
    }else{
        carnum=1;
    }
    setTimeout("picrotate();", 10000);
}

function getBrowser(){
    //Detect IE5.5+
    if (navigator.appVersion.indexOf("MSIE")!=-1){
    temp=navigator.appVersion.split("MSIE")
    version=parseFloat(temp[1])
    }

    if (version>=5.5) //NON IE browser will return 0
        version=1;
}

