
var cmsTimer;function prevCms(halt){if(halt){stopRotating=true;}
switch(currentCms){case'offersNew':offersNewCount=(offersNewCount>0)?offersNewCount-1:(offersNew.length-1);fetchCms(offersNewCount,offersNew,'offersCmsArea',true);break;case'offersUsed':offersUsedCount=(offersUsedCount>0)?offersUsedCount-1:(offersUsed.length-1);fetchCms(offersUsedCount,offersUsed,'offersCmsArea',true);break;case'offersAftersales':offersAftersalesCount=(offersAftersalesCount>0)?offersAftersalesCount-1:(offersAftersales.length-1);fetchCms(offersAftersalesCount,offersAftersales,'offersCmsArea',true);break;case'offersCommercial':offersCommercialCount=(offersCommercialCount>0)?offersCommercialCount-1:(offersCommercial.length-1);fetchCms(offersCommercialCount,offersCommercial,'offersCmsArea',true);break;case'offersFord':offersFordCount=(offersFordCount>0)?offersFordCount-1:(offersFord.length-1);fetchCms(offersFordCount,offersFord,'offersCmsArea',true);break;case'offersMazda':offersMazdaCount=(offersMazdaCount>0)?offersMazdaCount-1:(offersMazda.length-1);fetchCms(offersMazdaCount,offersMazda,'offersCmsArea',true);break;case'offersFiat':offersFiatCount=(offersFiatCount>0)?offersFiatCount-1:(offersFiat.length-1);fetchCms(offersFiatCount,offersFiat,'offersCmsArea',true);break;case'offersKia':offersKiaCount=(offersKiaCount>0)?offersKiaCount-1:(offersKia.length-1);fetchCms(offersKiaCount,offersKia,'offersCmsArea',true);break;case'offersEag':offersEagCount=(offersEagCount>0)?offersEagCount-1:(offersEag.length-1);fetchCms(offersEagCount,offersEag,'offersCmsArea',true);break;case'offersMotability':offersMotabilityCount=(offersMotabilityCount>0)?offersMotabilityCount-1:(offersMotability.length-1);fetchCms(offersMotabilityCount,offersMotability,'offersCmsArea',true);break;}}
function prevWallpaper(){wallpapersCount=(wallpapersCount>0)?wallpapersCount-1:(wallpapers.length-1);fetchCms(wallpapersCount,wallpapers,'wallpapersCmsArea',true);}
function changeCmsArea(newArea){$$('.offerLink').each(function(el){el.removeClassName('active');});$(newArea).addClassName('active');stopRotating=true;currentCms=newArea;switch(currentCms){case'offersNew':fetchCms(offersNewCount,offersNew,'offersCmsArea',true);break;case'offersUsed':fetchCms(offersUsedCount,offersUsed,'offersCmsArea',true);break;case'offersAftersales':fetchCms(offersAftersalesCount,offersAftersales,'offersCmsArea',true);break;case'offersCommercial':fetchCms(offersCommercialCount,offersCommercial,'offersCmsArea',true);break;case'offersFord':fetchCms(offersFordCount,offersFord,'offersCmsArea',true);break;case'offersMazda':fetchCms(offersMazdaCount,offersMazda,'offersCmsArea',true);break;case'offersFiat':fetchCms(offersFiatCount,offersFiat,'offersCmsArea',true);break;case'offersKia':fetchCms(offersKiaCount,offersKia,'offersCmsArea',true);break;case'offersVolvo':fetchCms(offersVolvoCount,offersVolvo,'offersCmsArea',true);break;case'offersMotability':fetchCms(offersMotabilityCount,offersMotability,'offersCmsArea',true);break;case'offersEag':fetchCms(offersEagCount,offersEag,'offersCmsArea',true);break;}
clearTimeout(cmsTimer);}
function nextCms(halt){if(halt){stopRotating=true;}
switch(currentCms){case'offersNew':offersNewCount=(offersNewCount<(offersNew.length-1))?offersNewCount+1:0;fetchCms(offersNewCount,offersNew,'offersCmsArea',true);break;case'offersUsed':offersUsedCount=(offersUsedCount<(offersUsed.length-1))?offersUsedCount+1:0;fetchCms(offersUsedCount,offersUsed,'offersCmsArea',true);break;case'offersAftersales':offersAftersalesCount=(offersAftersalesCount<(offersAftersales.length-1))?offersAftersalesCount+1:0;fetchCms(offersAftersalesCount,offersAftersales,'offersCmsArea',true);break;case'offersCommercial':offersCommercialCount=(offersCommercialCount<(offersCommercial.length-1))?offersCommercialCount+1:0;fetchCms(offersCommercialCount,offersCommercial,'offersCmsArea',true);break;case'offersFord':$('offersFord').addClassName('active');offersFordCount=(offersFordCount<(offersFord.length-1))?offersFordCount+1:0;fetchCms(offersFordCount,offersFord,'offersCmsArea',true);break;case'offersMazda':$('offersMazda').addClassName('active');offersMazdaCount=(offersMazdaCount<(offersMazda.length-1))?offersMazdaCount+1:0;fetchCms(offersMazdaCount,offersMazda,'offersCmsArea',true);break;case'offersFiat':$('offersFiat').addClassName('active');offersFiatCount=(offersFiatCount<(offersFiat.length-1))?offersFiatCount+1:0;fetchCms(offersFiatCount,offersFiat,'offersCmsArea',true);break;case'offersKia':$('offersKia').addClassName('active');offersKiaCount=(offersKiaCount<(offersKia.length-1))?offersKiaCount+1:0;fetchCms(offersKiaCount,offersKia,'offersCmsArea',true);break;case'offersVolvo':$('offersVolvo').addClassName('active');offersVolvoCount=(offersVolvoCount<(offersVolvo.length-1))?offersVolvoCount+1:0;fetchCms(offersVolvoCount,offersVolvo,'offersCmsArea',true);break;case'offersEag':offersEagCount=(offersEagCount<(offersEag.length-1))?offersEagCount+1:0;fetchCms(offersEagCount,offersEag,'offersCmsArea',true);break;case'offersMotability':$('offersMotability').addClassName('active');offersMotabilityCount=(offersMotabilityCount<(offersMotability.length-1))?offersMotabilityCount+1:0;fetchCms(offersMotabilityCount,offersMotability,'offersCmsArea',true);break;}}
function nextWallpaper(){wallpapersCount=(wallpapersCount<(wallpapers.length-1))?wallpapersCount+1:0;fetchCms(wallpapersCount,wallpapers,'wallpapersCmsArea',true);}
function rotateOffers(){cmsTimer=setTimeout("changeViaRotate(currentCms)",6000);}
function rotateOffersFranchise(){cmsTimerFranch=setTimeout("changeViaRotateFranchise()",6000);}
function changeViaRotateFranchise(){if(!stopRotating){nextCms();rotateOffersFranchise();}}
function changeViaRotate(cms){$$('.offerLink').each(function(el){el.removeClassName('active');});if(currentCms!=cms){}else{switch(cms){case'offersFord':fetchCms(offersFordCount,offersFord,'offersCmsArea',false);currentCms='offersMazda';$('offersFord').addClassName('active');break;case'offersMazda':fetchCms(offersMazdaCount,offersMazda,'offersCmsArea',false);currentCms='offersFiat';$('offersMazda').addClassName('active');break;case'offersFiat':fetchCms(offersFiatCount,offersFiat,'offersCmsArea',false);currentCms='offersKia';$('offersFiat').addClassName('active');break;case'offersKia':fetchCms(offersKiaCount,offersKia,'offersCmsArea',false);currentCms='offersMotability';$('offersKia').addClassName('active');break;case'offersVolvo':fetchCms(offersVolvoCount,offersVolvo,'offersCmsArea',false);currentCms='offersVolvo';$('offersVolvo').addClassName('active');break;case'offersAftersales':fetchCms(offersAftersalesCount,offersAftersales,'offersCmsArea',false);currentCms='offersNew';$('offersAftersales').addClassName('active');break;case'offersCommercial':fetchCms(offersCommercialCount,offersCommercial,'offersCmsArea',false);currentCms='offersAftersales';$('offersCommercial').addClassName('active');break;case'offersNew':fetchCms(offersNewCount,offersNew,'offersCmsArea',false);currentCms='offersUsed';$('offersNew').addClassName('active');break;case'offersUsed':fetchCms(offersUsedCount,offersUsed,'offersCmsArea',false);currentCms='offersMotability';$('offersUsed').addClassName('active');break;case'offersMotability':fetchCms(offersMotabilityCount,offersMotability,'offersCmsArea',false);currentCms='offersFord';$('offersMotability').addClassName('active');break;}
rotateOffers();}}
function displayLoadingCms(element){$(element).innerHTML='<div style="padding:80px 0px 0px 145px;"><img src="'+baseHref+'/images/layup/loading.gif" alt="loading..." style="margin-left:10px;" /><br />Loading...</div>';}
function fetchCms(cmsCount,cmsArray,cmsElement,loadShow){if($('totalNumberWallpaper')){$('totalNumberWallpaper').innerHTML=wallpapers.length;$('currentNumberWallpaper').innerHTML=wallpapersCount+1;}
if($('totalNumber')){$('totalNumber').innerHTML=cmsArray.length;$('currentNumber').innerHTML=cmsCount+1;}
if(loadShow){displayLoadingCms(cmsElement);}
var target='ajaxHome.php';var params='type=nextCmsItem&id='+cmsArray[cmsCount];var myAjax=new Ajax.Updater((cmsElement),target,{method:'post',parameters:params});}
function prevGroupNews($area){switch($area){case'news':currentEagNewsCount=(currentEagNewsCount>0)?currentEagNewsCount-1:(newsEag.length-1);fetchGroupNews(currentEagNewsCount,newsEag,'newsEagContentArea',true);$('eagCount').update((currentEagNewsCount+1)+' of '+newsEag.length);break;case'community':currentCommunityCount=(currentCommunityCount>0)?currentCommunityCount-1:(community.length-1);fetchGroupNews(currentCommunityCount,community,'communityContentArea',true);$('communityCount').update((currentCommunityCount+1)+' of '+community.length);break;case'careers':currentCareersCount=(currentCareersCount>0)?currentCareersCount-1:(careers.length-1);fetchGroupNews(currentCareersCount,careers,'careersContentArea',true);$('careersCount').update((currentCareersCount+1)+' of '+careers.length);break;}}
function nextGroupNews($area){switch($area){case'news':currentEagNewsCount=(currentEagNewsCount<(newsEag.length-1))?currentEagNewsCount+1:0;fetchGroupNews(currentEagNewsCount,newsEag,'newsEagContentArea',true);$('eagCount').update((currentEagNewsCount+1)+' of '+newsEag.length);break;case'community':currentCommunityCount=(currentCommunityCount<(community.length-1))?currentCommunityCount+1:0;fetchGroupNews(currentCommunityCount,community,'communityContentArea',true);$('communityCount').update((currentCommunityCount+1)+' of '+community.length);break;case'careers':currentCareersCount=(currentCareersCount<(careers.length-1))?currentCareersCount+1:0;fetchGroupNews(currentCareersCount,careers,'careersContentArea',true);$('careersCount').update((currentCareersCount+1)+' of '+careers.length);break;}}
function prevNews(){currentNewsCount=(currentNewsCount>0)?currentNewsCount-1:(news.length-1);fetchNews(currentNewsCount,news,'newsContentArea');$('newsCountCurrent').update((currentEagNewsCount+1)+' of '+newsEag.length);}
function nextNews(){currentNewsCount=(currentNewsCount<(news.length-1))?currentNewsCount+1:0;fetchNews(currentNewsCount,news,'newsContentArea');$('newsCountCurrent').update((currentEagNewsCount+1)+' of '+newsEag.length);}
function prevEagNews(){currentEagNewsCount=(currentEagNewsCount>0)?currentEagNewsCount-1:(newsEag.length-1);fetchNews(currentEagNewsCount,newsEag,'newsEagContentArea');}
function nextEagNews(){currentEagNewsCount=(currentEagNewsCount<(newsEag.length-1))?currentEagNewsCount+1:0;fetchNews(currentEagNewsCount,newsEag,'newsEagContentArea');}
function displayLoading(element){$(element).innerHTML='<div style="padding:80px 0px 0px 105px;"><img src="'+baseHref+'/images/layup/loading.gif" alt="loading..." style="margin-left:10px;" /><br />Loading...</div>';}
function displayGroupLoading(element){$(element).innerHTML='<div style="padding:80px 0px 0px 170px;"><img src="'+baseHref+'/images/layup/loading.gif" alt="loading..." style="margin-left:10px;" /><br />Loading...</div>';}
function fetchNews(currentNewsCount,news,newsElement){if(newsElement=='newsEagContentArea'){$('totalNumberEAGNews').innerHTML=news.length;$('currentNumberEAGNews').innerHTML=currentNewsCount+1;}else{$('totalNumberNews').innerHTML=news.length;$('currentNumberNews').innerHTML=currentNewsCount+1;}
displayLoading(newsElement);var target='ajaxHome.php';var params='type=nextNewsItem&id='+news[currentNewsCount];var myAjax=new Ajax.Updater((newsElement),target,{method:'post',parameters:params});}
function fetchGroupNews(currentNewsCount,news,newsElement,showLoad){if(showLoad)displayGroupLoading(newsElement);var target='ajaxHome.php';var params='type=nextGroupNewsItem&id='+news[currentNewsCount];var myAjax=new Ajax.Updater((newsElement),target,{method:'post',parameters:params});}
