var menuOpened=0;
var menuSubOpened=0;
var menuModelOpened=0;
var equipSubOpened=0;
var pageLoadingCreate=0;
var menuID='';
var catID='';
var subID='';
var brandID='';
var categoryID='';
var modelID='';
var uri = new Object();
var baseDir = 'http://';
var temp='';
var subscribe_open=false;
var sel=0;
var eq_temp='';

function equipSub(subName,brand,category){
	if(eq_temp!=subName+'_'+brand+'_'+category){
		if($('equip_'+subName+'_'+brand+'_'+category)){
			if(equipSubOpened>0){
				equipSubClose();
			}
			new Effect.BlindDown('equip_'+subName+'_'+brand+'_'+category, {duration: 0.25});
			equipSubOpened++;
			eq_temp = subName+'_'+brand+'_'+category;
			$('eq_'+eq_temp).setStyle({
				fontWeight : 'bold'
			});
		}
	}
}

function equipSubClose(){
	new Effect.BlindUp('equip_'+eq_temp, {duration: 0.25});
	equipSubOpened=0;	
	
	$('eq_'+eq_temp).setStyle({
		fontWeight : 'normal'
	});
	
	eq_temp = '';
}

//Navigator Toggel
function menuClick(menu){
	if(menu != menuID){
		if(menuOpened > 0){
			if(equipSubOpened>0){
				equipSubClose();
			}
			if(menuModelOpened > 0){
				menuModelClose();
			}
			if(menuSubOpened > 0){
				if(catID!='99'){
					menuSubClose();
				}else{
					var elm = document.getElementById('nav'+menuID+'cat'+catID).style;
					elm.fontWeight = 'normal';
					catID = '';
					menuSubOpened=0;
				}
			}
			menuClose();
		}
		if(menu == '1' || menu == '2'){
			new Effect.BlindDown('menu'+menu, {duration: 0.25});
		}
		var elm = document.getElementById('nav'+menu).style;
		//elm.color = 'rgb(255,255,255)';
		elm.fontWeight = 'bold';
		menuID = menu;
		menuOpened++;
		
		if(menu != '1' && menu != '2'){
			AjaxContent(menu,'0','0','0');	
		}
	}
}

function menuClose(){
	if(menuID == '1' || menuID == '2'){
		new Effect.BlindUp('menu'+menuID, {duration: 0.25});
	}
	var elm = document.getElementById('nav'+menuID).style;
	//elm.color = 'rgb(255,255,255)';
	elm.fontWeight = 'normal';
	menuID = '';
	menuOpened=0;
}

function menuSubClick(menu,cat){
	
	if(cat != catID){
		if(menuSubOpened > 0){
			if(equipSubOpened>0){
				equipSubClose();
			}
			if(menuModelOpened > 0){
				menuModelClose();
			}
			if(catID!='99'){
				menuSubClose();
			}else{
				var elm = document.getElementById('nav'+menuID+'cat'+catID).style;
				elm.fontWeight = 'normal';
				catID = '';
				menuSubOpened=0;
			}
		}
		if(cat!='99'){
			new Effect.BlindDown('menu'+menu+'cat'+cat, {duration: 0.25});
		}
		var elm = document.getElementById('nav'+menu+'cat'+cat).style;
		//elm.color = 'rgb(0,0,0)';
		elm.fontWeight = 'bold';
		menuID = menu;
		catID = cat;
		menuSubOpened++;
		if(cat=='99'){
			view_all(menu);
		}
	}
}

function menuSubClose(){
	new Effect.BlindUp('menu'+menuID+'cat'+catID, {duration: 0.25});
	var elm = document.getElementById('nav'+menuID+'cat'+catID).style;
	//elm.color = 'rgb(255,255,255)';
	elm.fontWeight = 'normal';
	catID = '';
	menuSubOpened=0;
}

function menuModelClick(menu,cat,subcat){
	if(subcat != subID){
		if(equipSubOpened>0){
			equipSubClose();
		}
		if(menuModelOpened > 0){
			menuModelClose();
		}
		new Effect.BlindDown('menu'+menu+'cat'+cat+'sub'+subcat, {duration: 0.25});
		var elm = document.getElementById('nav'+menu+'cat'+cat+'sub'+subcat).style;
		//elm.color = 'rgb(0,0,0)';
		elm.fontWeight = 'bold';
		menuID = menu;
		catID = cat;
		subID = subcat;
		menuModelOpened++;
	}
}

