// JavaScript Document
function cngBtn (){
	document.getElementById("btn").value = "Save";	
}


function init() {
	//scrollablediv 2
	var scroller2 = new Bs_ScrollableDiv();
	scroller2.init('divContainer_2', 'divContent_2');
	
	var sliderObj2 = new Bs_Slider();
	
	sliderObj2.attachOnChange(Bs_ScrollableDiv_sliderChange);
	sliderObj2.width          = 11;
	sliderObj2.height         = 'auto';
	sliderObj2.arrowMouseOver = true;
	sliderObj2.valueDefault   =0; //we don't start at position 0 by default. this is in percent.
	sliderObj2.direction      = 1;
	sliderObj2.imgDir         = 'js/images/';
	//sliderObj2.setBackgroundImage('scroll_ln.gif', 'repeat');
	sliderObj2.setSliderIcon('scroll_knob.gif', 11, 5);
	sliderObj2.setArrowIconLeft('scroll_up.gif', 11, 10);
	sliderObj2.setArrowIconRight('scroll_dn.gif', 11, 10);
	sliderObj2.useInputField = 0;
	
	scroller2.setSliderObject(sliderObj2, 'sliderDiv2');
	scroller2.setSlideSpeed(50, 'pixel'); //50 pixel per second
	scroller2.setWheelSpeed(5, 'pixel'); //20 pixel per tick
}

var nn = 1;

function validateForm()
{
	if(document.login_form.username.value == "")
	{
		alert("Please enter in your User ID.");

		document.login_form.form_submitted.value = "not_submitted";

		return false;
	}
	else if(document.login_form.password.value == "")
	{
		alert("Please enter in your password.");

		document.login_form.form_submitted.value = "not_submitted";

		return false;
	}
	document.login_form.form_submitted.value = "submitted";

	return true;
}

function main_content(con)
{
	switch (con) {
		case 1:
		{ document.getElementById("test").innerHTML = "<p class=\"head\">Body Repairs</p><p class=\"content\">Once again the standards set by Autologic are renowned with the philosophy of \"if you cannot do it well do not do it at all\".<br><br>Sheet metal work of the highest order is required in order toreconstitute the original appearance of an accident damaged BMW car.<br><br>Body repairs are the greyest areas of all automotive practices with an infinitely variable subjective interpretation of what is required in order to repair a vehicle following an accident.<br><br>Thus a dichotomy exists....  repair to price or repair to quality.<br><br>Autologic is empathetic to ensuring that the costs of body repairs are contained but not at the expense of quality.<br><br>Thus we seek to reinstate a vehicle back to its pre accident state with every effort made to ensure that all evidence of the repair is removed.<br><br>This even extends to careful processes to avoid excessive refinish paint film builds.<br><br>We do not rely upon heavy primer builds to correct for inadequate sheet metal work.<br><br>All body repairs are performed with an \"all metal\" philosophy without fillers being relied upon in order to achieve the fast buck.</p>";
		break; }
		case 2:
		{ document.getElementById("test").innerHTML = "<p class=\"head\">Electronic Diagnosis</p><p class=\"content\">Electronic diagnosis is becoming a more important tool for analysis of BMW electronics especially	as the systems gain greater linkage between the various electronic modules with the DME unit at	the heart of the system.<br><br>Notwithstanding this evolution Electronic analysis is not a substitute for skilled technicians and thus should not be relied upon solely to determine any problems a system may have.<br><br>Autologic has the latest electronic fault code download systems available along with a comprehensive document database to assist in the determination of electronic problems.<br><br>In many cases faults observed are the same as faults previously noted and consequently customers benefit from the experience of previous diagnostic events.<br><br>This is a clear benefit of being a BMW only specialist.<br><br>In addition to this given that Autologic works on a much broader base of model types and work is not	limited to todays warranty problems.<br><br>Thus immediate recall of specific model repetitive faults is maintained not forgotten when a new model comes along.<br><br>A number of BMW control units and electronic devices can in fact be repaired rather than replaced and Autologic has an ongoing program of repair and investigation of repair to electronic devices.</p>";
		break; }
		case 3:
		{ document.getElementById("test").innerHTML = "<p class=\"head\">Pre Purchase Inspections</p><p class=\"content\">The broad range of skills we have naturally are well exploited to your benefit at Autologic<br><br>Questions such as<br><br></p><ul class=\"content\"><li>Is the car the most suitable model for me</li><li>If previous damage has occurred should it exclude the car</li><li>If so how was it repaired and to what standard</li><li>What condition is the engine and other mechanical elements</li><li>What will the car be worth in 5 years</li><li>How much will it cost to finance</li><li>What is its current Value</li><li>Where do I seek finance and Insurance</li><li>Which Insurance companies should I avoid</li><li>What will be the cost of maintaining the car in peak condition</li><li>What level of maintenance is suitable for me</li><li>What do I need to be aware of with any particular model</li><li>Can I actively be involved and participate in the inspection</li></ul><p class=\"content\">These questions and more are answered when you have a pre purchase inspection at Autologic<br><br>All faults and attributes are listed out prioritized and any fault rectification cost calculated<br><br>Thus a pre purchase inspection at Autologic is such that our customers have the most complete snapshot of their potential vehicle and the informed basis on which to make a proper decision of what to buy how much to pay and how long to keep a vehicle<br><br>In addition we are also pleased to offer the optional paint film build analysis<br><br>This is the best way to determine any repainting or overcoating which has occurred and also allows us to determine the extent of fillers used in the repair of your prospective car<br><br>Given that we can now measure your paint film build in microns means that our pre purchase inspections are now more accurate than ever<br><br>It can be very revealing</p>";
		break; }
	}
}

