<!--
function loadFlash(f,w,h){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+w+'" height="'+h+'">');
document.write('<param name="wmode" value="opaque" />');
document.write('<param name="movie" value="'+f+'">');
document.write('<param name="quality" value="high">');
document.write('<embed wmode="opaque" src="'+f+'" width="'+w+'" height="'+h+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>');
document.write('</object>');
}

function loadFlashData(data1,data2){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="700" height="113">');
document.write('<param name="wmode" value="opaque" />');
document.write('<param name="movie" value="/data/promo/store_open.swf?startdate1='+data1+'">');
document.write('<param name="quality" value="high">');
document.write('<param name="startdate1" value="'+data1+'">');
document.write('<embed wmode="opaque" src="/data/promo/store_open.swf?startdate1='+data2+'" width="700" height="113" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>');
document.write('</object>');
}

function MenuActive(id)
{
	document.getElementById(id).style.height="35px";
	document.getElementById(id).style.marginTop="0px";
	document.getElementById(id).style.paddingTop="7px";
	document.getElementById(id).style.backgroundImage="none";
	document.getElementById(id).style.borderBottom="none";
}

function MenuDeActive(id,height,top)
{
	document.getElementById(id).style.height=(height-top)+"px";
	document.getElementById(id).style.marginTop="6px";
	document.getElementById(id).style.paddingTop=top+"px";
	var id_new = id.replace("menu_","");
	document.getElementById(id).style.backgroundImage="url('/images/bg/"+id_new+".png')";
	document.getElementById(id).style.borderBottom="#FFFFFF 1px solid";
}

var shov_lim='';
var hid_lim = new Array();

function ShowDiv(div) 
{
	document.getElementById(div).style.display = "block";
}

function ShowDivLimit(div,limit) 
{
	shov_lim=setTimeout("ShowDiv('"+div+"')", limit);
}

function ShowDivHidClear(div) 
{
	clearTimeout(hid_lim[div]);
	document.getElementById(div).style.display = "block";
}

function HiddenDiv(div) 
{
	document.getElementById(div).style.display = "none";
}

function HiddenDivLimit(div,limit) 
{
	clearTimeout(shov_lim);
	hid_lim[div]=setTimeout("HiddenDiv('"+div+"')", limit);
}

function ShowHidDiv(div)
{
	if (document.getElementById(div).style.display=='none')
	{
		ShowDiv(div);
	}
	else
	{
		HiddenDiv(div);
	}
}

function ShowPhoto(photoname, w, h) 
{
	url = "http://www.positronica.ru/showphoto/?img="+photoname;
	Win=window.open(url, 'viewPhoto',  'toolbar=0,scrollbars=0,location=0,directories=0,status=0,menubar=0,resizable=0,width='+w+',height='+h+',border=thin,top=50,left=50,help=0');
	Win.focus();
}

function ItemP(div)
{
	if (document.getElementById('item_photo'))
	{
		document.getElementById('item_photo').className="item_p";
		document.getElementById('item_photo_data').style.display = "none";
	}
	if (document.getElementById('item_prop'))
	{
		document.getElementById('item_prop').className="item_p";
		document.getElementById('item_prop_data').style.display = "none";
	}
	if (document.getElementById('item_reviews'))
	{
		document.getElementById('item_reviews').className="item_p";
		document.getElementById('item_reviews_data').style.display = "none";
	}
	if (document.getElementById('item_price'))
	{
		document.getElementById('item_price').className="item_p";
		document.getElementById('item_price_data').style.display = "none";
	}
	document.getElementById(div).className="item_p_active";
	document.getElementById(div+'_data').style.display = "block";
}


function BuyCity(item_id)
{	
	if (document.getElementById('buy_city').style.display=='none')
	{
		makeRequest('/ajax/buy_city.php?item_id='+item_id,'buy_city',1);
		ShowDiv('buy_city');
	}
	else
	{
		HiddenDiv('buy_city');
	}
}