function menuModelClose(){
	if(modelID!=''){
		if(menuID=='1'){
			var el = document.getElementById('nav'+menuID+'cat'+catID+'br0'+'sub'+subID+'mod'+modelID);
			if(el){
				el.style.fontWeight = 'normal';
			}
			modelID = '';
		}else{
			var el = document.getElementById('nav'+menuID+'cat'+catID+'br'+brandID+'sub'+categoryID+'mod'+modelID);
			if(el){
				el.style.fontWeight = 'normal';
			}
			brandID = '';
			categoryID = '';
			modelID = '';
		}
	}
	
	new Effect.BlindUp('menu'+menuID+'cat'+catID+'sub'+subID, {duration: 0.25});
	var elm = document.getElementById('nav'+menuID+'cat'+catID+'sub'+subID).style;
	//elm.color = 'rgb(255,255,255)';
	elm.fontWeight = 'normal';
	subID = '';
	menuModelOpened=0;
}

//E-Mail Toggle
function mail_over(){
	if(!subscribe_open){
		var elm = document.getElementById('spHeadTitle').innerHTML;	
		temp = elm;
		if(elm!='SUBSCRIBE FOR LATEST INFORMATION'){
			document.getElementById('spHeadTitle').innerHTML = 'SUBSCRIBE FOR LATEST INFORMATION';
		}
	}
}
function mail_out(){
	if(!subscribe_open){
		var elm = document.getElementById('spHeadTitle').innerHTML;
		if(elm=='SUBSCRIBE FOR LATEST INFORMATION'){
			document.getElementById('spHeadTitle').innerHTML = temp;
		}
	}
}

//Show loading content
function startLoading(loading,content){
	show_loading(loading,content);
}

function show_loading(loading,content){
	var el = document.getElementById(loading);
		if (el) {
			Element.show(loading);
			Element.hide(content);
		}
}

function stopLoading(loading,content) {
		new Effect.Fade(loading,{queue:{scope:'loading', position:'end'}, duration:1.0});
		new Effect.Appear(content,{queue:{scope:'loading', position:'end'}, duration:0.1});
}


