// JavaScript Document
function swapEvents(EventNum){
for(i=1;i<4;i++){
document.getElementById("event"+i).style.display = "none";
}
document.getElementById("event"+EventNum).style.display = "inline";
writeText = "";
switch(EventNum){
case 1:
writeText+="<b>Cape Town</b> | <a href='javascript:swapEvents(2);'>Joburg</a> | <a href='javascript:swapEvents(3);'>Durban</a>";
break;
case 2:
writeText+="<a href='javascript:swapEvents(1);'>Cape Town</a> | <b>Joburg</b> | <a href='javascript:swapEvents(3);'>Durban</a>";
break;
case 3:
writeText+="<a href='javascript:swapEvents(1);'>Cape Town</a> | <a href='javascript:swapEvents(2);'>Joburg</a> | <b>Durban</b>";
break;
default:
writeText+="<a href='javascript:swapEvents(1);'>Cape Town</a> | <a href='javascript:swapEvents(2);'>Joburg</a> | <a href='javascript:swapEvents(3);'>Durban</a>";
break;
}
document.getElementById('theEventHead').innerHTML = writeText;
}

<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
currentProd = "";

function rateProduct(theMark){
for(i=1;i<6;i++){
if(i!=theMark){MM_swapImage('mark'+i,'','images/mark_'+i+'.gif',1)}
}
document.getElementById("theRate").value = theMark;
currentProd = theMark;
}
function checkProduct(theMark){
if(theMark!=currentProd){
MM_swapImgRestore();
} else if(currentProd==""){
MM_swapImgRestore();
}
}

function openAZ(whichOne){
myCheck = document.getElementById("content_"+whichOne).style.display;
if(myCheck=="none" || myCheck==""){
document.getElementById("content_"+whichOne).style.display = "inline";
document.getElementById("hold_"+whichOne).className="azListOff";
} else {
document.getElementById("content_"+whichOne).style.display = "none";
document.getElementById("hold_"+whichOne).className="azListOn";
}

}

function showEvent(whichOne){
myCheck = document.getElementById(whichOne).style.display;
if(myCheck=="none" || myCheck==""){
document.getElementById(whichOne).style.display = "inline";
} else {
document.getElementById(whichOne).style.display = "none";
}
}

function openEvent(theURL) { 
  myWindow = window.open(theURL,'popper','resizable=yes,width=530,height=500,scrollbars=yes');
  myWindow.focus();
}

function submitVac(doWhich) { 
switch(doWhich){
case 0:
document.getElementById('toolResults').style.display = "none";
break;
case 1:
document.getElementById('toolResults').style.display = "inline";
break;
}
}


function submitDueDate(doWhich) { 
switch(doWhich){
case 0:
document.getElementById('toolResults').style.display = "none";
break;
case 1:
document.getElementById('toolResults').style.display = "inline";
break;
}
}


function submitOvulation(doWhich) { 
switch(doWhich){
case 0:
document.getElementById('toolResults').style.display = "none";
break;
case 1:
document.getElementById('toolResults').style.display = "inline";
break;
}
}

/////////////////////////////// nav /////////////////////////////////////
 