var value_opacty=6;

function setOpacity(top,left,script) {
   value_opacty += 0.1;
   var Obj = document.getElementById('blanking');
   
   Obj.style.width = "100%";
   Obj.style.height = "100%";
   Obj.style.display = "block";
   Obj.style.opacity = value_opacty/10;
   Obj.style.filter = 'alpha(opacity=' + value_opacty*10 + ')';
   myTimeout = setTimeout("setOpacity('blank_open')", 1);
   
   if ((value_opacty) >= 6.0) {
	  clearTimeout(myTimeout);
   }

  document.documentElement.style.overflow = "hidden";

  document.getElementById('blanking').style.top=document.documentElement.scrollTop+'px';
  document.getElementById('blank_open').style.top=document.documentElement.scrollTop+200+'px';
  var width=document.documentElement.clientWidth;
  document.getElementById('blank_open').style.left=(width/2-200)+'px';
 
  if (script)
  {
	  makeRequest(script,'blank_open',1);
  }
  document.getElementById('blank_open').style.display = "block";
}

function removeOpacity() {
   value_opacty -= 0.1;
   var Obj = document.getElementById('blanking');
   
   myTimeout2 = setTimeout("removeOpacity('blank_open')", 1);
   Obj.style.opacity = value_opacty/10;
   Obj.style.filter = 'alpha(opacity=' + value_opacty*10 + ')';
   
   if ((value_opacty) <= 6) {
	  Obj.style.display = "none";
	  clearTimeout(myTimeout2);
   }
  document.documentElement.style.overflow = "auto";
  document.getElementById('blank_open').style.display = "none";
}

function CloseAuthorize()
{
	document.getElementById('blank_open').innerHTML = "";
	removeOpacity();
}

function AutoIns(pass)
{
	var email=document.registration["email"].value;
	var zip=/(.*?)@/;
	var reg=zip.exec(email);
	if (reg!=null)
	{	var name=reg[1]+TimeCount(12198400000);	}
	else
	{	var name='posi'+TimeCount(12100000000);	}

	document.registration["login_reg"].value=name;
	document.registration["password_reg"].value=pass;
	document.registration["password2"].value=pass;
}

function TimeCount(minus)
{
	var d = new Date();
	return (Math.ceil(d.getTime()/100)-minus);
}


function GoURL(url, target) {
	var w;
	if (target == "_blank") {
		w = window.open(url,"w","");
		w.focus();
	}	else {
		document.location = url;
	}
	return false;
}

function Delivery()
{
	document.getElementById('delivery_but').className="ord_step_active";
	document.getElementById('pickup_but').className="ord_step";
	HiddenDiv('div_pickup'); 
	ShowDiv('div_delivery');
}

function Pickup()
{
	document.getElementById('delivery_but').className="ord_step";
	document.getElementById('pickup_but').className="ord_step_active";
	HiddenDiv('div_delivery'); 
	ShowDiv('div_pickup');
}

function Delivery2()
{
	document.getElementById('delivery_but').className="ord_step_ch_active";
	document.getElementById('pickup_but').className="ord_step_ch";
	HiddenDiv('div_pickup'); 
	ShowDiv('div_delivery');
}

function Pickup2()
{
	document.getElementById('delivery_but').className="ord_step_ch";
	document.getElementById('pickup_but').className="ord_step_ch_active";
	HiddenDiv('div_delivery'); 
	ShowDiv('div_pickup');
}

function implode(array, separator) 
{
   return array.join(separator); 
}

function getRadioGroupValue(radioGroupObj)
{
  for (var i=0; i < radioGroupObj.length; i++)
    if (radioGroupObj[i].checked) return radioGroupObj[i].value;

  return null;
}

