var bgname;
var idname;

hrname=new Array();
hrname[0]=new Image;
hrname[0]="Home.html";
hrname[1]=new Image;
hrname[1]="Who.html";
hrname[2]=new Image;
hrname[2]="Press.html";
hrname[3]=new Image;
hrname[3]="Kits.html";
hrname[4]=new Image;
hrname[4]="ContactUs.html";
hrname[5]=new Image;
hrname[5]="WallOfShame/WallOfShame.html";
hrname[6]=new Image;
hrname[6]="About.html";
hrname[7]=new Image;
hrname[7]="BossesWords.html";
hrname[8]=new Image;
hrname[8]="911Home.html";
hrname[9]=new Image;
hrname[9]="Videos.html";
hrname[10]=new Image;
hrname[10]="911/LS-1.html";
hrname[11]=new Image;
hrname[11]="Video01.html";
hrname[12]=new Image;
hrname[12]="911/911.html";
hrname[13]=new Image;
hrname[13]="Video02.html";
hrname[14]=new Image;
hrname[14]="911/Customers.html";
hrname[15]=new Image;
hrname[15]="Video03.html";
hrname[16]=new Image;
hrname[16]="914Home.html";
hrname[17]=new Image;
hrname[17]="Video04.html";
hrname[18]=new Image;
hrname[18]="914/LS/LS-Series.html";
hrname[19]=new Image;
hrname[19]="Video05.html";
hrname[20]=new Image;
hrname[20]="914/SBC/SBC.html";
hrname[21]=new Image;
hrname[21]="Video06.html";
hrname[22]=new Image;
hrname[22]="914/Subie/Subie.html";
hrname[23]=new Image;
hrname[23]="Video07.html";
hrname[24]=new Image;
hrname[24]="914/Customers.html";
hrname[25]=new Image;
hrname[25]="Video08.html";
hrname[26]=new Image;
hrname[26]="928Home.html";
hrname[27]=new Image;
hrname[27]="Video09.html";
hrname[28]=new Image;
hrname[28]="928/LS/LS.html";
hrname[29]=new Image;
hrname[29]="Video10.html";
hrname[30]=new Image;
hrname[30]="928/928.html";
hrname[31]=new Image;
hrname[31]="Testimonials/Testimonials.html";
hrname[32]=new Image;
hrname[32]="928/Customers.html";
hrname[33]=new Image;
hrname[33]="ForSale/CarsForSale.html";
hrname[34]=new Image;
hrname[34]="944Home.html";
hrname[35]=new Image;
hrname[35]="ForSale/PartsForSale.html";
hrname[36]=new Image;
hrname[36]="944/LS-1/LS-1.html";
hrname[37]=new Image;
hrname[37]="AboutUs/ShopTour.html";
hrname[38]=new Image;
hrname[38]="944/Customers.html";
hrname[39]=new Image;
hrname[39]="Video09.html";
hrname[40]=new Image;
hrname[40]="911/LS-1-996.html";

function MouseI(idname,idx) {
	bgname=document.getElementById(idname).background;
	document.getElementById(idname).background ="Graphics/button2.jpg";
        document.getElementById(idname).href=hrname[idx];
}

function MouseO(idname) {
	document.getElementById(idname).background=bgname;
}

function MouseIB(idname) {
	document.getElementById(idname).src="Graphics/arrowb2.jpg";
}

function MouseIP(idname) {
	document.getElementById(idname).src="Graphics/pause2.jpg";
}

function MouseIR(idname) {
	document.getElementById(idname).src="Graphics/resume2.jpg";
}

function MouseIN(idname) {
	document.getElementById(idname).src="Graphics/arrown2.jpg";
}

function MouseOB(idname) {
	document.getElementById(idname).src="Graphics/arrowb1.jpg";
}

function MouseOP(idname) {
	document.getElementById(idname).src="Graphics/pause1.jpg";
}

function MouseOR(idname) {
	document.getElementById(idname).src="Graphics/resume1.jpg";
}

function MouseON(idname) {
	document.getElementById(idname).src="Graphics/arrown1.jpg";
}

function Clickit(idx) {
	document.getElementById("mainframe").src=hrname[idx];
}

function hideit() {
   document.getElementById('boxObject').style.visibility = 'hidden';
}

function visible() {
   document.getElementById('boxObject').style.visibility = 'visible';
}

function callafter() {
  int1=setTimeout(visible,2000); // Show transparent message after 2 seconds.
}

function loadhome() {
	document.getElementById("mainframe").src='Home.html';
}

function startslides() {
  int1=setTimeout(loadhome,4000); // Show transparent message after 4 seconds.
}

