//ПЕРЕМЕННЫЕ И КОНСТАНТЫ
//-----------

var CurThumb = '1' //"эта превьюшка сейчас отображена" начальное значение
isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;


//ФУНКЦИИ
//-------

// функция вызова объекта по его имени
function getelementbyid(myid) {
   if (isNS4){
        objElement = document.layers[myid];
     }else if (isIE4) {
        objElement = document.all[myid];
     }else if (isIE5 || isNS6) {
             objElement = document.getElementById(myid);
     }
return(objElement);
}

//функция определения номера изображения в карусели по порядковому номеру файла
function thisItemNumber(x) {
if (Thumbs-parseInt(x,10)<9) {
	withAddedNull='0'+String(Thumbs-parseInt(x,10)+1);
} else {	
	withAddedNull=String(Thumbs+1-parseInt(x,10));
};
return (withAddedNull);
}

function ClickThumb(tmb, txt, p, ps, psn, opisanie, price) {
	Source = Podrazdel + tmb + '.jpg';
	cartItemPreviewPath = window.location.href.replace('photos.html','') + Source.replace('photos_files','photos_files/preview_in_'+Podrazdel.replace('photos_files/kogel.ru.','').replace('.','')); 
		
	getelementbyid('krup').src = Source;
	$(".zoomed").attr("href", PodrazdelZoom + tmb + ".jpg");
	getelementbyid('scrolltext').childNodes[0].nodeValue = getelementbyid('thumbtext').childNodes[0].nodeValue;//tmb;
	cartItemNumber = getelementbyid('thumbtext').childNodes[0].nodeValue;
	if (getelementbyid('colltitle')){
		getelementbyid('colltitle').childNodes[0].nodeValue = txt;
	};
	if (getelementbyid('photographer')){
		getelementbyid('photographer').childNodes[0].nodeValue = p;
	};
	if (!(getelementbyid('psite'))&!(psn=='')) { //если первая фотка с подписью без ссылки
		var psiteEl=document.createElement("a");
		psiteEl.id="psite";
		psiteEl.appendChild(document.createTextNode('.'));
		getelementbyid('photographer').parentNode.appendChild(psiteEl);
	};
	if (getelementbyid('psite')){
		getelementbyid('psite').setAttribute('href',ps);
		getelementbyid('psite').childNodes[0].nodeValue = psn;
	};
	if (getelementbyid('opisanie_modeli')){
		getelementbyid('opisanie_modeli').childNodes[0].nodeValue = opisanie;
		cartItemDescription = getelementbyid('opisanie_modeli').childNodes[0].nodeValue;
	};
	if (getelementbyid('price')){
		getelementbyid('price').childNodes[0].nodeValue = price;	
		cartItemPrice = getelementbyid('price').childNodes[0].nodeValue; //alert(cartItemPrice);
	};
	CurThumb = tmb;
	//отключение zoom-switch, поскольку прик первом клике на превьюшке зум начинает нормально работать
	if ($("div.zoom-switch > a").attr( "onclick")){
	$("div.zoom-switch > a").removeAttr( "onclick" );
	};
}

function g777(ob,q,w,e,r,t,y,u) {
$('#main_container').css({'height':'100%','backgroundImage':'none'});
$('a').css({'display':'block','marginBottom':'20px','textDecoration':'none'});
te='&lt;offer id="2'+thisItemNumber(q)+'" type="vendor.model" available="true"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;price&gt;'+u+'&lt;/price&gt;<br>';
te=te+'&nbsp;&nbsp;&nbsp;&nbsp;&lt;currencyId&gt;RUR&lt;/currencyId&gt;<br>';
te=te+'&nbsp;&nbsp;&nbsp;&nbsp;&lt;categoryId&gt;2&lt;/categoryId&gt;<br>';
te=te+'&nbsp;&nbsp;&nbsp;&nbsp;&lt;picture&gt;http://www.kogel.ru/boutique/blouses/photos_files/kogel.ru.blouses.'+q+'.jpg&lt;/picture&gt;<br>';
te=te+'&nbsp;&nbsp;&nbsp;&nbsp;&lt;name&gt;Блуза&lt;/name&gt;<br>';
te=te+'&nbsp;&nbsp;&nbsp;&nbsp;&lt;description&gt;'+y+'&lt;/description&gt;<br>';
te=te+'&nbsp;&nbsp;&nbsp;&nbsp;&lt;param name="Сезон"&gt;'+w+'&lt;/param&gt;<br>';
te=te+'&lt;/offer&gt;<br>';
$(ob).before(te);
$('#mycarousel1 li img').css({'display':'none'})
//$(ob).before('----------<br><p>'+thisItemNumber(q)+'<br>'+u+'<br>'+e+''+r+''+t+''+y+'y<br>'+w+'</p>');
}

function order(iz, inu, prw, prc, prd) {
	// изделие, номер, путь к превьюшке, цена, описание
	var c = iz +'|'+ inu +'|'+ prw +'|'+ prc +'|'+ prd;  
	createCookie('kogelrucart', encodeURI(c), 2);
	window.location = "../../cart.html";
	}



