var WMTT=null;
var p="right";
var ratingactive=false;
var thumbrow_modern=0;
var thumbrow_classic=0;
var thumbrow_video=0;
var thumbrow_submitter=0;
document.onmousemove=updateToolTip;

function getMoreHotshots(submitter,start)
{
	$.ajax
	({
		type:"POST",
		url:"getmorehotshots.php",
		data:"submitter="+submitter+"&start="+start,
		beforeSend:function(data)
		{
			document.getElementById('myhotshots').innerHTML="<img src='http://www.exoticsonroad.com/img/icon_wait.gif' border=0 style='margin:36px; margin-bottom:38px;'>";
		},
		success:function(data)
		{
			document.getElementById('myhotshots').innerHTML=data;
		},
	});
}

function showLogin()
{ 
	document.getElementById('showlogintext').style.display='none';
	document.getElementById('loginform').style.display='';
}

function switchNaviButtons(area)
{
	document.getElementById('navibuttons_modern').style.display="none";
	document.getElementById('navibuttons_classic').style.display="none";
	document.getElementById('navibuttons_video').style.display="none";
	
	document.getElementById('navibuttons_'+area).style.display="";
}

function getCalendar(y,m,c,d)
{
	setRotatingCalendarArrows(d);
	x_getCalendar(y,m,c,setCalendar);
}

function setCalendar(result)
{
	document.getElementById('calendarspan').innerHTML=result;
	setTitle('Calendar loaded');
}

function setRotatingCalendarArrows(d)
{
	document.getElementById('calimg'+d).innerHTML="<img src='img/loading.gif' border=0 width=14 height=15>";
	setTitle('Loading new calendar');
}

function setCommentsAsActveTab()
{
	document.getElementById('eorstats').className="eorstats";
	document.getElementById('recentcomments').className="recentcommentsactive";
}

function setStatsAsActveTab()
{
	document.getElementById('eorstats').className="eorstatsactive";
	document.getElementById('recentcomments').className="recentcomments";
}

function hideStats()
{
	document.getElementById('right_stats').style.display="none";
}

function showStats()
{
	document.getElementById('right_stats').style.display="";
}

function hideComments()
{
	document.getElementById('right_comments').style.display="none";
}

function showComments()
{
	document.getElementById('right_comments').style.display="";
}

function getS()
{
	return document.getElementById('s').innerHTML;
}

function setS(newS)
{
	document.getElementById('s').innerHTML=newS;
}

function getDID()
{
	return document.getElementById('did').innerHTML;
}

function setDID(newdid)
{
	document.getElementById('did').innerHTML=newdid;
}	

function getIC()
{
	return document.getElementById('ic').innerHTML;
}

function setIC(newic)
{
	document.getElementById('ic').innerHTML=newic;
}	

function qri2(id,ic,s,r)
{
    document.getElementById('oneto5stars'+id).innerHTML="<img src='http://www.exoticsonroad.com/img/loadingbar.gif' width=96 height=12 border=0 alt='Please wait..'>";
    x_rate(id,ic,s,r,rated);
}

function qri(id,ic,s,r)
{
	//if(!ratingactive)
	{
		ratingactive=true;
		document.getElementById('span_ratingimg'+id).innerHTML="<img src='http://www.exoticsonroad.com/img/loadingbar.gif' width=96 height=12 border=0 alt='Please wait..'>";
		x_rate(id,ic,s,r,rated);
	}
	//else
	{
		//alert("Please wait until your previuos rating has been processed.");
	}
}

function rated(result)
{
	id=result[0];
	nr=result[1];

	document.getElementById('span_ratingimg'+id).innerHTML="Thanks for your vote!";

	if(nr>=0 && nr<=5) setTimeout("setNewRating('"+id+"','"+nr+"')",2000);
	ratingactive=false;
}

function setNewRating(id,r)
{
	try { document.getElementById('span_ratingimg'+id).innerHTML="New avg: <img src='http://www.exoticsonroad.com/img/stars/"+r+".gif' alt='"+r+" stars'>"; } catch(e) { }
}

function sri2(id,cid)
{
	try { document.getElementById('oneto5stars'+id).className='oneto5stars'+cid; } catch(e) { }
}

function sri(c,i)
{
	try { document.getElementById('img_rating_'+c).src="img/stars/"+i+".gif"; } catch(e) { }
}

function smy(y,m,ym)
{
	for(i=1;i<=12;i++) for(j=2006;j<=2008;j++)
	{
		try
		{
			document.getElementById('calendar_'+j+i).style.display="none";	
			document.getElementById('paging_'+j+i).style.display="none";			
		}
		catch(e){}
	}
	
	try
	{
		document.getElementById('calendar_'+y+m).style.display="";
		document.getElementById('paging_'+y+m).style.display="";
	}
	catch(e)
	{
		document.getElementById('calendar_'+ym).style.display="";
		document.getElementById('paging_'+ym).style.display="";
	}
}

