function openWishlist(pid,partner){
  if (partner == null || partner == 'undefined') partner=''; 
  w=window.open("/basket/wishlist.php?act=add&pid="+pid+"&ID_PARTNER="+partner+"&no_html=1",'',"height=105,width=200,status=no,toolbar=no,menubar=no,location=no");
  w.focus();
}

function openOrderDisabled(uaid){
  w=window.open("/order/disabled.php?uaid="+uaid,"bolero_disabled","height=300,width=600,status=no,toolbar=no,menubar=no,location=no");
  w.focus();
}

function OpenPopUpWindow(URL,width,height){
    var size = '';
    if(isNaN(width)){width = 200;}
    if(isNaN(height)){height = 200;}
    popup_w =window.open(URL,'PopUp',"height="+height+",width="+width+",left=300,top=150,resizable=yes,scrollbars=no,toolbar=no,location=no,menubar=no,status=no");
    popup_w.focus();
}
 
var xx;
//var growthByStep = new Array(50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100);
var growthByStep = new Array(50, 60, 70, 80, 90, 100);
var stepCount = growthByStep.length;
var realWidth = 100;
var realHeight = 185;
var realLeft = 7;
var realTop = 58;
var stepNo = 0;
var dLeft=0;
var dTop=0;

function imgOver(id){
  document.getElementById(id+'_div').style.display='block';
  showBiggerImage(id);
}

function showBiggerImage(id){
	img=document.getElementById(id+'_b');
	if ((stepCount > stepNo + 1)){
		document.getElementById(id+'_b').style.display='block';
		stepNo++;
    img.width = realWidth * growthByStep[stepNo] / 100;
    	dLeft=realWidth*growthByStep[stepNo]/200-realWidth*growthByStep[stepNo-1]/200;
    	dTop=realHeight*growthByStep[stepNo]/100-realHeight*growthByStep[stepNo-1]/100;
    //img.height = /*realHeight * */growthByStep[stepNo] / 100;
		img.style.marginLeft=img.style.marginLeft.substring(0, img.style.marginLeft.length-2)-dLeft+'px';
		img.style.marginTop=img.style.marginTop.substring(0, img.style.marginTop.length-2)-dTop+'px';
  		xx=setTimeout('showBiggerImage("'+id+'")', 30);
//		img.style.opacity = stepNo/10+0.5;
//		img.style.filter = 'alpha(opacity=' + ((stepNo+1)*100/stepCount) + ')';
	}
}

function imgOut(id){
  img=document.getElementById(id+'_b');
  clearTimeout(xx);
  
  img.style.display='none';
  document.getElementById(id+'_div').style.display='none';
  img.style.marginLeft=realLeft+'px';
  img.style.marginTop=realTop+'px';
  
  stepNo = 0;
  dLeft=0;
  dTop=0;
}

function hideLayer(id){
	document.getElementById(id).style.display = "none";
}
	
function showLayer(id){	
	document.getElementById(id).style.display = "inline";
}	

function showHiddenText(id){
	if(document.getElementById('hidden_text_'+id).style.display == "block"){
		
		document.getElementById('hidden_text_'+id).style.display = "none"
		document.getElementById('open_'+id).style.display = "block";
	}else{
		
		document.getElementById('hidden_text_'+id).style.display = "block";
		document.getElementById('open_'+id).style.display = "none";
	}
	//alert(document.getElementById('more_hidden_'+id).style.display);
}	

function resiseImg(id,width,height,lWidth,lHeight){
	var oImg = document.getElementById(id);
	
	if(oImg.width == lWidth && oImg.height == lHeight){
		oImg.width = width;
		oImg.height = height;
	}else{
		oImg.width = lWidth;
		oImg.height = lHeight;
	}
}

function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function open_window(owindow,owidth,oheight){
	var w = window.open(owindow,'POP_UP', 'width='+owidth+',height='+oheight+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0' );
	w.focus();
}
	//--- Функции для прорисовки звёзд (рейтингов, общих оцено и прочего)
	// common_div_id - это общая составляющая названий идентификаторов дивов со звёздаками
	// star_light,star_off и star_half --классы соответствующие закрашенной,незакрашенной и закрашенной  половину звезде. Объявляются в файле где рисуем звёзды
function showSelStars(common_div_id,s) {
		//Отчищаем все звёзды 
	for (var i=1; i<=5; i++) {
		document.getElementById(common_div_id+i).className = star_off;
	}
		//Прорисовываем закрашенные
	for (var i=1; i<=s; i++) {
		document.getElementById(common_div_id+i).className = star_light;
	}
}

function hideSelStars(common_div_id,s) {
	for (var i=1; i<=s; i++) {
		document.getElementById(common_div_id+i).className = star_off;
	}
		// Прорисовывем согласно рейтингу
	showStars(common_div_id,review_mark,5);
}


	//Прорисовка звёзд, согласно оценке 
function showStars(common_div_id,rate,max_elem){
	var celoe = Math.floor(rate);					//Целая часть
	var mantisa = Math.floor((rate - celoe)*10);	//Десятичная часть
	var delta = 1;									//Смещение на 1, если с половинкой
		// Если мантиса >6 то округляем в большую сторону.
	if(mantisa >= 6){
		celoe++;
		mantisa = 0;
	}
		//Строим целую часть
	for (var i=1; i<=celoe; i++) {
		document.getElementById(common_div_id+i).className = star_light;
	}
		//Проверяем на десятичную чать
	if(mantisa > 0){
		document.getElementById(common_div_id+i).className = star_half;
		delta += 1;
	}
		//Достраиваем пустые
	for (var i=(celoe+delta); i<=max_elem; i++) {
		document.getElementById(common_div_id+i).className = star_off;
	}
}

function analizeIAgreeCheckbox(){
	
	if(document.getElementById('i_agree').checked == true){
		document.getElementById('act_makeorder').disabled = false;
	}else{
		document.getElementById('act_makeorder').disabled = true;
	}
}