function getimg(current, next) {
   hideit(); // Hide transparent message after 2 seconds.
   document.getElementById('tagline1').innerHTML=$(next).attr('title');
   if (document.getElementById('tagline1').innerHTML=="914") {
       document.getElementById('tagline1').innerHTML="<h5><i>914 Small Block Chevy Conversions</i></h5>";
       document.getElementById('tagline1').href="914/SBC/SBC.html";
       document.getElementById('tagline2').innerHTML=
       "<h7><i>For 25 years, Renegade Hybrids has offered Small Block Chevy conversion kits for many Porsches.</i></h7>";
       document.getElementById('tagline2').href="914/SBC/SBC.html";
   }
   if (document.getElementById('tagline1').innerHTML=="944") {
       document.getElementById('tagline1').innerHTML="<h5><i>944 All Aluminum LS Series V8 Conversions</i></h5>";
       document.getElementById('tagline1').href="944/LS-1/LS-1.html";
       document.getElementById('tagline2').innerHTML=
       "<h7><i>Over 12 years ago, the 924S, 944, 951 and 968 models were also fitted with a GM performance boost.</i></h7>";
       document.getElementById('tagline2').href="944/LS-1/LS-1.html";
   }
   if (document.getElementById('tagline1').innerHTML=="928") {
       document.getElementById('tagline1').innerHTML="<i>928 LS V-8 Automatic and Five Speed Conversions</i>";
       document.getElementById('tagline1').href="928/LS/LS.html";
       document.getElementById('tagline2').innerHTML=
       "<h7><i>15 years ago, Renegade introduced the \"German Corvette\" to some \"American Muscle\".</i></h7>";
       document.getElementById('tagline2').href="928/LS/LS.html";
   }
   if (document.getElementById('tagline1').innerHTML=="930") {
       document.getElementById('tagline1').innerHTML="<i>930 Conversions<br></i>";
       document.getElementById('tagline1').href="911/911.html";
       document.getElementById('tagline2').innerHTML=
       "<h7><i>Renegade Hybrids has been in the German car engine conversion industry for over 25 years.</i></h7>";
       document.getElementById('tagline2').href="911/911.html";
   }
   if (document.getElementById('tagline1').innerHTML=="911") {
       document.getElementById('tagline1').innerHTML="<h5><i>911 Conversions</i></h5>";
       document.getElementById('tagline1').href="911/911.html";
       document.getElementById('tagline2').innerHTML=
       "<h7><i>Today, renegade provides the most complete, reliable and powerful engine conversions available.</i></h7>";
       document.getElementById('tagline2').href="911/911.html";
   }
}

function slidefade() {
   $('.slides').cycle({
      fx: 'fade'
   });
}

function slideshuf() {
   $('.slides').cycle({
      fx: 'suffle'
   });
}

function slidego(action) {
   $('.slides').cycle(action);
   $('.slides').cycle('resume');
}

function slidenext() {
   $('.slides').cycle('next');
   $('.slides').cycle({
      prev: false,
      next: true
   });
   $('.slides').cycle('resume');
}

function slideprev() {
   $('.slides').cycle('pause');
   $('.slides').cycle({
      prev: true,
      next: false
   });
   $('.slides').cycle('resume');
}

function slidecontrol(action) {
   $('.slides').cycle(action);
}

$(document).ready(function() {

	//this is the useful function to scroll a text inside an element...

	function startScrolling(scroller_obj, velocity, start_from){
		//bind animation to the children inside the scroller element
		scroller_obj.children().bind('marquee', function(event,c) {
			//text to scroll
			var ob = $(this);
			//scroller width
			var sw = parseInt(ob.parent().width());
			//text width
			var tw = parseInt(ob.width());
			//text left position relative to the offset parent
			var tl = parseInt(ob.position().left);
			//velocity converted to calculate duration
			var v  = velocity>0 && velocity<100 ? (100-velocity)*100 : 5000;
			//same velocity for different text's length in relation with duration
			var dr = (v*tw/sw)+v;
			//is it scrolling from right or left?
			switch(start_from){
			case 'right':
				//is it the first time?
				if(typeof c == 'undefined'){
					//if yes, start from the absolute right
					ob.css({ left: sw });
					sw = -tw;
				}else{
					//else calculate destination position
					sw = tl - (tw + sw);
				};
				break;
			default:
				if(typeof c == 'undefined'){
					//start from the absolute left
					ob.css({ left: -tw });
				}else{
					//else calculate destination position
					sw += tl + tw;
				};
			}
			//attach animation to scroller element and start it by a trigger
			ob.animate(	{left:sw},
						{	duration:dr,
							easing:'linear',
							complete:function(){ob.trigger('marquee');},
							step:function(){
								//check if scroller limits are reached
								if(start_from == 'right'){
									if(parseInt(ob.position().left) < -parseInt(ob.width())){
										//we need to stop and restart animation
										ob.stop();
										ob.trigger('marquee');
									};
								}else{
									if(parseInt(ob.position().left) > parseInt(ob.parent().width())){
										ob.stop();
										ob.trigger('marquee');
									};
								};
							}
						});
		}).trigger('marquee');
		//pause scrolling animation on mouse over
		scroller_obj.mouseover(function(){
			$(this).children().stop();
		});
		//resume scrolling animation on mouse out
		scroller_obj.mouseout(function(){
			$(this).children().trigger('marquee',['resume']);
		});
	};

	//the main app starts here...

	//change the cursor type for each scroller
	$('.scroller').css("cursor","pointer");

	//settings to pass to function
	var scroller			= $('.scroller');	// element(s) to scroll
	var scrolling_velocity 	= 40; 				// 1-99
	var scrolling_from 		= 'right';			// 'right' or 'left'

	//call the function and start to scroll..
	startScrolling( scroller, scrolling_velocity, scrolling_from );


});