function CheckEmail(e){
	e = e.toLowerCase();
	var ch="@";
	var count=0;
	var error=false;
	
	for (var i=0; i<e.length; i++){
		if(e.charAt(i)==ch || e.charAt(i)=="."){
			error = (count==0) ? true : error;
			ch = (ch==".") ? 0 : ch;
			ch = (e.charAt(i)=="@") ? "." : ch;
			count=0;
			continue;
		}
		count++;
	
		if((e.charAt(i)<"a" || e.charAt(i)>"z") && (e.charAt(i)<"0" || e.charAt(i)>"9") && e.charAt(i)!="_" && e.charAt(i)!="-"){
			error = true;
			break;
		}
	}
	error = (count==0) ? true : error;
	error = (ch==0) ? error : true;
	return !error;
}

function openWin (url, w, h, win_name) {
		Win=window.open(url, win_name,  'toolbar=0,scrollbars=1,location=0,directories=0,status=0,menubar=0,resizable=1,width='+w+',height='+h+',border=thin,top=50,left=50,help=0');
		Win.focus();
}

function CheckQuickBuyForm(form_name)
{
	if (document.forms[form_name]["name"].value=='' || document.forms[form_name]["name"].value=='Ваше имя' || document.forms[form_name]["phone"].value=='' || document.forms[form_name]["phone"].value=='Телефон')
	{
		alert("Заполните, пожалуйста, все поля!");
		return;
	}
	
	var phone=document.forms[form_name]["phone"].value;
	phone=str_replace(" ","",phone);
	phone=str_replace("-","",phone);
	var reg=/\+\d{1}\(\d{1,5}\)\d{4,9}/;
	var check=reg.exec(phone);

	if (check==null)
	{
		alert("Ошибка в номере телефона! Заполните, пожалуйста, в правильном формате.");
		return;
	}
	
	document.forms[form_name]["quickbuy"].submit();
}


function FormFocus(form_name,name,def)
{
	if (document.forms[form_name][name].value==def)
		document.forms[form_name][name].value='';
}

function FormBlur(form_name,name,def)
{
	if (document.forms[form_name][name].value=='')
		document.forms[form_name][name].value=def;
}


function str_replace ( search, replace, subject ) {    // Replace all occurrences of the search string with the replacement string
    // 
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
 
    if(!(replace instanceof Array)){
        replace=new Array(replace);
        if(search instanceof Array){//If search    is an array and replace    is a string, then this replacement string is used for every value of search
            while(search.length>replace.length){
                replace[replace.length]=replace[0];
            }
        }
    }
 
    if(!(search instanceof Array))search=new Array(search);
    while(search.length>replace.length){//If replace    has fewer values than search , then an empty string is used for the rest of replacement values
        replace[replace.length]='';
    }
 
    if(subject instanceof Array){//If subject is an array, then the search and replace is performed with every entry of subject , and the return value is an array as well.
        for(k in subject){
            subject[k]=str_replace(search,replace,subject[k]);
        }
        return subject;
    }
 
    for(var k=0; k<search.length; k++){
        var i = subject.indexOf(search[k]);
        while(i>-1){
            subject = subject.replace(search[k], replace[k]);
            i = subject.indexOf(search[k],i);
        }
    }
 
    return subject;
 
}


function makeChoose(type_id) {
	window.open('/catalog/compare/loader.php/?type_id='+type_id, 'compareWindow', 'width=900, height=650, scrollbars=1, resizable=1');
}

function SelectAll(Name){
	if (DOM) {
		thisCheckBoxes = document.getElementsByTagName('input');

		for (i = 1; i < thisCheckBoxes.length; i++) {
			if (thisCheckBoxes[i].name == Name){
				thisCheckBoxes[i].checked = true;
			}
		}
	}
}

function UnSelectAll(Name){
	if (DOM) {
		thisCheckBoxes = document.getElementsByTagName('input');

		for (i = 1; i < thisCheckBoxes.length; i++) {
			if (thisCheckBoxes[i].name == Name){
				thisCheckBoxes[i].checked = false;
			}
		}
	}
}