//Ajax Content
function AjaxContent(menu,cat,br,subcat,model){
	var elm = document.getElementById('contentIndex')
	if(elm){
		var dvBody = document.getElementById('dvBody');
		var dvSideBar = document.getElementById('dvSideBar');
		dvBody.removeChild(dvSideBar);
		dvBody.removeChild(elm);
		
		var newContent = document.createElement('div');
		newContent.setAttribute('id','content');
		dvBody.appendChild(newContent);
		
		var newLoadingContent = document.createElement('div');
		newLoadingContent.setAttribute('id','content_loading');
		newLoadingContent.setAttribute('class','dvLoading');
		newLoadingContent.style.cssText = 'width:633px !important;margin-top:100px;display:none;';

		var newTable = '<table width="100%" cellspacing="0"><tr>';
		newTable = newTable+'<td align="right" width="45%"><img src="'+baseDir+'images/body/loader_transparent.gif" alt="Loading..." style="padding-right:5px;"/></td>';
		newTable = newTable+'<td align="left" width="55%"><span class="loadingText">loading...</span></td>';
		newTable = newTable+'</tr></table>';

		newLoadingContent.innerHTML = newTable;
		dvBody.appendChild(newLoadingContent);	
	}
	
	if(menuOpened > 0){
		if(menuModelOpened > 0){
				if(menuID=='1'){
					var el = document.getElementById('nav'+menuID+'cat'+catID+'br0'+'sub'+subID+'mod'+modelID);
					if(el){
						el.style.fontWeight = 'normal';
					}
					modelID = '';
				}else{
					var el = document.getElementById('nav'+menuID+'cat'+catID+'br'+brandID+'sub'+categoryID+'mod'+modelID);
					if(el){
						el.style.fontWeight = 'normal';
					}
					brandID = '';
					categoryID = '';
					modelID = '';
				}
	
			Element.hide('menu'+menuID+'cat'+catID+'sub'+subID);
			var elm = document.getElementById('nav'+menuID+'cat'+catID+'sub'+subID).style;
			//elm.color = 'rgb(255,255,255)';
			elm.fontWeight = 'normal';
			subID = '';
			menuModelOpened=0;
		}
		if(menuSubOpened > 0){
			if(catID!='99'){
				Element.hide('menu'+menuID+'cat'+catID);
			}
			var elm = document.getElementById('nav'+menuID+'cat'+catID).style;
			//elm.color = 'rgb(255,255,255)';
			elm.fontWeight = 'normal';
			catID = '';
			menuSubOpened=0;
		}
		if(menuID == '1' || menuID == '2'){
			Element.hide('menu'+menuID);
			var elm = document.getElementById('nav'+menuID).style;
			//elm.color = 'rgb(255,255,255)';
			elm.fontWeight = 'normal';
			menuID = '';
			menuOpened=0;
		}
	}
	
	if(modelID!=''){
		if(menu=='1'){
			var el = document.getElementById('nav'+menuID+'cat'+catID+'br0'+'sub'+subID+'mod'+modelID);
			if(el){
				el.style.fontWeight = 'normal';
			}
				menuID = '';
				catID = '';
				subID = '';
				modelID = '';
		}else{
			var el = document.getElementById('nav'+menuID+'cat'+catID+'br'+brandID+'sub'+categoryID+'mod'+modelID);
			if(el){
				el.style.fontWeight = 'normal';
			}
				menuID = '';
				catID = '';
				subID = '';
				brandID = '';
				categoryID = '';
				modelID = '';
		}
	}
	
	startLoading('content_loading','content');
	document.getElementById('content').innerHTML = '';
	document.getElementById('email').value='';
	document.getElementById('search_key').value='';
	var elm = document.getElementById('spHeadTitle');
	
	switch(menu){
		case '1' : {	if(menuOpened>0 && menuID=='2'){
							if(menuModelOpened > 0){
								menuModelClose();
							}
							if(menuSubOpened > 0){
								if(catID!='99'){
									menuSubClose();
								}else{
									var elm = document.getElementById('nav'+menuID+'cat'+catID).style;
									elm.fontWeight = 'normal';
									catID = '';
									menuSubOpened=0;
								}
							}
							menuClose();
						}	
						
						var el = document.getElementById('nav'+menu+'cat'+cat).style;
						el.fontWeight = 'bold';
						var el = document.getElementById('nav'+menu+'cat'+cat+'sub'+subcat).style;
						el.fontWeight = 'bold';
						var el = document.getElementById('nav'+menu+'cat'+cat+'br0'+'sub'+subcat+'mod'+model).style;
						el.fontWeight = 'bold';
						menuID = menu;catID = cat;subID = subcat;modelID = model;
						
						var elm = document.getElementById('nav'+menu).style; elm.fontWeight='bold';
						Element.show('menu'+menu);
						Element.show('menu'+menu+'cat'+cat);
						Element.show('menu'+menu+'cat'+cat+'sub'+subcat);
						menuOpened++;
						menuSubOpened++;
						menuModelOpened++;
						new Ajax.Updater('content', baseDir+'index.php/apps/AjaxContent', 
							{
								 method: 'post', 
								 postBody:'menu='+ menu +'&cat='+ cat +'&subcat='+ subcat +'&model='+ model +'',
								 onComplete: function(){
									stopLoading('content_loading','content');
									elm = document.getElementById('spHeadTitle');
									elm.innerHTML = 'BIKES'; 
								}
						 });
						break;
				   }
		case '2' : {
						if(menuOpened>0 && menuID=='1'){
							if(equipSubOpened>0){
								equipSubClose();
							}
							if(menuModelOpened > 0){
								menuModelClose();
							}
							if(menuSubOpened > 0){
								menuSubClose();
							}
							menuClose();
						}	
						
						var el = document.getElementById('nav'+menu+'cat'+cat).style;
						el.fontWeight = 'bold';
						if(cat=='7'){
							var el = document.getElementById('nav'+menu+'cat'+cat+'sub'+br).style;
							el.fontWeight = 'bold';
						}else{
							var el = document.getElementById('nav'+menu+'cat'+cat+'sub'+subcat).style;
							el.fontWeight = 'bold';
						}
						
						Element.show('menu'+menu);
						Element.show('menu'+menu+'cat'+cat);
						
						if(cat=='7'){
							Element.show('menu'+menu+'cat'+cat+'sub'+br);
							subID= br;
							
							$('equip_brand_'+br+'_'+subcat).show();
							eq_temp ='brand_'+br+'_'+subcat;
							menuID = menu;catID = cat;subID= br;brandID = br;categoryID = subcat;modelID = model;
						}else{
							Element.show('menu'+menu+'cat'+cat+'sub'+subcat);
							subID= subcat;
							
							$('equip_category_'+br+'_'+subcat).show();
							eq_temp ='category_'+br+'_'+subcat;
							menuID = menu;catID = cat;subID= subcat;brandID = br;categoryID = subcat;modelID = model;
						}
						var elm = document.getElementById('nav'+menu).style; elm.fontWeight='bold';
						
						equipSubOpened++;
						menuOpened++;
						menuSubOpened++;
						menuModelOpened++;
						
						/*new Effect.BlindDown('equip_'+subName+'_'+brand+'_'+category, {duration: 0.25});
						equipSubOpened++;
						eq_temp = subName+'_'+brand+'_'+category;
						$('eq_'+eq_temp).setStyle({
							fontWeight : 'bold'
						});*/
						/*
						var el = document.getElementById('nav'+menu+'cat'+cat).style;
						el.fontWeight = 'bold';
						if(cat=='7'){
							var el = document.getElementById('nav'+menu+'cat'+cat+'sub'+br).style;
							el.fontWeight = 'bold';
						}else{
							var el = document.getElementById('nav'+menu+'cat'+cat+'sub'+subcat).style;
							el.fontWeight = 'bold';
						}
						var el = document.getElementById('nav'+menu+'cat'+cat+'br'+br+'sub'+subcat+'mod'+model).style;
						el.fontWeight = 'bold';
						menuID = menu;catID = cat;subID= br;brandID = br;categoryID = subcat;modelID = model;
						
						var elm = document.getElementById('nav'+menu).style; elm.fontWeight='bold';
						Element.show('menu'+menu);
						Element.show('menu'+menu+'cat'+cat);
						if(cat=='7'){
							Element.show('menu'+menu+'cat'+cat+'sub'+br);
							subID= br;
						}else{
							Element.show('menu'+menu+'cat'+cat+'sub'+subcat);
							subID= subcat;
						}
						
						menuOpened++;
						menuSubOpened++;
						menuModelOpened++;
						*/
						new Ajax.Updater('content', baseDir+'index.php/apps/AjaxContent', 
							{
								 method: 'post', 
								 postBody:'menu='+ menu +'&cat='+ cat +'&br='+ br +'&subcat='+ subcat +'&model='+ model +'',
								 onComplete: function(){
									stopLoading('content_loading','content');
									elm = document.getElementById('spHeadTitle');
									elm.innerHTML = 'EQUIPMENT'; 
								}
						 });
						break;
				   }
		case '3' : {
						new Ajax.Updater('content', baseDir+'index.php/apps/AjaxContent', 
							{
								 method: 'post', 
								 postBody:'menu='+ menu +'',
								 onComplete: function(){
									stopLoading('content_loading','content');
									elm.innerHTML = 'HOME';
								}
							});						
						break;
				   }	
		case '4' : {
						new Ajax.Updater('content', baseDir+'index.php/apps/AjaxContent', 
							{
								 method: 'post', 
								 postBody:'menu='+ menu +'',
								 onComplete: function(){
									stopLoading('content_loading','content');
									elm.innerHTML = 'TEAM &amp; RIDERS';
								}
							});
						break;
				   }
		case '5' : {
						new Ajax.Updater('content', baseDir+'index.php/apps/AjaxContent', 
							{
								 method: 'post', 
								 postBody:'menu='+ menu +'&page=1',
								 onComplete: function(){
									stopLoading('content_loading','content');
									elm.innerHTML = 'PROMOTION';
									pageLoadingCreate=0;
								}
							});
						break;
				   }
		case '6' : {
						new Ajax.Updater('content', baseDir+'index.php/apps/AjaxContent', 
							{
								 method: 'post', 
								 postBody:'menu='+ menu +'&page=1',
								 onComplete: function(){
									stopLoading('content_loading','content');
									elm.innerHTML = 'GALLERIES';
									pageLoadingCreate=0;
								}
							});	
						break;
				   }
		case '7' : {
						new Ajax.Updater('content', baseDir+'index.php/apps/AjaxContent', 
							{
								 method: 'post', 
								 postBody:'menu='+ menu +'',
								 onComplete: function(){
									stopLoading('content_loading','content');
									elm.innerHTML = 'JOBS';
								}
							});	
						break;
				   }
		case '8' : {
						new Ajax.Updater('content', baseDir+'index.php/apps/AjaxContent', 
							{
								 method: 'post', 
								 postBody:'menu='+ menu +'',
								 onComplete: function(){
									stopLoading('content_loading','content');
									elm.innerHTML = 'HELP &amp SUPPORT';
								}
							});	
						break;
				   }
		case '9' : {
						new Ajax.Updater('content', baseDir+'index.php/apps/AjaxContent', 
							{
								 method: 'post', 
								 postBody:'menu='+ menu +'',
								 onComplete: function(){
									stopLoading('content_loading','content');
									elm.innerHTML = 'OUR STORE';
								}
							});	
						break;
				   }
	}
	
	temp = document.getElementById('spHeadTitle').innerHTML;
	subscribe_open=false;
}

