 function AdminVisualOn(idStr){
  document.getElementById(idStr).style.border='dashed 1px gray';
 }
 function AdminVisualOff(idStr){
  document.getElementById(idStr).style.border='dashed 1px white';
 }

function ShowUploadForm(){
  document.getElementById('blockAboutAddPhoto').style.display='block';
  document.getElementById('blockAboutAddPhoto').style.top=(getWindowDims().h/4)+'px';
  document.getElementById('blockAboutAddPhoto').style.right=(getWindowDims().w/4)+'px';
 
  
 
}

function onFinal(val1)
{
  if (val1==1) 
  {
    document.getElementById('blockMiddlePhoto').innerHTML='';
  }
}

 //Ajax



 var trans = [];
for (var i = 0x410; i <= 0x44F; i++)
 trans[i] = i - 0x350; 
trans[0x401] = 0xA8;    
trans[0x451] = 0xB8;    

var escapeOrig = window.escape;
window.escape = function(str)
{
  var ret = [];
  for (var i = 0; i < str.length; i++)
  {
    var n = str.charCodeAt(i);
    if (typeof trans[n] != 'undefined')
      n = trans[n];
    if (n <= 0xFF)
      ret.push(n);
  }
  return escapeOrig(String.fromCharCode.apply(null, ret));
}
 
 function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfY;
}

function getWindowDims(){
  if (window.innerWidth){
    return {w:window.innerWidth, h:window.innerHeight};
  }
  if (document.documentElement && document.documentElement.clientWidth){
    return {w:document.documentElement.clientWidth, h:document.documentElement.cliendHeight};
  }
  if (document.body){
    return {w:document.body.clientWidth, h:document.body.clientHeight};
  }
  return {w:0, h:0}
}



//----------------------------------------------
// Предварительная загрузка изображений
var imgs = document.images;
function preLoad() {
if (imgs) { var count = imgs.length; }
else { var count=0; }
var i=0;
for (i=0; i<count; i++) {
if (imgs[i].name!='') {
imgs[imgs[i].name+'_over'] = new Image(imgs[i].height,imgs[i].width);
imgs[imgs[i].name+'_over'].src=imgs[imgs[i].name].src.replace(/\.(.*?)$/,"_over.$1");
}
}
}
function on(pic) {
pic.src=imgs[pic.name+'_over'].src;
}
function off(pic) {
pic.src=pic.src.replace(/_over.(.*?)$/i,".$1");
}

//----------------------------------------------

function gN(name,n) {
	sum=0;
	 for(i=1;i<n;i++)
 { 
  var elem=document.getElementById(name+i);
  if(elem.checked)sum=sum+parseInt(elem.value);
 }
 return sum;
}

 function doLoad(aValue,anchor,script,ff,rd,aFile) {

    document.getElementById('label_save').style.visibility='visible';
	document.getElementById('label_save').style.left='0px';
	document.getElementById('label_save').style.top=getScrollXY()+'px';




    // Create new JsHttpRequest object.
    var req = new JsHttpRequest();
    // Code automatically called on load finishing.
    req.onreadystatechange = function() {
        if (req.readyState == 4) {

        if (req.responseJS.errcode!=0) {
          document.getElementById('outerrmsg').innerHTML=req.responseJS.message;
          document.getElementById('error').style.visibility='visible';
        }


      else
      {
		document.getElementById('label_save').style.visibility='hidden';
        if (anchor!=null) {
                document.getElementById(anchor).innerHTML = req.responseText;
                
                
            if (ff!=null) {
                
 
                 
                 document.getElementById(ff).focus();
                 document.getElementById(ff).focus();
                 
             }
             

        }

        if (req.responseJS.focusid!=null) {


          document.getElementById(req.responseJS.focusid).focus();
        }

         if (rd!=null){
             window.location.href ='./';
           }
      }

        }
    }
    // Prepare request object (automatically choose GET or POST).
    req.open(null, script, true);
    // Send data to backend.
    req.send( { val: aValue,e: aFile } );
   
  
}
