
function MM_preloadImages() {
	var d = document;
	if(d.images){
		if(!d.MM_p) d.MM_p=new Array();
		var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
		for(i=0; i<a.length; i++){
			if (a[i].indexOf("#")!=0){
				d.MM_p[j]=new Image;
				d.MM_p[j].src=a[i];
				j++;
			}
		}
	}
}

var autosArr = [['daewoo.jpg', 'daewoo1.jpg', 'http://www.avalink.ru/catalogue.php?id=201&lang_id=1&cat_id=2&good_id=5', 'Daewoo Matiz', 'daewoo2.jpg', 'http://www.avalink.ru/catalogue.php?id=201&lang_id=1&cat_id=1&good_id=3', 'Daewoo Nexia'], ['geely.jpg', 'geely_cross.jpg', 'http://www.geely-avalink.ru/index.php?id=34', 'Geely MK Cross', /*'geely2.jpg', '/', 'Geely Otaka',*/ 'geely3.jpg', 'http://www.geely-avalink.ru/index.php?id=33', 'Geely MK'], ['hyundai.jpg', 'hyundai1.jpg', 'http://www.tagaz-avalink.ru/avalink/cars/accent/', 'Hyundai Accent', 'hyundai2.jpg', 'http://www.tagaz-avalink.ru/avalink/cars/elantra/', 'Hyundai Elantra XD', 'hyundai3.jpg', 'http://www.tagaz-avalink.ru/avalink/cars/sonata/', 'Hyundai Sonata', 'hyundai4.jpg', 'http://www.tagaz-avalink.ru/avalink/off-roads/santafe/', 'Hyundai Santa Fe Classic','tagaz4.jpg', 'http://www.tagaz-avalink.ru/avalink/cars/vega/', 'Tagaz Vega C-100', 'hyundai5.jpg', 'http://www.tagaz-avalink.ru/avalink/trucks/porter/', 'Hyundai Porter', 'tagaz1.jpg', 'http://www.tagaz-avalink.ru/avalink/off-roads/tager/', 'Tagaz Tager', 'tagaz2.jpg', 'http://www.tagaz-avalink.ru/avalink/off-roads/22/', 'Tagaz Road Partner', 'tagaz3.jpg', 'http://www.tagaz-avalink.ru/avalink/cars/estina/', 'Tagaz Vortex Estina', 'tagaz5.jpg', 'http://www.tagaz-avalink.ru/avalink/off-roads/tiggo/', 'Cherry Tiggo'], ['zaz.jpg', 'zaz3.jpg', 'http://www.avalink.ru/catalogue.php?id=201&lang_id=1&cat_id=3&good_id=12', 'Chance(Lanos) Sedan 1.3 ','zaz2.jpg','http://www.avalink.ru/catalogue.php?id=201&lang_id=1&cat_id=4&good_id=15', 'Chance(Lanos) Sedan 1.5 ','hb.jpg','http://www.avalink.ru/catalogue.php?id=201&lang_id=1&cat_id=5&good_id=18', 'Chance(Lanos) HB'],['ssangyong.jpg', 'actyon.gif', 'http://www.ssangyong-avalink.ru/ru/pages/index.php?id=24', 'Actyon', 'action_sports.gif', 'http://www.ssangyong-avalink.ru/ru/pages/index.php?id=23', 'Actyon Sports', 'rexton2.jpg', 'http://www.ssangyong-avalink.ru/ru/pages/index.php?id=21', 'Rexton II', 'kyron2.jpg', 'http://www.ssangyong-avalink.ru/ru/pages/index.php?id=305', 'Kyron II', 'rodius.jpg', 'http://www.ssangyong-avalink.ru/ru/pages/index.php?id=19', 'Rodius']];
var logoSmall = ['daewoo_small.jpg', '/form.php?id=208&lang_id=1', '/form.php?id=206&lang_id=1', '/form.php?id=209&lang_id=1', 'geely_small.jpg', 'http://geely-avalink.ru', 'http://geely-avalink.ru','http://geely-avalink.ru', 'hyundai_small.jpg', 'http://www.tagaz-avalink.ru/services/testdrive/', 'http://www.tagaz-avalink.ru/services/credit/', 'http://www.tagaz-avalink.ru/services/parts/', 'zaz_small.jpg', '/form.php?id=208&lang_id=1', '/form.php?id=206&lang_id=1', '/form.php?id=209&lang_id=1', 'ssan_small.jpg', 'http://www.ssangyong-avalink.ru/ru/pages/index.php?id=103','http://www.ssangyong-avalink.ru/ru/pages/index.php?id=10&id2=393','http://www.ssangyong-avalink.ru/ru/pages/index.php?id=7'];

