function OpenImagePopup(imgPath, title, alt) {
    var win = window.open('','preview',
    'width=50,height=50,left=0,top=0,screenX=0,screenY=0,resizable=1,scrollbar=0,status=0');
    
    var winDoc = win.document;
    if (title == undefined) title = 'My Image, Click to Close';
    if (alt   == undefined) alt   = 'My Image, Click to Close';
    var content = '<html><head><title>' + title + '</title>' +
    			  '<style>body{overflow: hidden;margin:0;}img{border:0;}</style>' +
    			  '</head><body><a href="javascript:self.close()">' +
    			  '<img alt="' + alt + '" id="image" src="' + imgPath + '" /></a></body></html>'
    win.document.write(content);
    
    winDoc.body.onload = function() {
    	var obj = winDoc.getElementById('image');
    	var w = obj.width, h = obj.height;
    	var iHeight= document.body.clientHeight, iWidth = self.innerWidth;
    	
    	var left = (self.opera ? iWidth : screen.availWidth)/2 - w/2;
    	var top =  (self.opera ? iHeight : screen.availHeight)/2 - h/2;
    	win.resizeTo(w+10, h+80);
    	win.moveTo(left, top);
    }
    
    win.onload = winDoc.body.onload; // special for Mozilla
    
    // !!! Very important statement: popup onload won't execute without it!
    win.document.close();
    win.focus();
}    

function form_auth_submit(){
        f1 = document.authLeftForm; 
        if ((f1.target_path.selectedIndex==2)||(f1.target_path.selectedIndex==3)){
			if (f1.target_path.selectedIndex==2){
				textalert = validphone(f1.smplnumber.value);
				if(textalert == ''){
					path="http://"+f1.smplnumber.value+".pbx.rosnet.ru/";
				} else {
					alert(textalert);
                     return false;
				}
		    } 
			if (f1.target_path.selectedIndex==3){
				//textalert = validphone(f1.smplnumber.value);
				//if(textalert == ''){
					path="http://phone.rosnet.ru/";
				//} else {
					//alert(textalert);
                 //    return false;
				//}
			}
                 
        }
        else {
                 path=f1.target_path[f1.target_path.selectedIndex].value;
        }
        //path=f1.target_path[f1.target_path.selectedIndex].value;
        //alert(path);
        //location.href = path;
        f1.action = path;
        f1.submit();
        return false;
}

function validphone(phone) { 
  len=phone.length;
  digits="0123456789";
  textalert = "";

  for(i=0; i<len; i++){
    if (digits.indexOf(phone.charAt(i))<0) {
         textalert = "Допустимы только цифры!";
         break;
    }
  }
  return textalert;
}



 function branchSwitch(id){
//     alert(id);
    switch (id){
	 case 2:
          document.getElementById(2).style.display = 'block';
		  document.getElementById(3).style.display = 'none';
          document.getElementById(0).style.display = 'none';
		  break;
      case 3:
		  document.getElementById(2).style.display = 'block';
		  document.getElementById(3).style.display = 'none';
          document.getElementById(0).style.display = 'none';
          break;
	  default:
         document.getElementById(0).style.display = 'block';	 
         document.getElementById(2).style.display = 'none';
		 document.getElementById(3).style.display = 'none';
	}
}

