var msg="MNS Auto | Quebec, Montreal | Sell Used Cars";

function ScrollTitle() {
    document.title=msg;
}
ScrollTitle();

function popUp(URL) {

	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=635,height=600');");
}

function popUp2(URL) {

	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=845,height=638');");
}

function popUp3(URL) {

	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300');");
}

var winheight=100
var winsize=100
var x=5

function openwindow(thelocation){

	temploc=thelocation

	if (!(window.resizeTo&&document.all)&&!(window.resizeTo&&document.getElementById)){

		window.open(thelocation)
		return
	}

	win2=window.open("","","scrollbars")
	win2.moveTo(0,0)
	win2.resizeTo(100,100)
	go2()
}

function go2(){

	if (winheight>=screen.availHeight-3)
		x=0
		win2.resizeBy(5,x)
		winheight+=5
		winsize+=5

		if (winsize>=screen.width-5){
			win2.location=temploc
			winheight=100
			winsize=100
			x=5
			return
		}

	setTimeout("go2()",50)
}

var browserOK = false;
var pics;
browserOK = true;
pics = new Array();
var objCount = 0;

function preload(name, first, second) {  

  if (browserOK) {     

    pics[objCount] = new Array(3);
    pics[objCount][0] = new Image();
    pics[objCount][0].src = first;
    pics[objCount][1] = new Image();
    pics[objCount][1].src = second;
    pics[objCount][2] = name;
    objCount++;
  }
}



function on(name){

  if (browserOK) {
     for (i = 0; i < objCount; i++) {
      if (document.images[pics[i][2]] != null)
        if (name != pics[i][2]) { 
          document.images[pics[i][2]].src = pics[i][0].src;

        } else {
           document.images[pics[i][2]].src = pics[i][1].src;
        }
    }
  }
}



function off(){

  if (browserOK) {
     for (i = 0; i < objCount; i++) {
      if (document.images[pics[i][2]] != null) 
        document.images[pics[i][2]].src = pics[i][0].src;
    }
  }
}

preload("index", "../ei/butsmall6.gif", "../ei/butbig6.gif")
preload("about", "../ei/butsmall.gif", "../ei/butbig.gif");
preload("achat", "../ei/butsmall2.gif", "../ei/butbig2.gif");
preload("leasing", "../ei/butsmall3.gif", "../ei/butbig3.gif");
preload("service", "../ei/butsmall4.gif", "../ei/butbig4.gif");
preload("contact", "../ei/butsmall5.gif", "../ei/butbig5.gif");
preload("financing", "../ei/butsmall7.gif", "../ei/butbig7.gif");
preload("francais", "../ei/butsmallfra.gif", "../ei/butbigfra.gif");
preload("home", "../ui/toplogo1.gif", "../ui/toplogo2.gif");

function statbar(txt) {

   window.status = txt;
}

function formHandler(form){

	var URL = document.form.site.options[document.form.site.selectedIndex].value;
	window.location.href = URL;
}

var interval = 2.5; // delay between rotating images (in seconds)
var random_display = 1; // 0 = no, 1 = yes
interval *= 1000;
var image_index = 0;

image_list = new Array();

image_list[image_index++] = new imageItem("../ui/car-1.jpg");
image_list[image_index++] = new imageItem("../ui/car-7.jpg");
image_list[image_index++] = new imageItem("../ui/car-3.jpg");
image_list[image_index++] = new imageItem("../ui/car-4.jpg");
image_list[image_index++] = new imageItem("../ui/car-5.jpg");
image_list[image_index++] = new imageItem("../ui/car-6.jpg");
image_list[image_index++] = new imageItem("../ui/car-2.jpg");

var number_of_image = image_list.length;

function imageItem(image_location) {

	this.image_item = new Image();
	this.image_item.src = image_location;
}

function get_ImageItemLocation(imageObj) {

	return(imageObj.image_item.src)
}

function generate(x, y) {

	var range = y - x + 1;
	return Math.floor(Math.random() * range) + x;
}

function getNextImage() {

	if (random_display) {
	image_index = generate(0, number_of_image-1);
	}else {
	image_index = (image_index+1) % number_of_image;
	}

	var new_image = get_ImageItemLocation(image_list[image_index]);
	return(new_image);
}

function rotateImage(place) {

	var new_image = getNextImage();
	document[place].src = new_image;
	var recur_call = "rotateImage('"+place+"')";
	setTimeout(recur_call, interval);
}

function loadDate()
{
   var theday=new Date();
   //var weekday=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
   var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
   
  
   document.write("<span class='datetxt'>");
   document.write(monthname[theday.getMonth()] + " ");
   document.write(theday.getDate() + ", ");
   document.write(theday.getFullYear()+"</span>");
}

var tempId = '0';
function showBiggerPic(id){
  if(id != tempId){
    document.getElementById('showBiggerPic_' + id).style.display = 'block';
    closeBiggerPic();
  }
  tempId = id;
}

function closeBiggerPic(){
  document.getElementById('showBiggerPic_' + tempId).style.display = 'none';
  tempId = '0';
  return false;
}