function checkSize()
{
	if($(window).width() <= 1069)
	{
		var hw = ( $(window).width() / 2 ) - ( $('#headerContainer').width() / 2 );
		$('#headerContainer').css(
		{
			'position': 'relative',
			'left': hw+'px'
		});
	} else {
		$('#headerContainer').css(
		{
			'position': '',
			'left': ''
		});
	}
	if($(window).width() <= 1024)
	{
		var mw = ( $(window).width() / 2 ) - ( $('#mainContainer').width() / 2 );
		$('#mainContainer').css(
		{
			'position': 'relative',
			'left': mw+'px'
		});
	} else {
		$('#mainContainer').css(
		{
			'position': '',
			'left': ''
		});
	}
}

$(document).ready(function()
{
	checkSize();

	$('#vehicleSpecials .featuredVehicle').each(function(i, elem)
	{
		if(i == 0 || i == 1)
			$(this).css('margin-top', '0px');
		
		if(i % 2 == 0)
		{
			$(this).css('float', 'left');
		}
		else
		{
			$(this).css('float', 'right');
			$('<br class="clear" />').insertAfter(this);
		}
		
	});

	var le = $('#vehicleSpecials').children().last();
	if($(le).css('float') == 'left')
		$('#vehicleSpecials').append('<br class="clear" />');
});

$(window).resize(function()
{
	checkSize();
});

// Application Buttons //
var ENG;
//Service & Body Shop
var imgOnAppointment = new Image(253,48);
imgOnAppointment.src = '/images/image.php?file=buttons/ENG/appointment2.gif';
var imgOffAppointment = new Image(253,48);
imgOffAppointment.src = '/images/image.php?file=buttons/ENG/appointment1.gif';

// MORE INFO BUTTON
var imgOnInfo = new Image(253,48);
imgOnInfo.src = '/images/image.php?file=buttons/ENG/more_info2.gif';
var imgOffInfo = new Image(253,48);
imgOffInfo.src = '/images/image.php?file=buttons/ENG/more_info1.gif';

//Parts
var imgOnPartsRequest = new Image(253,48);
imgOnPartsRequest.src = '/images/image.php?file=buttons/ENG/parts_request2.gif';
var imgOffPartsRequest = new Image(253,48);
imgOffPartsRequest.src = '/images/image.php?file=buttons/ENG/parts_request1.gif';

//Finance
var imgOnCreditApp = new Image(253,48);
imgOnCreditApp.src = '/images/image.php?file=buttons/ENG/credit_app2.gif';
var imgOffCreditApp = new Image(253,48);
imgOffCreditApp.src = '/images/image.php?file=buttons/ENG/credit_app1.gif';

function showStatus(sMsg) {//used often
	//setTimeout("window.status = \'" + sMsg + "\';", 0);
    window.status = sMsg ;
    return true ;
}
function openWindow(url,width,height){
	newWin = window.open(url, 'viewWin', 'toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,left='+(screen.width-width)/2+',top='+(screen.height-height)/2+',width=' + width + ',height=' + height + '');
}		

function changeImg(imgName,imgPre) {
	if(document.images){
		document.images[imgName].src = eval(imgPre + '.src');
	}
}

function changeStyle(obj, new_style) {
    obj.className = new_style;
}