function createNav(){
topNav = new Array();
topNav[0] = new Array()
topNav[0][0] = new Array("News","http://www.wheels24.co.za/Content/News/",0);
topNav[0][1] = new Array();
topNav[0][1][0] = new Array("General News","http://www.wheels24.co.za/Content/News/General_News/",10);
topNav[0][1][1] = new Array("Future Models","http://www.wheels24.co.za/Content/News/Future_Models/",11);
topNav[0][1][2] = new Array("Environmental","http://www.wheels24.co.za/Content/News/Environmental/",12);
topNav[0][1][3] = new Array("Industry News","http://www.wheels24.co.za/Content/News/Industry_News/",13);
topNav[0][1][4] = new Array("Custom Cars","http://www.wheels24.co.za/Content/Custom_Cars/",14);
topNav[1] = new Array()
topNav[1][0] = new Array("New Models","http://www.wheels24.co.za/Content/NewModels/",1);
topNav[1][1] = new Array();
topNav[1][1][0] = new Array("New Models Home","http://www.wheels24.co.za/Content/NewModels/",20);
topNav[1][1][1] = new Array("Prices & Specs","http://www.autospecs.co.za/frmExt.aspx?logon=W24",21);
topNav[1][1][2] = new Array("SA's Top-selling Cars","http://www.wheels24.co.za/Content/NewModels/TopSellingCars/",22);
topNav[1][1][3] = new Array("Buy a Car","http://autolist.wheels24.co.za/AutoList/Default.aspx",23);
topNav[2] = new Array()
topNav[2][0] = new Array("Road Tests","http://www.wheels24.co.za/Content/RoadTests/",2);
topNav[2][1] = new Array();
topNav[2][1][0] = new Array("Latest Tests","http://www.wheels24.co.za/Content/RoadTests/Latest_Tests/",30);
topNav[2][1][1] = new Array("Reader Tests","http://www.wheels24.co.za/Content/RoadTests/Reader_Tests/",31);
topNav[2][1][2] = new Array("Long-term Tests","http://www.wheels24.co.za/Content/RoadTests/Long-term_Tests/",32);
topNav[3] = new Array()
topNav[3][0] = new Array("4x4","http://www.wheels24.co.za/Content/4x4/",3);
topNav[3][1] = new Array();
topNav[4] = new Array()
topNav[4][0] = new Array("Motor Shows","http://www.wheels24.co.za/Content/Motor_Shows/",4);
topNav[4][1] = new Array();
topNav[4][1][0] = new Array("Geneva Motor Show","http://www.wheels24.co.za/Content/Motor_Shows/Geneva_Motor_Show",50);
topNav[4][1][1] = new Array("Frankfurt Motor Show","http://www.wheels24.co.za/Content/Motor_Shows/Frankfurt_Motor_Show",51);
topNav[4][1][2] = new Array("Other Motor Shows","http://www.wheels24.co.za/Content/Motor_Shows/Other",52);
topNav[5] = new Array()
topNav[5][0] = new Array("Bikes","http://www.wheels24.co.za/Content/BikesQuads/",5);
topNav[5][1] = new Array();
topNav[5][1][0] = new Array("Biking News","http://www.wheels24.co.za/Content/BikesQuads/BikingNews/",60);
topNav[5][1][1] = new Array("New Models","http://www.wheels24.co.za/Content/BikesQuads/NewModels/",61);
topNav[5][1][2] = new Array("Road Tests","http://www.wheels24.co.za/Content/BikesQuads/RoadTests/",62);
topNav[6] = new Array()
topNav[6][0] = new Array("Formula One","http://www.wheels24.co.za/Content/FormulaOne/",6);
topNav[6][1] = new Array();
topNav[6][1][0] = new Array("F1 News","http://www.wheels24.co.za/Content/FormulaOne/",70);
topNav[6][1][1] = new Array("Teams","http://www.wheels24.co.za/Content/FormulaOne/TeamsAndDrivers/McLaren/",71);
topNav[6][1][2] = new Array("Tracks","http://www.wheels24.co.za/Content/FormulaOne/Tracks/",72);
topNav[6][1][3] = new Array("Results", "http://www.wheels24.co.za/Content/FormulaOne/Results/");
topNav[6][1][4] = new Array("Driver Standings","http://www.wheels24.co.za/Content/FormulaOne/DriverStandings/",73);
topNav[6][1][5] = new Array("Team Standings","http://www.wheels24.co.za/Content/FormulaOne/TeamStandings/",74);
topNav[6][1][6] = new Array("Calander 2010","http://www.wheels24.co.za/Content/FormulaOne/Schedule/",75);
topNav[7] = new Array()
topNav[7][0] = new Array("Motorsport","http://www.wheels24.co.za/Content/Motorsport/",7);
topNav[7][1] = new Array();
topNav[7][1][0] = new Array("General","http://www.wheels24.co.za/Content/Motorsport/General/",80);
topNav[7][1][1] = new Array("WRC","http://www.wheels24.co.za/Content/Motorsport/WRC/",81);
topNav[7][1][2] = new Array("Bikes Racing","http://www.wheels24.co.za/Content/Motorsport/Bikes_Racing/",82);
topNav[7][1][3] = new Array("A1 GP","http://www.wheels24.co.za/Content/Motorsport/A1_Grand_Prix/",83);
topNav[8] = new Array()
topNav[8][0] = new Array("Multimedia","http://www.wheels24.co.za/Content/Galleries/",8);
topNav[8][1] = new Array();
topNav[8][1][0] = new Array("Photo Galleries","http://www.wheels24.co.za/Content/Galleries/Image/",90);
topNav[8][1][1] = new Array("Videos","http://www.wheels24.co.za/Content/Galleries/Video/",91); 
topNav[9] = new Array()
topNav[9][0] = new Array("Community","http://www.wheels24.co.za/Content/Community/",9);
topNav[9][1] = new Array();
topNav[9][1][0] = new Array("Blogs","http://blogs.wheels24.co.za/",100);
topNav[9][1][1] = new Array("Reader Rides","http://www.wheels24.co.za/Content/RoadTests/Reader_Tests/",101);
topNav[9][1][2] = new Array("Zoopedup","http://www.zoopedup.com/",102);
topNav[9][1][3] = new Array("Facebook Group","http://www.facebook.com/group.php?gid=2563398708",103);
topNav[10] = new Array()
topNav[10][0] = new Array("Vehicle Search","http://autolist.wheels24.co.za/AutoList/Default.aspx",10);
topNav[10][1] = new Array();
topNav[10][1][0] = new Array("New Vehicles","http://autolist.wheels24.co.za/AUTOLIST/SearchResults.aspx?action=search&searchType=NEW",200);
topNav[10][1][1] = new Array("Used Vehicles","http://autolist.wheels24.co.za/AUTOLIST/SearchResults.aspx?action=search&searchType=USED",201);
topNav[10][1][2] = new Array("Prices & Specs","http://www.autospecs.co.za/frmExt.aspx?logon=W24",202);

//-->


//////////////////////////////////////////// write nav
myNav = "";
/////////////////write main nav
mySub="";
for(i=0;i<topNav.length;i++){
myNav+="<a href=\""+topNav[i][0][1]+"\" onMouseOver=\"showSub("+topNav[i][0][2]+");\" onMouseOut=\"checkState();\" id=\"top_"+topNav[i][0][2]+"\">"+topNav[i][0][0]+"</a>"
if(i!=topNav.length-1){myNav+="<p></p>"}
/////////////////write sub nav
mySub += "<div id=\"subNav"+topNav[i][0][2]+"\" style=\"display:none;\">";
for(a=0;a<topNav[i][1].length;a++){
mySub+="<a href=\""+topNav[i][1][a][1]+"\" onMouseOver=\"clearOut();\" onMouseOut=\"checkState();\" id=\"sub_"+topNav[i][1][a][2]+"\">"+topNav[i][1][a][0]+"</a>"
if(a!=topNav[i][1].length-1){mySub+="<p></p>"}
}
mySub += "</div>";
}
document.getElementById("mainNav").innerHTML=myNav;
document.getElementById("sNav").innerHTML=mySub;
if((theMarker=="") || (theMarker==undefined)){}else{
setMainStyle(theMarker,theSubMarker);showSub(theMarker);
}

}
////////////////////////////////////////// end write nav
mynavTime = "";

