$(document).ready(function(){ // Get all images var goleft = true; var goright = false; var kk =0; $("div.scrollBox").each(function() { kk++; }); totalboxes = kk; // Get the left position of the image widthend = $("#sb7").css("left"); var plantinfo = new Array(); plantinfo[1] = "

Succulents

Succulents are a higher power's answer to the now 'standard'...

"; plantinfo[2] = "

Citrus Trees

Whether you fancy yourself as the next Jamie Oliver or just like...

"; plantinfo[3] = "

Coral Jade

Jade can be found thriving from the middle of the outback to...

"; plantinfo[4] = "

Lavender

Lavender has been used for domestic purposes for centuries. ...

"; plantinfo[5] = "

Cycad

If you're looking for something dramatic look no further. The...

"; plantinfo[6] = "

Kalanchoe 'Flapjacks'

The Kalanchoe fans out its leaves like a proud peacock. From...

"; plantinfo[7] = "

Cordyline Glauca

This variety of Cordyline is my favourite with the subtle darker...

"; plantinfo[8] = "

Pittosporum Golfball

The Pittosporum Golfball is a cultivar that is made to shape....

"; plantinfo[9] = "

Chinese Star Jasmine

Traditionally a climber the Chinese Star Jasmine is a delicate...

"; plantinfo[10] = "

Protea 'Little Prince'

The'Little Prince' is exquisitely regal. Beautiful and robust,...

"; $("#clickLeft, #clickRight").hover(function() { $(this).css('cursor', 'pointer'); }, function() { $(this).css('cursor', 'default'); }); locked = false; $("#clickLeft, #clickRight").click(function (e) { if (!locked) { locked = true; $("div.scrollBox").each(function(i) { newleft = 0; //this.style.color = ""; thiswidth = $(this).css("width"); thiswidth = thiswidth.replace(/px,*\)*/g,""); thiswidth = parseInt(thiswidth); thisleft = $(this).css("left"); thisleft = thisleft.replace(/px,*\)*/g,""); thisleft = parseInt(thisleft); if (e.target.id == 'clickLeft') { dir = 'right'; } else { dir= 'left'; } if (e.target) { if (e.target.id == 'clickLeft') { dir = 'l'; if ($("#sb1").css("left") == "0px") { goright = false; } else { goright = true; } newleft = thisleft+(thiswidth+1); }else { dir = 'r'; leftbox = $("#sb"+totalboxes).css("left").replace(/px,*\)*/g,""); leftbox = parseInt(leftbox); compleft = widthend.replace(/px,*\)*/g,""); compleft = parseInt(compleft); if (leftbox <= compleft) { goleft = false; // alert("Cant..."+goleft+" -- #sb"+totalboxes+" pos of "+$("#sb"+totalboxes).css("left")+" is less than "+widthend+" "); } else { goleft = true; } newleft = thisleft-(thiswidth+1); } } else { if (e.srcElement.id == 'clickLeft') { dir = 'l'; if ($("#sb1").css("left") == "0px") { goright = false; } else { goright = true; } newleft = thisleft+(thiswidth+1); }else { dir = 'r'; if ($("#sb"+totalboxes).css("left") <= widthend) { goleft = false; } else { goleft = true; } newleft = thisleft-(thiswidth+1); } } //alert("Dir: "+dir+" and goleft: "+goleft); if ((dir == 'r' && goleft == true) || (dir == 'l' && goright== true)) { $(this).animate({ left: newleft+"px" }, 300, function() { locked = false; } ); } else { locked = false; } }); } }); $("div.scrollBox").hover(function(i) { //alert("This element is "+$(this).offset().left+" from the left of screen"); //alert($(this).offset(true,false,false,true,true,"document").left); boxX = $(this).offset(true,false,false,true,true,"#scrollCont").left; boxY = $(this).offset().top; boxY = boxY - 75; if ($.browser.msie) { } thisid= $(this).attr("id"); thiskey = thisid.replace(/sb,*\)*/g,""); //alert(thiskey); $("div.scrollBox").css("cursor", "pointer") $("#plantInfo").css("top", boxY); $("#plantInfo").css("left", boxX); $("#pInfoWrap").html(plantinfo[thiskey]); show = true; setTimeout(function() { //Do stuff here if (show == true) { $("#plantInfo").css("display", "block"); } }, 300); }, function() { show = false; $("#plantInfo").css("display", "none"); }); });