var img = 1;

function changeDivImage(tt)
{
	var imgPath = new String();

	img = tt;
	
	switch(tt) {
		case 1: 
		imgPath = "url(images/1a.jpg)";
		document.getElementById("imgSel").innerHTML = "<li><a href=\"javascript:changeDivImage(1)\" class=\"iSA\"></a></li><li><a href=\"javascript:changeDivImage(2)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(3)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(4)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(5)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(6)\" class=\"iS\"></a></li>";
		break;
		case 2: 
		imgPath = "url(images/2a.jpg)";
		document.getElementById("imgSel").innerHTML = "<li><a href=\"javascript:changeDivImage(1)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(2)\" class=\"iSA\"></a></li><li><a href=\"javascript:changeDivImage(3)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(4)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(5)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(6)\" class=\"iS\"></a></li>";
		break;
		case 3: 
		imgPath = "url(images/3a.jpg)";
		document.getElementById("imgSel").innerHTML = "<li><a href=\"javascript:changeDivImage(1)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(2)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(3)\" class=\"iSA\"></a></li><li><a href=\"javascript:changeDivImage(4)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(5)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(6)\" class=\"iS\"></a></li>";
		break;
		case 4: 
		imgPath = "url(images/4a.jpg)";
		document.getElementById("imgSel").innerHTML = "<li><a href=\"javascript:changeDivImage(1)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(2)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(3)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(4)\" class=\"iSA\"></a></li><li><a href=\"javascript:changeDivImage(5)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(6)\" class=\"iS\"></a></li>";
		break;
		case 5: 
		imgPath = "url(images/5a.jpg)";
		document.getElementById("imgSel").innerHTML = "<li><a href=\"javascript:changeDivImage(1)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(2)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(3)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(4)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(5)\" class=\"iSA\"></a></li><li><a href=\"javascript:changeDivImage(6)\" class=\"iS\"></a></li>";
		break;
		case 6: 
		imgPath = "url(images/6a.jpg)";
		document.getElementById("imgSel").innerHTML = "<li><a href=\"javascript:changeDivImage(1)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(2)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(3)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(4)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(5)\" class=\"iS\"></a></li><li><a href=\"javascript:changeDivImage(6)\" class=\"iSA\"></a></li>";
		break;
	}
	
	if(imgPath != "")
	{
		document.getElementById("mainphoto").style.backgroundImage = imgPath;
	}
}