function showSub(tSub){
for(i=0;i<topNav.length;i++){
document.getElementById("top_"+topNav[i][0][2]).className = "offNav";
}
clearInterval(mynavTime);
hideSubs()
if((theSubMarker=="") || (theSubMarker==undefined)) {}else{
document.getElementById("subNav"+tSub).style.display = "inline";
}
document.getElementById("top_"+tSub).className = "hightLightNav";
}

function clearSub(){
if((theMarker=="") || (theMarker==undefined)){
hideSubs();
} else {
showSub(theMarker);
setMainStyle(theMarker,theSubMarker);
}
clearInterval(mynavTime);
}

function checkState(){
mynavTime = setInterval(clearSub,1000);
}

function setMainStyle(theID,theSubID){
document.getElementById("top_"+theID).className = "hightLightNav";

if((theSubMarker=="") || (theSubMarker==undefined)) {}else{
document.getElementById("sub_"+theSubID).className = "hightLightSub";
document.getElementById("subNav"+theID).style.display = "inline";}
}


function hideSubs(){
for(i=0;i<topNav.length;i++){
document.getElementById("subNav"+topNav[i][0][2]).style.display = "none";
document.getElementById("top_"+topNav[i][0][2]).className = "offNav";
}
}

function clearOut(){
clearInterval(mynavTime);
}

////////////////////////////////////////////////////////////// scrollbars////////////////////////////////////////////////////////
/////////------------------- start scrolly  -----------------------------/////////////////////////////
///////// scripted by overactive //////////////////////////////////////////////////////////////////////////////
//ssmyArray = new Array(200,200,400,200,400,200)
ssarrayNum = "";
ssCurrentPos = 0;//position of content
ssSpeed = 50;//speed of movement
ssMoveme = "";//interval
ssAutoMoveme = "";//interval
ssTotal="";//total width
ssEnd=0;