var startAuto = new Array();

function showAutoList()
{
	var countRows = autosArr.length;
	var content = '';
	for(var i = 0; i<countRows; i++){
		startAuto[i] = 0;
		content += '<div class="AutoListItem"><div class="AutoILogo">';
        if(i == 0) {
			if(autosArr[i][0]!='') content += '<a href=\"http://www.avalink.ru/catalogue.php?id=201&lang_id=1\"><img src="/image/' + autosArr[i][0] + '"></a>';
		}
		else if(i == 1) {
			if(autosArr[i][0]!='') content += '<a href=\"http://geely-avalink.ru/\"><img src="/image/' + autosArr[i][0] + '" /></a>';
		}
		else if(i == 2) {
			if(autosArr[i][0]!='') content += '<a href=\"http://tagaz-avalink.ru\"><img src="/image/' + autosArr[i][0] + '"></a>';
		}
		else if(i == 3) {
			if(autosArr[i][0]!='') content += '<a href=\"http://www.avalink.ru/catalogue.php?chance=1\"><img src="/image/' + autosArr[i][0] + '"></a>';
		}
		else {
			if(autosArr[i][0]!='') content += '<a href=\"http://www.ssangyong-avalink.ru/\"><img src="/image/' + autosArr[i][0] + '"></a>';
		}
		content += '</div><div class="AutoILeft AutoIBacknone" id="autoileft'+ i +'"><img src="/image/autoitemleft.jpg" onClick="showAuto('+ i +', 0)" onMouseOver="this.src=\'/image/autoitemlefton.jpg\'" onMouseOut="this.src=\'/image/autoitemleft.jpg\'" onMouseDown="this.src=\'/image/autoitemleftclick.jpg\'" onMouseUp="this.src=\'/image/autoitemlefton.jpg\'"></div>';
		content += '<div class="AutoIShow" id="autoishow'+ i +'">';
		var countCols = parseInt((autosArr[i].length - 1) / 3);
		for(var j = 0; j<5; j++){
			if(j<countCols) {
				//if (i == 1) {
				//	content += '<div class="AutoIElement" id="auto'+ i +'_'+ j +'"><img src="/image/'+ autosArr[i][1 + j*3] +'"><br/>'+ autosArr[i][3 + j*3] +'</div>';
				//}
				//else {
					content += '<div class="AutoIElement" id="auto'+ i +'_'+ j +'"><a href="'+ autosArr[i][2 + j*3] +'"><img src="/image/'+ autosArr[i][1 + j*3] +'"></a><br/><a href="'+ autosArr[i][2 + j*3] +'">'+ autosArr[i][3 + j*3] +'</a></div>';
				//}
			}
			else {
				content += '<div class="AutoIElement" id="auto'+ i +'_'+ j +'"></div>';
			}
		}
		content += '</div>';
		var classRight = (countCols>5) ? '' : ' AutoIBacknone';
		content += '<div class="AutoIRight'+ classRight +'" id="autoiright'+ i +'"><img src="/image/autoitemright.jpg" onClick="showAuto('+ i +', 1)" onMouseOver="this.src=\'/image/autoitemrighton.jpg\'" onMouseOut="this.src=\'/image/autoitemright.jpg\'" onMouseDown="this.src=\'/image/autoitemrightclick.jpg\'" onMouseUp="this.src=\'/image/autoitemrighton.jpg\'"></div>';
		content += '</div>';
	}
	document.getElementById('AutoList').innerHTML = content;
}