//View All
function view_all(menu){
	var elm = document.getElementById('contentIndex')
	if(elm){
		var dvBody = document.getElementById('dvBody');
		var dvSideBar = document.getElementById('dvSideBar');
		dvBody.removeChild(dvSideBar);
		dvBody.removeChild(elm);
		
		var newContent = document.createElement('div');
		newContent.setAttribute('id','content');
		dvBody.appendChild(newContent);
		
		var newLoadingContent = document.createElement('div');
		newLoadingContent.setAttribute('id','content_loading');
		newLoadingContent.setAttribute('class','dvLoading');
		newLoadingContent.style.cssText = 'width:633px !important;margin-top:100px;display:none;';

		var newTable = '<table width="100%" cellspacing="0"><tr>';
		newTable = newTable+'<td align="right" width="45%"><img src="'+baseDir+'images/body/loader_transparent.gif" alt="Loading..." style="padding-right:5px;"/></td>';
		newTable = newTable+'<td align="left" width="55%"><span class="loadingText">loading...</span></td>';
		newTable = newTable+'</tr></table>';

		newLoadingContent.innerHTML = newTable;
		dvBody.appendChild(newLoadingContent);	
	}else{
		var elm = document.getElementById('content_loading')
		if(elm && pageLoadingCreate==0){
			var dvBody = document.getElementById('dvBody');
			dvBody.removeChild(elm);
		
			var newLoadingContent = document.createElement('div');
			newLoadingContent.setAttribute('id','content_loading');
			newLoadingContent.setAttribute('class','dvLoading');
			newLoadingContent.style.cssText = 'width:633px !important;margin-top:100px;display:none;';

			var newTable = '<table width="100%" cellspacing="0"><tr>';
			newTable = newTable+'<td align="right" width="45%"><img src="'+baseDir+'images/body/loader_transparent.gif" alt="Loading..." style="padding-right:5px;"/></td>';
			newTable = newTable+'<td align="left" width="55%"><span class="loadingText">loading...</span></td>';
			newTable = newTable+'</tr></table>';

			newLoadingContent.innerHTML = newTable;
			dvBody.appendChild(newLoadingContent);	
			pageLoadingCreate++;
		}	
	}
	
	startLoading('content_loading','content');
	
	switch(menu){
		case '1': 
					new Ajax.Updater('content', baseDir+'index.php/apps/AjaxContent', 
						{
							method: 'post', 
							//postBody:'menu='+menu+'&page='+page+'&cat='+cat+'&br='+brand+'&subcat='+category+'&model='+model,
							postBody:'menu=10&page=1',
							onComplete: function(){
								stopLoading('content_loading','content');
								document.getElementById('spHeadTitle').innerHTML = 'BIKES';
							}
						});	
				  break;
		case '2': new Ajax.Updater('content', baseDir+'index.php/apps/AjaxContent', 
						{
							method: 'post', 
							//postBody:'menu='+menu+'&page='+page+'&cat='+cat+'&br='+brand+'&subcat='+category+'&model='+model,
							postBody:'menu=11&page=1',
							onComplete: function(){
								stopLoading('content_loading','content');
								document.getElementById('spHeadTitle').innerHTML = 'EQUIPMENT';
							}
						});	
				  break;
	}	
}

