function debugStr( obj ){
 var str = new String; 
 var anObject=obj; 
 var propertyInfo = "" ;
 for (var propertyName in anObject) { 
  propertyInfo = propertyName + " = " + anObject[propertyName]; 
  str += propertyInfo + "\r\n\n" ;
 };
 
 str = str.replace(/</g,"\&lt;");
 str = str.replace(/>/g,"\&gt;");
 str = str.replace(/\r\n\n/g,"<br>");
 	
 return str;
}

function AjaxRQ(method, uri, data ){
 var ajaxRequest;
 try{
 // Opera 8.0+, Firefox, Safari
  ajaxRequest = new XMLHttpRequest();
 } catch (e){
  // Internet Explorer Browsers
  try{
   ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP.3.0");
  } catch (e) {
   try{
    ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP.3.0");
   } catch (e){
    // Something went wrong
    alert("Ошибка создания объекта XMLHttpRequest!\n Возможно, Ваш браузер не поддерживает этот объект");
    return false;
	 }
	}
 }
 ajaxRequest.open(method , uri,false);
 ajaxRequest.send(data);
 /*
 var st = new Date(); 
 while( ajaxRequest.readyState != 4 ){ 
  if( (new Date() - st)>8000 ) break;
  try{
   window.status = 'loading...'+ajaxRequest.readyState+'/4 '+ajaxRequest.status;
	}catch(e){
	}
 }
 */
 var str = ajaxRequest.responseText;
 return str;
}

function ShowNews(id,el){
 win = window.open('index.php?get=newstext&id='+id,'_blank','fullscreen=no,height=300, width=480, resizable=no, scrollbars=yes, toolbar=no');
}

function SendOrder(form){
 try{
  answer.innerHTML = 'sending...';
  strq = 'index.php?get=order';
  for(var i = 0; i < form.length; i++){
   if( form[i].name != '' ){
 	  strq += '&'+form[i].name+'='+form[i].value.replace(/\n/g,"<br>");
 	 }
  }
	str = AjaxRQ('GET',strq,'');
	
   var st = new Date(); 
  answer.innerHTML = str;
 }catch(e){
  answer.innerHTML = debugStr(e);
 }
 return false;
}


function SendQuery(form){
 try{
  answer.innerHTML = 'sending...';
  strq = 'index.php?get=question';
  for(var i = 0; i < form.length; i++){
   if( form[i].name != '' ){
 	  strq += '&'+form[i].name+'='+form[i].value.replace(/\n/g,"<br>");
 	 }
  }
	form['mail'].value='';
	str = AjaxRQ('GET',strq,'');
	
   var st = new Date(); 
  answer.innerHTML = str;
 }catch(e){
  answer.innerHTML = debugStr(e);
 }
 return false;
}

function ChangePasword(form){
 try{
  passChRes.innerHTML = '';
  //passChRes.innerHTML = debugStr(form.chc);
  //return false;
  
  var status = form.chc.status;
  if( status == undefined )
   status = form.chc.value;
   
  if( status && hex_md5(form.pass1.value) == hex_md5(form.pass2.value) ){
   var oldp = hex_md5(form.oldp.value);
	 var newp = hex_md5(form.pass1.value);
	 var data = "&oldp="+oldp+"&newp="+newp;
	 //alert(data);
	 passChRes.innerHTML = AjaxRQ('GET','index.php?get=chpassw'+data,null);
	 form.pass1.value = '';
	 form.pass2.value = '';
	}else{
	 passChRes.innerHTML = '<span class="red">Не совпадают пароль и подтверждение, либо не установлен флаг смены пароля!</span>';
	}
 }catch(e){
  passChRes.innerHTML = 'some error happends...';
 }
 
 return false;
}

function findPosX(obj){
    var curleft = 0;
    if (obj.offsetParent){
        while (obj.offsetParent){
            curleft += obj.offsetLeft;
            obj = obj.offsetParent;
        }                   
    }
    else if (obj.x) curleft += obj.x;
    return curleft;
}

function findPosY(obj){
    var curtop = 0;    
    if (obj.offsetParent){
        while (obj.offsetParent){
            curtop += obj.offsetTop;
            obj = obj.offsetParent;
        }
    }
    else if (obj.y) curtop += obj.y;
    return curtop;
}

function openVC(id){
 window.open('index.php?get=vcard&vc='+id,'_blank','location=no,menubar=no,resizable=no,toolbar=no,statusbar=no,height=420,width=250');
 return false;
}


var t,t2,obj,op;
var cm;		// для отображения процентов

function appear(x)   // x - конечное значение прозрачности
{

  obj = document.getElementById("greybar"); 
	op = x;//(obj.style.opacity)?parseFloat(obj.style.opacity):parseInt(obj.style.filter)/100;
	obj.style.opacity = op;
	obj.style.filter='alpha(opacity='+op*100+')';
  obj.style.display = "block";
/*  	
	if(op < x) {
		clearTimeout(t2);
		op += 0.25;
		//cm.innerHTML = Math.round(op*10)/10*100+'%'; // отображение процентов
		obj.style.opacity = op;
		obj.style.filter='alpha(opacity='+op*100+')';
		t=setTimeout('appear('+x+')',5);
	}else{
*/  
   obj = document.getElementById("greycontentparent");
   obj.style.display = "block";

   obj = document.getElementById("greycontent");
   obj.style.display = "block";
//  } 

/*  
  if( op < 0.1){
   obj.style.display = "none";

   obj = document.getElementById("greycontent");
   obj.style.display = "none";
   obj = document.getElementById("greycontentparent");
   obj.style.display = "none";
   
  }
*/ 
}

function disappear(x) {
  obj = document.getElementById("greycontent");
  obj.style.display = "none";
  obj = document.getElementById("greycontentparent");
  obj.style.display = "none";
 
	obj = document.getElementById("greybar");
	//op = (obj.style.opacity)?parseFloat(obj.style.opacity):parseInt(obj.style.filter)/100;
  
/*  
	if(op > x) {
		clearTimeout(t);
		op -= 0.15;
		//cm.innerHTML = Math.round(op*10)/10*100+'%'; // отображение процентов
		obj.style.opacity = op;
		obj.style.filter='alpha(opacity='+op*100+')';
		t2=setTimeout('disappear('+x+')',5);
	}
  if( op < 0.1){
*/
   obj.style.display = "none";
//  } 
}

function showProduct(art){
  obj = document.getElementById("greycontent");
  src = "./index.php?info&art="+URLEncode(art);

  obj.innerHTML = AjaxRQ("GET", src, null );

}

function showImage(url){
 
}