function showAutoList_en()
{
	var countRows = autosArr.length;
	var content = '';
	for(var i = 0; i<countRows; i++){
		startAuto[i] = 0;
		content += '<div class="AutoListItem"><div class="AutoILogo">';
        if(i == 0) {
			if(autosArr[i][0]!='') content += '<a href=\"http://www.avalink.ru/catalogue.php?id=201&lang_id=1\"><img src="http://www.avalink.ru/image/' + autosArr[i][0] + '"></a>';
		}
		else if(i == 1) {
			if(autosArr[i][0]!='') content += '<a href=\"http://geely-avalink.ru/\"><img src="http://www.avalink.ru/image/' + autosArr[i][0] + '" /></a>';
		}
		else if(i == 2) {
			if(autosArr[i][0]!='') content += '<a href=\"http://tagaz-avalink.ru\"><img src="http://www.avalink.ru/image/' + autosArr[i][0] + '"></a>';
		}
		else if(i == 3) {
			if(autosArr[i][0]!='') content += '<a href=\"http://www.avalink.ru/catalogue.php?chance=1\"><img src="http://www.avalink.ru/image/' + autosArr[i][0] + '"></a>';
		}
		else {
			if(autosArr[i][0]!='') content += '<a href=\"http://www.ssangyong-avalink.ru/\"><img src="http://www.avalink.ru/image/' + autosArr[i][0] + '"></a>';
		}
		content += '</div><div class="AutoILeft AutoIBacknone" id="autoileft'+ i +'"><img src="http://www.avalink.ru/image/autoitemleft.jpg" onClick="showAuto_en('+ i +', 0)" onMouseOver="this.src=\'http://www.avalink.ru/image/autoitemlefton.jpg\'" onMouseOut="this.src=\'http://www.avalink.ru/image/autoitemleft.jpg\'" onMouseDown="this.src=\'http://www.avalink.ru/image/autoitemleftclick.jpg\'" onMouseUp="this.src=\'http://www.avalink.ru/image/autoitemlefton.jpg\'"></div>';
		content += '<div class="AutoIShow" id="autoishow'+ i +'">';
		var countCols = parseInt((autosArr[i].length - 1) / 3);
		for(var j = 0; j<5; j++){
			if(j<countCols) {
				//if (i == 1) {
				//	content += '<div class="AutoIElement" id="auto'+ i +'_'+ j +'"><img src="/image/'+ autosArr[i][1 + j*3] +'"><br/>'+ autosArr[i][3 + j*3] +'</div>';
				//}
				//else {
					content += '<div class="AutoIElement" id="auto'+ i +'_'+ j +'"><img src="http://www.avalink.ru/image/'+ autosArr[i][1 + j*3] +'"><br/>'+ autosArr[i][3 + j*3] +'</div>';
				//}
			}
			else {
				content += '<div class="AutoIElement" id="auto'+ i +'_'+ j +'"></div>';
			}
		}
		content += '</div>';
		var classRight = (countCols>5) ? '' : ' AutoIBacknone';
		content += '<div class="AutoIRight'+ classRight +'" id="autoiright'+ i +'"><img src="http://www.avalink.ru/image/autoitemright.jpg" onClick="showAuto_en('+ i +', 1)" onMouseOver="this.src=\'http://www.avalink.ru/image/autoitemrighton.jpg\'" onMouseOut="this.src=\'http://www.avalink.ru/image/autoitemright.jpg\'" onMouseDown="this.src=\'http://www.avalink.ru/image/autoitemrightclick.jpg\'" onMouseUp="this.src=\'http://www.avalink.ru/image/autoitemrighton.jpg\'"></div>';
		content += '</div>';
	}
	document.getElementById('AutoList').innerHTML = content;
}