/////////////////////////////////// eased moving  /////////////////////////////////////////////////////////////
function ssmoveScroll(ssDir){
ssMoveAmount = (ssEnd-ssCurrentPos)/3;
if((ssCurrentPos<ssEnd+2)&&(ssCurrentPos>ssEnd-2)){
// cleartimeout
ssCurrentPos = ssEnd;clearInterval(ssMoveme);
}else {
ssCurrentPos=Math.round(ssCurrentPos+ssMoveAmount);
}
document.getElementById("scrollMover").style.left =ssCurrentPos+"px";
}
/////////////////////////////////// pause it  /////////////////////////////////////////////////////////////
function ssPause() {
clearInterval(ssAutoMoveme);
//clearInterval(ssMoveme);
}
/////////////////////////////////// move next  /////////////////////////////////////////////////////////////
function ssNext() {
clearInterval(ssAutoMoveme);
clearInterval(ssMoveme);
ssEnd-=ssMoveAmt;
//if((ssEnd+(ssMoveAmt-20))<=(sstotalWidth-ssTotal)){ssEnd=0}
if((ssEnd-(ssMoveAmt))<=(sstotalWidth-ssTotal)){ssEnd+=ssMoveAmt;}else{
writeIt("total"+ssTotal+"end"+ssEnd+"move amount"+ssMoveAmt+"/")
ssMoveme = setInterval("ssmoveScroll(1)",ssSpeed);
}
}
/////////////////////////////////// move next  /////////////////////////////////////////////////////////////
function ssNextAuto() {
clearInterval(ssMoveme);
ssEnd-=ssMoveAmt;
if((ssEnd+((ssMoveAmt)))<=(sstotalWidth-ssTotal)){ssEnd=0}
writeIt("total"+ssTotal+"end"+ssEnd+"move amount"+ssMoveAmt+"/")
ssMoveme = setInterval("ssmoveScroll(1)",ssSpeed);
}
/////////////////////////////////// move back  /////////////////////////////////////////////////////////////
function ssPrev() {
clearInterval(ssAutoMoveme);
clearInterval(ssMoveme);
ssEnd+=ssMoveAmt;
//if(ssEnd>=(ssMoveAmt-20)){ssEnd=sstotalWidth-ssTotal+20}
if(ssEnd>=(ssMoveAmt-20)){ssEnd-=ssMoveAmt;} else {
writeIt("total"+ssTotal+"end"+ssEnd+"move amount"+ssMoveAmt+"/")
ssMoveme = setInterval("ssmoveScroll(0)",ssSpeed);
}
}
/////////////////////////////////// total width  /////////////////////////////////////////////////////////////
function writeIt(thetxt){
//document.getElementById("writ").innerHTML = thetxt;
}

function ssCalcWidth() {
sstotalWidth = Number(ss_holderwidth);//width of holder
ssMoveAmt = Number(ss_movewidth);// move amount
sstheNum=0;
//for(i=0;i<ssmyArray.length;i++){sstheNum+=ssmyArray[i];}
for(i=0;i<ss_numarticles+1;i++){sstheNum+=ss_movewidth;} 
ssTotal=sstheNum;
document.getElementById("scrollMover").style.width = ssTotal+"px";
// ssautoMove();
}
/////////////////////////////////// automove  /////////////////////////////////////////////////////////////
function ssautoMove(){
ssAutoMoveme =  setInterval("ssNextAuto()",10000);
}

/////////------------------ end scrolly  -------------------////////////////////////////////////


///////////////////////////////////// gallery scripts ////////////////////////////////////////////////////
function showImage(imgNum){
document.getElementById('thePic').innerHTML = "<img src='"+pImages[imgNum][0]+"'>";
document.getElementById('theCap').innerHTML = pImages[imgNum][1];
currentNum = imgNum;
}

function showNext(){
if((currentNum+1)==totalNum){currentNum=0} else {currentNum++;}
showImage(currentNum);
}

function showPrev(){
if((currentNum-1)<0){currentNum=totalNum-1} else {currentNum--;}
showImage(currentNum);
}

function initiateGal(){
totalPages = Math.ceil(totalNum/16);
remainder = totalNum-(totalPages*16)
currentPage = 0;
showImage(0);
setThumbs();
}


function setThumbs(){
start = (currentPage*16)
if(currentPage==(totalPages-1)){theTotal=16+((currentPage*16)+remainder)} else {theTotal=16+(currentPage*16)}
myWriteThumb = "";
for(i=start;i<theTotal;i++){
if(pImages[i][2]!=undefined){myWriteThumb += "<a href='javascript:showImage("+i+");'><img src='"+pImages[i][2]+"' border='0'></a>";}
}
document.getElementById('theThumbs').innerHTML = myWriteThumb;
document.getElementById('theNums').innerHTML = "Page "+(currentPage+1)+" of "+totalPages;
}

function galNext(which){
switch(which){
case 0:
currentPage--;
if(currentPage<0){currentPage=0;}
break;
case 1:
currentPage++;
if(currentPage>=totalPages-1){currentPage=totalPages-1;}
break;
}
setThumbs();
}
///////////////////////////////////////////////////////////////////////////////////////////////