//Changin Tab Models
function ChangeTab(index){
	switch(index){
		case 1:{
			var elm = document.getElementsByClassName('TabContentInside');
			for(i=0;i<=elm.length-1;i++){
				elm[i].style.display = 'none';	
			}
			Element.show('storyContent');
			document.getElementById('storyTab').className = 'TabActive';
			document.getElementById('featureTab').className = 'TabInactive';
			document.getElementById('specificationTab').className = 'TabInactiveLast';
			document.getElementById('storyTab').innerHTML = 'Story';
			document.getElementById('featureTab').innerHTML = '<a href="javascript:;" onclick="ChangeTab(2)">Feature</a>';
			document.getElementById('specificationTab').innerHTML = '<a href="javascript:;" onclick="ChangeTab(3)">Technical Specifications</a>';
			break;
		}
		case 2:{
			var elm = document.getElementsByClassName('TabContentInside');
			for(i=0;i<=elm.length-1;i++){
				elm[i].style.display = 'none';	
			}
			Element.show('featureContent');
			document.getElementById('storyTab').className = 'TabInactive';
			document.getElementById('featureTab').className = 'TabActive';
			document.getElementById('specificationTab').className = 'TabInactiveLast';
			document.getElementById('storyTab').innerHTML = '<a href="javascript:;" onclick="ChangeTab(1)">Story</a>';
			document.getElementById('featureTab').innerHTML = 'Feature';
			document.getElementById('specificationTab').innerHTML = '<a href="javascript:;" onclick="ChangeTab(3)">Technical Specifications</a>';
			break;
		}
		case 3:{
			var elm = document.getElementsByClassName('TabContentInside');
			for(i=0;i<=elm.length-1;i++){
				elm[i].style.display = 'none';	
			}
			Element.show('specificationContent');
			document.getElementById('storyTab').className = 'TabInactive';
			document.getElementById('featureTab').className = 'TabInactive';
			document.getElementById('specificationTab').className = 'TabActiveLast';
			document.getElementById('storyTab').innerHTML = '<a href="javascript:;" onclick="ChangeTab(1)">Story</a>';
			document.getElementById('featureTab').innerHTML = '<a href="javascript:;" onclick="ChangeTab(2)">Feature</a>';
			document.getElementById('specificationTab').innerHTML = 'Technical Specifications';
			break;
		}
	}
}