function showMore(i)
{
	document.getElementById('span_more'+i+'a').style.display="block";
	document.getElementById('span_more'+i+'b').style.display="none";
}

function hidePagingBlock()
{
	document.getElementById('pagingblock').style.display="none";
}

function showPagingBlock()
{
	document.getElementById('pagingblock').style.display="block";
}

function isIE()
{
	CSAct = new Object; 
	CSAg = window.navigator.userAgent; 
	return CSAg.indexOf("MSIE")>0;
}

function isFF()
{
	CSAct = new Object; 
	CSAg = window.navigator.userAgent; 
	return (CSAg.indexOf("Firefox")>0 || CSAg.indexOf("Mozilla")>0);
}

function writeIECss()
{
	document.write("<style>#file_tabs ul{padding-left:200px;margin-top:5px;}</style>");
	document.write("<style>#picalphaoverlay{display:none;}</style>");
	document.write("<style>#zoomthumbnail{margin-left:0px;}</style>");
}

function writeFFCss()
{
	document.write("<style>#file_tabs ul{padding-left:290px;}</style>");
}

function setActivetab(collection)
{
	document.getElementById('tabmodern').className="modern";
	document.getElementById('tabclassic').className="classic";
	document.getElementById('tabvideo').className="video";
	
	document.getElementById('tmodern').style.display="none";
	document.getElementById('tvideo').style.display="none";
	document.getElementById('tclassic').style.display="none";
	
	if(collection=="modern")
	{
		document.getElementById('tabmodern').className="modernactive";
		x_get('recentthumbs/modern_recentthumbs0.htm','div_thumbrow_modern');
		document.getElementById('tmodern').style.display="block";
	}
	
	if(collection=="classic")
	{
		document.getElementById('tabclassic').className="classicactive";
		x_get('recentthumbs/modern_recentthumbs_classic0.htm','div_thumbrow_classic');
		document.getElementById('tclassic').style.display="block";
	}
	
	if(collection=="video")
	{
		document.getElementById('tabvideo').className="videoactive";
		x_get('recentthumbs/modern_recentthumbs_video0.htm','div_thumbrow_video');
		document.getElementById('tvideo').style.display="block";
	}
}

function showNextThumbRow(collection)
{
	if(collection=="modern")
	{
		thumbrow_modern++;
		if(thumbrow_modern>20)  thumbrow_modern=0;
		x_get('recentthumbs/modern_recentthumbs'+thumbrow_modern+'.htm','div_thumbrow_'+collection);
	}
	else
	{
		if(collection=="classic")
		{
			thumbrow_classic++;
			if(thumbrow_classic>20)  thumbrow_classic=0;
			x_get('recentthumbs/modern_recentthumbs_classic'+thumbrow_classic+'.htm','div_thumbrow_'+collection);
		}
		else
		{
			if(collection=="video")
			{
				thumbrow_video++;
				if(thumbrow_video>20)  thumbrow_video=0;
				x_get('recentthumbs/modern_recentthumbs_video'+thumbrow_video+'.htm','div_thumbrow_'+collection);
			}
			else
			{
				thumbrow_submitter++;
				if(thumbrow_submitter>20)  thumbrow_submitter=0;
				x_get('recentthumbs/modern_recentthumbs_'+collection+thumbrow_submitter+'.htm','div_thumbrow_'+collection);
			}
		}
	}
}

function setTitle(s)
{
	if(s=="") s="Welcome to EOR";
	document.getElementById('divtitle').innerHTML=s;
}

function reSetTitle(s)
{
	document.getElementById('divtitle').innerHTML="Welcome to EOR";
}

function downlightPictures(collection)
{
	for(i=0;i<50;i++)
	{
		try
		{
			document.getElementById('thumbpage_picture_'+i).className='location_'+collection+'new';
		}
		catch(e) {}
	}
}

function highlightPicture(id,collection)
{
	downlightPictures(collection);
	document.getElementById(id).className='location_'+collection+'new_highlighted';
}

function hideCommentDivs()
{
	for(i=0;i<6;i++)
	{
		try
		{
			document.getElementById('div_comment_'+i).style.display="none";
		}
		catch(e) {}
	}
}

function showCommentsDiv(id)
{
	hideCommentDivs();
	document.getElementById(id).style.display="block";
}

