// JavaScript Document
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  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];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function ViewIcons(textBlockId) {
  textBlock = document.getElementById(textBlockId);
  textBlock.style.visibility = 'visible';
}
function HideIcons(textBlockId) {
  textBlock = document.getElementById(textBlockId);
  textBlock.style.visibility = 'hidden';
}
function activate_leader(BlockId){
	textBlock = document.getElementById('leader_lot'+BlockId);
	textBlock.style.background = 'url(/images/template/orange_outline.png)';
	textBlock = document.getElementById('leader_price'+BlockId);
	textBlock.src = '/images/template/price_bg_active.png';
}
function deactivate_leader(BlockId){
	textBlock = document.getElementById('leader_lot'+BlockId);
	textBlock.style.background = 'none';
	textBlock = document.getElementById('leader_price'+BlockId);
	textBlock.src = '/images/template/price_bg.png';
	
}
function actCatLot(BlockId){
	textBlock = document.getElementById('ctl'+BlockId);
	textBlock.src = '/images/catalog/orange_left.jpg';
	textBlock = document.getElementById('ctm'+BlockId);
	textBlock.style.background = 'url(/images/catalog/orange_bg.jpg)';
	textBlock = document.getElementById('ctr'+BlockId);
	textBlock.src = '/images/catalog/orange_right.jpg';
	textBlock = document.getElementById('cb'+BlockId);
	textBlock.style.visibility = 'visible';
}
function deactCatLot(BlockId){
	textBlock = document.getElementById('ctl'+BlockId);
	textBlock.src = '/images/catalog/grey_left.jpg';
	textBlock = document.getElementById('ctm'+BlockId);
	textBlock.style.background = 'url(/images/catalog/grey_bg.jpg)';
	textBlock = document.getElementById('ctr'+BlockId);
	textBlock.src = '/images/catalog/grey_right.jpg';
	textBlock = document.getElementById('cb'+BlockId);
	textBlock.style.visibility = 'hidden';
}

function activateLeftMenuLot(BlockId){
	textBlock = document.getElementById('menu_lot'+BlockId);
	textBlock.style.background = 'url(/images/template/left_menu_lot_bg.jpg)';
	
}
function deactivateLeftMenuLot(BlockId){
	textBlock = document.getElementById('menu_lot'+BlockId);
	textBlock.style.background = 'none';
	
}
function actPhoto(photoId){
	textBlock = document.getElementById('photo'+photoId);
	textBlock.style.border = 'solid #e8e8e8 1px';
}
function deactPhoto(photoId){
	textBlock = document.getElementById('photo'+photoId);
	textBlock.style.border = 'solid #FFF 1px';
}

function select_col(i){
	if (document.ord_form.elements['colors'].length){
		document.ord_form.colors[i].checked=true;
	}
	else{
		document.ord_form.colors.checked=true;
	}	
}

function select_side(i)
{
	if (i == 0) document.ord_form.variant[0].checked=true;
	if (i == 1) document.ord_form.variant[1].checked=true;	
}
function select_mirror(i)
{
	if (i == 0) document.ord_form.mirror[0].checked=true;
	if (i == 1) document.ord_form.mirror[1].checked=true;		
}
function validate_custinfo()
{
	var ind=1;
	var ind_variant=1;
	var ind_mirror=1;
	var alert_string = '';

	if(document.ord_form.elements['colors'].length){
		ind=0;
		alert_string +=', выберите цвет изделия ';
		for(i=0;i<document.ord_form.elements['colors'].length;i++) {
			if(document.ord_form.colors[i].checked==true) {
			ind=1;
			}
		}
	}
	else{
		ind=0;
		alert_string +=', выберите цвет изделия';		
		if(document.ord_form.colors.checked==true) 
			ind=1;		
	}

	if(document.ord_form.elements['variant']){
		ind_variant=0;
		for(i=0;i<document.ord_form.elements['variant'].length;i++) {
			if(document.ord_form.variant[i].checked==true) 	ind_variant=1;
		}
		if (ind_variant == 0) alert_string +=', выберите вариант исполнения изделия!';
	}
	
	if(document.ord_form.elements['mirror']){
		ind_mirror=0;
		for(i=0;i<document.ord_form.elements['mirror'].length;i++) {
			if(document.ord_form.mirror[i].checked==true) 	ind_mirror=1;
		}
		if (ind_mirror == 0) alert_string +=' С зеркалом или без зеркала?';
	}
	
	
	if (!(ind & ind_variant & ind_mirror))
	{
		alert('Пожалуйста' + alert_string);
		return false;
	}
	else	
		return true;		
	
}