//Change Page for Gallery
//function open_page(menu,cat,brand,category,model,page){
function open_page(menu,page){
	var elm = document.getElementById('content_loading')
	if(elm && pageLoadingCreate==0){
		var dvBody = document.getElementById('dvBody');
		dvBody.removeChild(elm);
		
		var newLoadingContent = document.createElement('div');
		newLoadingContent.setAttribute('id','content_loading');
		newLoadingContent.setAttribute('class','dvLoading');
		newLoadingContent.style.cssText = 'width:633px !important;margin-top:100px;display:none;';

		var newTable = '<table width="100%" cellspacing="0"><tr>';
		newTable = newTable+'<td align="right" width="45%"><img src="'+baseDir+'images/body/loader_transparent.gif" alt="Loading..." style="padding-right:5px;"/></td>';
		newTable = newTable+'<td align="left" width="55%"><span class="loadingText">loading...</span></td>';
		newTable = newTable+'</tr></table>';

		newLoadingContent.innerHTML = newTable;
		dvBody.appendChild(newLoadingContent);	
		pageLoadingCreate++;
	}
	
	startLoading('content_loading','content');
	var elm = document.getElementById('view_page');
	var per_page = elm.value;
	document.getElementById('content').innerHTML = '';

	new Ajax.Updater('content', baseDir+'index.php/apps/AjaxContent', 
	{
		method: 'post', 
		//postBody:'menu='+menu+'&page='+page+'&cat='+cat+'&br='+brand+'&subcat='+category+'&model='+model,
		postBody:'menu='+menu+'&page='+page+'&per_page='+per_page,
		onComplete: function(){
			stopLoading('content_loading','content');
			document.getElementById('view_page').selectedIndex = sel;
		}
	});	


}

function AjaxPerPage(menu){
	var elm = document.getElementById('content_loading');
	if(elm && pageLoadingCreate==0){
		var dvBody = document.getElementById('dvBody');
		dvBody.removeChild(elm);
		
		var newLoadingContent = document.createElement('div');
		newLoadingContent.setAttribute('id','content_loading');
		newLoadingContent.setAttribute('class','dvLoading');
		newLoadingContent.style.cssText = 'width:633px !important;margin-top:100px;display:none;';

		var newTable = '<table width="100%" cellspacing="0"><tr>';
		newTable = newTable+'<td align="right" width="45%"><img src="'+baseDir+'images/body/loader_transparent.gif" alt="Loading..." style="padding-right:5px;"/></td>';
		newTable = newTable+'<td align="left" width="55%"><span class="loadingText">loading...</span></td>';
		newTable = newTable+'</tr></table>';

		newLoadingContent.innerHTML = newTable;
		dvBody.appendChild(newLoadingContent);	
		pageLoadingCreate++;
	}
	
	startLoading('content_loading','content');
	var elm = document.getElementById('view_page');
	var per_page = elm.value;
	sel = elm.selectedIndex;
	document.getElementById('content').innerHTML = '';

	new Ajax.Updater('content', baseDir+'index.php/apps/AjaxContent', 
	{
		method: 'post', 
		postBody:'menu='+menu+'&page=1&per_page='+per_page,
		onComplete: function(){
			stopLoading('content_loading','content');
			document.getElementById('view_page').selectedIndex = sel;
		}
	});		
}

//Print Content
function printPage(){
	var elm = document.getElementById('contentIndex');
	if(!elm){
		elm = document.getElementById('content');
	}
	var title=document.getElementById('spHeadTitle').innerHTML;
	/*switch(menuID){
		case '1': title='BIKES';break;
		case '2': title='EQUIPMENT';break;
		case '3': title='HOME';break;
		case '4': title='TEAM &amp; RIDER';break;
		case '5': title='PROMOTION';break;
		case '6': title='GALLERIES';break;
		case '7': title='JOBS';break;
		case '8': title='HELP &amp; SUPPORT';break;
		case '9': title='CONTACT US';break;
	}*/
	
	var openWindow = window.open('','','width=633,height=550,scrollbars=yes,resizable=no,toolbar=no,copyhistory=no');
	openWindow.document.open("text/html");
	openWindow.document.write('<link href="'+baseDir+'css/print.css" rel="stylesheet" type="text/css" />');
	openWindow.document.write('<title>RODALINK -'+title+'</title>');
	openWindow.document.write('<div id="contentPrint">');
	openWindow.document.write('<div id="dvPrintHead">');
	openWindow.document.write('<table width="80%" cellspacing="0" style="border-bottom:1px #cccccc solid;margin-left:20px;"><tr><td width="20%" align="left"><img src="'+baseDir+'images/body/logo.gif" width="162" height="30" border="0" /></td><td width="80%" align="left"><h1 class="h1Print">'+title+'</h1></td></tr></table>');
	openWindow.document.write('</div>');
	openWindow.document.write('<div id="dvPrint">');
	openWindow.document.write(elm.innerHTML);
	openWindow.document.write('</div>');
	openWindow.document.write('</div>');
	openWindow.document.write('<NOSCRIPT>It seems you either have an early version Browser or have JavaScript disabled. We regret that some features such as the ability to click on thumbnail images will not be available.</NOSCRIPT>');
	openWindow.document.close();
	openWindow.print();	
	//openWindow.close();
}