function ReplaceContentInContainer(id,content) 
{
	var container = document.getElementById(id);
	container.innerHTML = content;
	if(content == 1)
	{
		container.innerHTML = '<p><h2>Contact Us</h2></p><iframe width="425" height="240" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com.au/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Autologic+Pty+Ltd++++++10+Ardena+Court++++++East+Bentleigh+++++3165++++++Australia&amp;sll=-37.916403,145.058627&amp;sspn=0.00303,0.006968&amp;gl=au&amp;ie=UTF8&amp;hq=Autologic+Pty+Ltd&amp;hnear=10+Ardena+Ct,+Bentleigh+East+Victoria+3165&amp;ll=-37.915628,145.060344&amp;spn=0.008126,0.018239&amp;z=15&amp;output=embed"></iframe>';
	}
	else if(content == 2)
	{
		container.innerHTML = '<p><h2>Contact Us</h2></p><iframe width="425" height="240" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com.au/maps?oe=utf-8&amp;client=firefox-a&amp;ie=UTF8&amp;q=Autologic+Pty+Ltd++++++10+Ardena+Court++++++East+Bentleigh+++++3165++++++Australia&amp;fb=1&amp;gl=au&amp;hq=Autologic+Pty+Ltd&amp;hnear=10+Ardena+Ct,+Bentleigh+East+VIC+3165&amp;cid=0,0,3254241913546131279&amp;ei=kicoTMaNKY_JccfnxM4C&amp;ved=0CBUQnwIwAA&amp;layer=c&amp;cbll=-37.916402,145.058627&amp;panoid=fukqS0KW9uW2-2fZk7klng&amp;cbp=13,204.8,,0,5.07&amp;ll=-37.91639,145.05852&amp;spn=0,0.012059&amp;z=16&amp;source=embed&amp;output=svembed"></iframe>';
	}
}

var secs;
var timerID = null;
var timerRunning = false;
var delay = 1000;
var delay2 = 1000;

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 7;
    StopTheClock();
    StartTheTimer();
}

function StopTheClock()
{
    if(timerRunning)
    clearTimeout(timerID);
    timerRunning = false;
}

function StartTheTimer()
{
	if (secs==0)
{
		StopTheClock();
		switch(img) {
		case 1:
		fade('mainphoto');
	  	var t2 = setTimeout("changeDivImage(2)", delay2);
		img = 2;
		break;
		case 2:
		fade('mainphoto');
		var t2 = setTimeout("changeDivImage(3)", delay2);
		img = 3;
		break;
		case 3:
		fade('mainphoto');
		var t2 = setTimeout("changeDivImage(4)", delay2);
		img = 4;
		break;
		case 4:
		fade('mainphoto');
		var t2 = setTimeout("changeDivImage(5)", delay2);
		img = 5;
		break;
		case 5:
		fade('mainphoto');
		var t2 = setTimeout("changeDivImage(6)", delay2);
		img = 6;
		break;
		case 6:
		fade('mainphoto');
		var t2 = setTimeout("changeDivImage(1)", delay2);
		img = 1;
		break;
		}
		var n2 = setTimeout("fade('mainphoto')", 2000);
		InitializeTimer();
	}
    else
    {
        self.status = secs;
        secs = secs - 1;
        timerRunning = true;
        timerID = self.setTimeout("StartTheTimer()", delay);
    }
}

var TimeToFade = 1000.0;
var TimeToFade2 = 2000.0;

function fade(eid)
{
  var element = document.getElementById(eid);
  if(element == null)
    return;
   
  if(element.FadeState == null)
  {
    if(element.style.opacity == null
        || element.style.opacity == ''
        || element.style.opacity == '1')
    {
      element.FadeState = 2;
    }
    else
    {
      element.FadeState = -2;
    }
  }
   
  if(element.FadeState == 1 || element.FadeState == -1)
  {
    element.FadeState = element.FadeState == 1 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
  }
  else
  {
    element.FadeState = element.FadeState == 2 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade;
    setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
  }  
}

function animateFade(lastTick, eid)
{  
  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
 
  var element = document.getElementById(eid);
 
  if(element.FadeTimeLeft <= elapsedTicks)
  {
    element.style.opacity = element.FadeState == 1 ? '1' : '0';
    element.style.filter = 'alpha(opacity = '
        + (element.FadeState == 1 ? '100' : '0') + ')';
    element.FadeState = element.FadeState == 1 ? 2 : -2;
    return;
  }
 
  element.FadeTimeLeft -= elapsedTicks;
  var newOpVal = element.FadeTimeLeft/TimeToFade;
  if(element.FadeState == 1)
    newOpVal = 1 - newOpVal;

  element.style.opacity = newOpVal;
  element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
 
  setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
}

function fadein(eid)
{
  fade('mainphoto');
  var t5 = setTimeout("changeDivImage(1)", 1000);
  var t6 = setTimeout("fade('mainphoto')", 1000);
}