// Используется в форме сравнения товаров
function refresher(field1,field2,field3){
// вызов (поле1,поле2,поле3)
if (field1!='' && field1!=-1 && field2!='' && field2!=-1) {
	if (field1 == 'none') field1 = ''; // значение none используется для сравнения товаров, не имеющих заполненных свойств (все поля пустые)
	document.forms['refresher'].property_ids.value=field1;
	document.forms['refresher'].item_ids.value=field2;
	document.forms['refresher'].sorting.value=field3;
alert(field1+' | '+field2+' | '+field3);

	document.forms['refresher'].submit();
} else { 
	alert('Результатом операции будет пустая таблица. Пожалуйста, измените условия фильтрации.'); 
	}
}

// Используется в форме сравнения товаров
function DeleteRow(i,arr,arr1){
//alert('3');
	s='';
	for (j=0;j<arr.length;j++) if (arr[j]!=i) s=s+','+arr[j];
	if (s!='') s=s.substr(1);
	s1='';
	for (j=0;j<arr1.length;j++) s1=s1+','+arr1[j];	
	if (s1!='') s1=s1.substr(1);
	refresher(s,s1,document.forms['refresher'].sorting.value);
}

// Используется в форме сравнения товаров
function DeleteColumn(i,arr,arr1){
	s='';
	for (j=0;j<arr.length;j++) s=s+','+arr[j];
	if (s!='') s=s.substr(1);
	s1='';
	for (j=0;j<arr1.length;j++) if (arr1[j]!=i) s1=s1+','+arr1[j]; 
	if (s1!='') s1=s1.substr(1);
	refresher(s,s1,document.forms['refresher'].sorting.value);
}

function getSpisok(arr){
//	alert(arr+' | '+arr.length);
//	len = arr.length;
//	alert(arr[1]+' | '+ arr[0] +' | '+arr.length );
	if (arr.length) {s=''; for (i=0;i<arr.length;i++) s=s+','+arr[i];if (s!='') s=s.substr(1);}
	else s = arr[0];
//	alert("meee:"+s);
	return (s);
}

function mgetSpisok(oform,name,arr,checked){
//alert([oform,name,arr,checked])
//alert(oform.name);
	if (arr.length) {
///*
		s='';
//		alert(arr);
	        j=0;
		for (i=0;(i<arr.length);i++) {
		
			el=(name+'['+arr[i]+']');
//			alert(el);
//			alert(oform.elements[el]);
			if (oform.elements[el] && oform.elements[el].checked==checked) {s=s+','+arr[i];	j++;}
		}
		if ((s!='' && j<=10 && oform.name =='ItemList') || (s!='' && oform.name != 'ItemList')) s=s.substr(1);
		else if (s!='') s=-1;
//			alert(s);
	  }
//*/
	return (s);

}



function ReBuildMoreValue(Url,FormName,UrlE)
{
	Form=document.forms[FormName];

	var ArrayBrands = new Array();
	var ArrayFilters = new Array();
	
	var b=0;
	var f=0;
	for (var i=0; i < Form.length; i++) 
	{
		if (Form[i].name=='brand[]' && Form[i].checked==true)
		{
			ArrayBrands[b]=Form[i].value;
			b++;
		}
		if (Form[i].name=='filter[]' && Form[i].checked==true)
		{
			ArrayFilters[f]=Form[i].value;
			f++;
		}
			
	}
	
	if (f>0)
		UrlLoad=implode(ArrayFilters,",");
	else
	{
		if (b>0)
			UrlLoad=implode(ArrayBrands,",");
		else
			UrlLoad='';
	}

	if (UrlE!="=" && UrlLoad!='')
		UrlP=",";
	else
		UrlP="";
		
	window.location.href = Url+UrlP+UrlLoad;
}


function implode(array, separator) 
{
  return array.join(separator);
}

function ShowDivMgn()
{
	HiddenDiv('regions_int');
	ShowDiv('div_mgn');
}

function HiddenDivMgn()
{
	ShowDiv('regions_int');
	HiddenDiv('div_mgn');
}

//-->