//Search
function AjaxSearch(){
	var elm = document.getElementById('contentIndex')
	if(elm){
		var dvBody = document.getElementById('dvBody');
		var dvSideBar = document.getElementById('dvSideBar');
		dvBody.removeChild(dvSideBar);
		dvBody.removeChild(elm);
		
		var newContent = document.createElement('div');
		newContent.setAttribute('id','content');
		dvBody.appendChild(newContent);
		
		var newLoadingContent = document.createElement('div');
		newLoadingContent.setAttribute('id','content_loading');
		newLoadingContent.setAttribute('class','dvLoading');
		newLoadingContent.style.cssText = 'width:600px;margin-top:100px;display:none;';

		var newTable = '<table width="100%" cellspacing="0"><tr>';
		newTable = newTable+'<td align="right" width="45%"><img src="'+baseDir+'images/body/loader_transparent.gif" alt="Loading..." style="padding-right:5px;"/></td>';
		newTable = newTable+'<td align="left" width="55%"><span class="loadingText">loading...</span></td>';
		newTable = newTable+'</tr></table>';

		newLoadingContent.innerHTML = newTable;
		dvBody.appendChild(newLoadingContent);
		
	}
	startLoading('content_loading','content');
	document.getElementById('content').innerHTML = '';
	document.getElementById('email').value='';
	var elm = document.getElementById('spHeadTitle');
	if(menuOpened > 0){
		if(menuModelOpened > 0){
			menuModelClose();
		}
		if(menuSubOpened > 0){
			if(catID!='99'){
				menuSubClose();
			}else{
				var elm = document.getElementById('nav'+menuID+'cat'+catID).style;
				elm.fontWeight = 'normal';
				catID = '';
				menuSubOpened=0;
			}
		}
		menuClose();
	}
	
	var key = document.getElementById('search_key').value;
	new Ajax.Updater('content', baseDir+'index.php/apps/AjaxSearch', 
							{
								 method: 'post', 
								 postBody:'key='+key,
								 onComplete: function(){
									stopLoading('content_loading','content');
									elm.innerHTML = 'SEARCH';
								}
							});	
}

window.onload = function(){
	init();
}

function init(){
	getURL(uri);
	baseDir = baseDir + uri.dom + '/' + uri.path + '/';
	
	if($('contentIndex')){
		$('footerContent').style.marginTop='12px';
		$('fC').style.marginBottom='0px';
	}
	
	//Create ToolTips
	//createToolTips();
}

function createToolTips(){
	new Tip('dvMail', 'Insert your E-Mail address here to subscribe.', {duration: 0.3,title:'Subscribe for Latest Information', effect: 'appear' });
}

function getURL(uri) {
	uri.dir = location.href.substring(0, location.href.lastIndexOf('\/'));
	uri.dom = uri.dir; if (uri.dom.substr(0,7) == 'http:\/\/') uri.dom = uri.dom.substr(7);
	uri.path = ''; var pos = uri.dom.indexOf('\/'); if (pos > -1) {uri.path = uri.dom.substr(pos+1); uri.dom = uri.dom.substr(0,pos);}
	uri.page = location.href.substring(uri.dir.length+1, location.href.length+1);
	pos = uri.page.indexOf('?');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	pos = uri.page.indexOf('#');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	uri.ext = ''; pos = uri.page.indexOf('.');if (pos > -1) {uri.ext =uri.page.substring(pos+1); uri.page = uri.page.substr(0,pos);}
	uri.file = uri.page;
	if (uri.ext != '') uri.file += '.' + uri.ext;
	if (uri.file == '') uri.page = 'index';
	uri.args = location.search.substr(1).split("?");
	
	return uri;
}