function showAuto(id, mode)
{
	// mode = 0 - влево
	// mode = 1 - вправо
	var countCols = parseInt((autosArr[id].length - 1) / 3);
	if(mode==0){
		if(startAuto[id]>0){
			var current = parseInt(startAuto[id] - 1);
			for(var i = current; i<parseInt(current + 5); i++){
				document.getElementById('auto'+ id +'_'+ (i-current)).innerHTML = '<a href="'+ autosArr[id][2 + i*3] +'"><img src="/image/'+ autosArr[id][1 + i*3] +'"></a><br/><a href="'+ autosArr[id][2 + i*3] +'">'+ autosArr[id][3 + i*3] +'</a>';
			}
			startAuto[id] = current;
		}
	}
	if(mode==1){
		if(parseInt(startAuto[id] + 5) < countCols){
			var current = parseInt(startAuto[id] + 1);
			for(var i = current; i<parseInt(current + 5); i++){
				document.getElementById('auto'+ id +'_'+ (i-current)).innerHTML = '<a href="'+ autosArr[id][2 + i*3] +'"><img src="/image/'+ autosArr[id][1 + i*3] +'"></a><br/><a href="'+ autosArr[id][2 + i*3] +'">'+ autosArr[id][3 + i*3] +'</a>';
			}
			startAuto[id] = current;
		}
	}
	if(startAuto[id]>0) document.getElementById('autoileft'+ id).className = 'AutoILeft';
	else document.getElementById('autoileft'+ id).className = 'AutoILeft AutoIBacknone';
	if(parseInt(startAuto[id] + 5) < countCols) document.getElementById('autoiright'+ id).className = 'AutoIRight';
	else document.getElementById('autoiright'+ id).className = 'AutoIRight AutoIBacknone';
}



function showAuto_en(id, mode)
{
	// mode = 0 - влево
	// mode = 1 - вправо
	var countCols = parseInt((autosArr[id].length - 1) / 3);
	if(mode==0){
		if(startAuto[id]>0){
			var current = parseInt(startAuto[id] - 1);
			for(var i = current; i<parseInt(current + 5); i++){
				document.getElementById('auto'+ id +'_'+ (i-current)).innerHTML = '<img src="http://www.avalink.ru/image/'+ autosArr[id][1 + i*3] +'"><br/>'+ autosArr[id][3 + i*3] +' ';
			}
			startAuto[id] = current;
		}
	}
	if(mode==1){
		if(parseInt(startAuto[id] + 5) < countCols){
			var current = parseInt(startAuto[id] + 1);
			for(var i = current; i<parseInt(current + 5); i++){
				document.getElementById('auto'+ id +'_'+ (i-current)).innerHTML = '<img src="http://www.avalink.ru/image/'+ autosArr[id][1 + i*3] +'"><br/>'+ autosArr[id][3 + i*3] +' ';
			}
			startAuto[id] = current;
		}
	}
	if(startAuto[id]>0) document.getElementById('autoileft'+ id).className = 'AutoILeft';
	else document.getElementById('autoileft'+ id).className = 'AutoILeft AutoIBacknone';
	if(parseInt(startAuto[id] + 5) < countCols) document.getElementById('autoiright'+ id).className = 'AutoIRight';
	else document.getElementById('autoiright'+ id).className = 'AutoIRight AutoIBacknone';
}




function showSmallLogo()
{
	var countLogo = parseInt(logoSmall.length / 4);
	for(var i = 1; i<=4; i++){
		var content = '';
		for(var j = 0; j<countLogo; j++){
			//Модель Geely
			/*if(j == 1) {
				content += '<img src="/image/'+ logoSmall[4*j] +'" border="0" style="margin-right:10px;"/>';
			}
			else {*/
				content += '<a href="'+ logoSmall[4*j + i] +'"><img src="/image/'+ logoSmall[4*j] +'" border="0"></a>';
			/*}*/
		}
		var name = 'smalllogo' + i;
		document.getElementById(name).innerHTML = content;
	}
}