function setStartpageToolTip(car,model,count,submitter,type,img)
{
	document.getElementById('main_tooltip_car').innerHTML=car;
	document.getElementById('main_tooltip_model').innerHTML=model;
	document.getElementById('main_tooltip_count').innerHTML=count;
	document.getElementById('main_tooltip_submitter').innerHTML=submitter;
	document.getElementById('main_tooltip_type').innerHTML=type;
	document.getElementById('main_tooltip_img').innerHTML=img;
}

function setToolTipMap(color,m_country_map,m_country_title,m_state_map,m_state_title)
{
	worldmap="";
	statemap="";
	
	m_country_map=m_country_map.toLowerCase();
	m_state_map=m_state_map.toLowerCase();
	
	if(m_country_map!="" && m_country_title!="")
	{
		worldmap=
		"<table border=0 cellpadding=0 cellspacing=0 style='border:1px "+color+" solid;'>"+
		"  <tr>"+
		"    <td bgcolor='"+color+"' height=22><font color='#FFFFFF'><b>"+m_country_title+"</b></font></td>"+
		"  </tr>"+
		"  <tr>"+
		"    <td bgcolor='#FFFFFF'><img src='maps/world/"+m_country_map+".gif' alt='maps/world/"+m_country_map+".gif'></td>"+
		"  </tr>"+
		"</table>";
	}
	
	if(m_state_map!="" && m_state_title!="")
	{
		statemap=
		"<table border=0 cellpadding=0 cellspacing=0 style='border:1px "+color+" solid;'>"+
		"  <tr>"+
		"    <td bgcolor='"+color+"' height=22><font color='#FFFFFF'><b>"+m_state_title+"</b></font></td>"+
		"  </tr>"+
		"  <tr>"+
		"    <td bgcolor='#FFFFFF'><img src='maps/"+m_country_map+"/"+m_state_map+".gif' alt='maps/world/"+m_country_map+".gif'></td>"+
		"  </tr>"+
		"</table>";
	}
	
	if(worldmap!="")
	{
		document.getElementById('maps').innerHTML=
		"<table>"+
		"  <tr>"+
		"    <td colspan=2 bgcolor='"+color+"'>"+
		"      <font color='#FFFFFF'>This car is registered in</font>"+
		"    </td>"+
		"  </tr>"+
		"  <tr>"+
		"    <td>"+worldmap+"</td>"+
		"    <td>"+statemap+"</td>"+
		"  </tr>"+
		"</table>";
	}
	else
	{
		document.getElementById('maps').innerHTML="";
	}
}

function expandMarke(input,forcecollaps)
{
	section=document.getElementById(input);
	if(section.style.display=='none' && !forcecollaps)
	{
		section.style.display='block';
		document.getElementById("img"+input+"p").style.display="none";
		document.getElementById("img"+input+"m").style.display="";
	}
	else
	{
		section.style.display='none';
		document.getElementById("img"+input+"p").style.display="";
		document.getElementById("img"+input+"m").style.display="none";
	}
}

function switchSection(input)
{
	expandMarke(input);
}

function updateToolTip(e) 	
{	
	x=(document.all)?window.event.x+document.body.scrollLeft:e.pageX;	
	y=(document.all)?window.event.y+document.body.scrollTop:e.pageY;
	
	if(WMTT!=null) 	
	{			
		var WMTTID = WMTT.id;	
		
		if(positionX=='bigpic')
		{
			WMTT.style.left=(x+10)+"px";	
			WMTT.style.top=(y+10)+"px";
		}
		else
		{
			oben=-100;
	
			if(positionX=="right")	
			{
				links=500;	 // -500
			}
			else
			{
				if(positionX=="middle")	
				{
					links=300;	 //  -300
				}	
				else	
				{
					links=-300;	 // -300
				}	
			}
			
			WMTT.style.left=(x-230)+"px";	
			WMTT.style.top=(y-100)+"px";
		}
	}
}

function showToolTip(id,inputpositionX,inputpositionY) 
{
	positionX=inputpositionX;
	positionY=inputpositionY;
	updateToolTip;
	WMTT=document.getElementById(id);
	WMTT.style.display="block";
}

function stt(id,inputpositionX,inputpositionY) 
{
	positionX=inputpositionX;
	positionY=inputpositionY;
	updateToolTip;
	WMTT=document.getElementById(id);
	WMTT.style.display="block";
}

function hideToolTip() 
{
	if(WMTT!=null)WMTT.style.display="none";
}

function htt() 
{
	if(WMTT!=null)WMTT.style.display="none";
}

function showMoreComments(start)
{
	x_getMoreComments(start,setMoreComments);
}

function setMoreComments(result)
{
	document.getElementById('right_comments').innerHTML=result;
}