function enlarge_me(image_link){
		new Ajax.Request(	
					 baseDir+'index.php?act=apps&m=AjaxEnlargeMe',
					 {
						method: 'post', postBody:'image='+image_link,
						onSuccess: function(get){
							result = get.responseText;
							result = result.split('#');
							var title=document.getElementById('spHeadTitle').innerHTML;
							var newWindow = window.open('','','width='+result[0]+',height='+(parseInt(result[1])+90)+',scrollbars=yes,resizable=no,toolbar=no,copyhistory=no');
							newWindow.document.open("text/html");
							newWindow.document.write('<link href="'+baseDir+'css/print.css" rel="stylesheet" type="text/css" />');
							newWindow.document.write('<title>RODALINK -'+title+'</title>');
							newWindow.document.write('<div id="contentPrint">');
							newWindow.document.write('<div id="dvPrintHead">');
							newWindow.document.write('<table width="80%" cellspacing="0" style="border-bottom:1px #cccccc solid;margin-left:20px;"><tr><td width="20%" align="left"><img src="'+baseDir+'images/body/logo.gif" width="162" height="30" border="0" /></td><td width="80%" align="left"><h1 class="h1Print">'+title+'</h1></td></tr></table>');
							newWindow.document.write('</div>');
							if($('loc')){
								newWindow.document.write('<div style="margin-top:5px;margin-left:20px;text-align:left;">'+$('loc').innerHTML+'</div>');	
							}							
							newWindow.document.write('<div id="dvPrint" style="margin:10px 5px 0px 5px;">');
							newWindow.document.write('<a href="javascript:;" class="close" onclick="self.close();"><img src="'+baseDir+image_link+'" border="0" /></a>');
							newWindow.document.write('</div>');
							newWindow.document.write('<div id="dvPrint" style="margin:10px;text-align:right;">');
							newWindow.document.write('<a href="javascript:;" class="close" onclick="self.close();">close</a>');
							newWindow.document.write('</div>');
							newWindow.document.write('</div>');
							newWindow.document.write('<NOSCRIPT>It seems you either have an early version Browser or have JavaScript disabled. We regret that some features such as the ability to click on thumbnail images will not be available.</NOSCRIPT>');
							newWindow.document.close();	
						}	 
					 }
					);	
}
	

/***********************************************
* Email Validation script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function checkmail(){
	var elm = document.getElementById('contentIndex')
	if(elm){
		var dvBody = document.getElementById('dvBody');
		var dvSideBar = document.getElementById('dvSideBar');
		dvBody.removeChild(dvSideBar);
		dvBody.removeChild(elm);
		
		var newContent = document.createElement('div');
		newContent.setAttribute('id','content');
		dvBody.appendChild(newContent);
		
		var newLoadingContent = document.createElement('div');
		newLoadingContent.setAttribute('id','content_loading');
		newLoadingContent.setAttribute('class','dvLoading');
		newLoadingContent.style.cssText = 'width:600px;margin-top:100px;display:none;';

		var newTable = '<table width="100%" cellspacing="0"><tr>';
		newTable = newTable+'<td align="right" width="45%"><img src="'+baseDir+'images/body/loader_transparent.gif" alt="Loading..." style="padding-right:5px;"/></td>';
		newTable = newTable+'<td align="left" width="55%"><span class="loadingText">loading...</span></td>';
		newTable = newTable+'</tr></table>';

		newLoadingContent.innerHTML = newTable;
		dvBody.appendChild(newLoadingContent);
		
	}
	startLoading('content_loading','content');
	document.getElementById('content').innerHTML = '';
	document.getElementById('search_key').value='';
	var elm = document.getElementById('spHeadTitle');
	subscribe_open=true;
	if(menuOpened > 0){
		if(menuModelOpened > 0){
			menuModelClose();
		}
		if(menuSubOpened > 0){
			menuSubClose();
		}
		menuClose();
	}

	var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
	var e = document.getElementById('email');
	var valid=emailfilter.test(e.value);
	
	if(!valid){
			var div = '<div id="contentSubscribe" class="invalid">';
				div = div+'Sorry....<br/>The address you have entered is invalid';
			div = div+'<div>';
			document.getElementById('content').innerHTML = div;
			stopLoading('content_loading','content');
			e.select();
			elm.innerHTML = 'SUBSCRIBE FOR LATEST INFORMATION';
	}else{
			new Ajax.Updater('content', baseDir+'index.php/apps/AjaxSubscribe', 
							{
								 method: 'post', 
								 postBody:'email='+e.value,
								 onComplete: function(){
									stopLoading('content_loading','content');
									e.value='';
									elm.innerHTML = 'SUBSCRIBE FOR LATEST INFORMATION';
								}
							});	
	}
	
	
}