/**
 * @author peter.yakovlev
 */



function DeviceScreenResize()
{
	
//showQuickDial();
// Device screen height adjust
  var frame = document.getElementById("device-screen");  
  var htmlheight = document.body.parentNode.scrollHeight;  
  var windowheight = window.innerHeight;  
  frame.style.height = htmlheight-70-275 + "px";   /* HTML height - header height - footer height */
  
  
  if (document.getElementById('cv-upload-widget-container') != null) { 
    
    
    // stretching CV upload input field
    //document.getElementById("cv-upload-file-field").style.width = document.getElementById("cv-upload-widget-container").offsetWidth-125 + "px";
    /*
    var containerWidth = document.getElementById('cv-upload-widget-container').offsetWidth;
    var IE7Delta = 0;
    if (navigator.appVersion.indexOf('MSIE 7') !== -1) { 
      IE7Delta = 20; };            
    document.getElementById('FileNameContainer').style.width = containerWidth - 119 - IE7Delta + "px";
    document.getElementById('FileName').style.width = containerWidth - 114 - IE7Delta + "px";
    */
   
   
    // 119-114 = FileName left margin // Lazy me  :-P.
  }
  
  // Quick Dial positioning
  var quick_dial_container = document.getElementById("quick-dial-container");
  var delta = parseInt(frame.style.height); 
  quick_dial_container.style.top = 55 + "px"; // at some point become unnecessary
}

function showQuickDial() {
  // alert('OLOLO');
	 var quick_dial_container = document.getElementById("quick-dial-container");
	 var quickdial_bg = document.getElementById("quickdial-bg");
	
	 
	if (quick_dial_container.className=='invisible') {
		
		quick_dial_container.className='visible';
		quickdial_bg.className='nav-menu-quickdial-pressed';
	}
	else {
		quick_dial_container.className='invisible';
		quickdial_bg.className='nav-menu-quickdial-normal';
	} 
}

function  QuickDialPress(idpart) {
	var target = document.getElementById("quick-dial-"+idpart);
	
}


//////////////////////////////////////////////
// CV upload widget: file input costomization  ///
//////////////////////////////////////////////

function InputChanged() {
              
    fileInput = document.getElementById('File1');

    file = fileInput.value;
 
    var sp = file.lastIndexOf("\\");
    var file1 = file.substring(sp+1);
      
    document.getElementById('FileName').innerHTML = file1;
    
    //reWin = /.*(.*)/;
    //var fileTitle = file.replace(reWin, "$1"); //выдираем название файла для windows
    //reUnix = /.*/(.*)/;
    //fileTitle = fileTitle.replace(reUnix, "$1"); //выдираем название файла для unix-систем
    //fileName.innerHTML = fileTitle;

};


/* fake input "Browse" button hover. ToDo. PY.
function MakeActive() {
    activeButton.style.display = 'block';
};

function UnMakeActive() {
    activeButton.style.display = 'none';
};
*/
  
  // cross-browser OnLoad
  function init() {
      if (arguments.callee.done) return;
      arguments.callee.done = true;
      
      /////////   my onload code  //////////
      // disabled temporary until fully crossbrowser replacement of file input is done. (PY)
        if (document.getElementById('cv-upload-widget-container') != null) { 

            // real file input operations
            var fileInput = document.getElementById('File1');
            fileInput.value = '';
            
            // not implemented yet... 
            /*fileInput.onmouseover = MakeActive; 
            fileInput.onmouseout = UnMakeActive;*/
           
            fileInput.className = 'customFile';
            
            var wrap = document.getElementById('fake-input-placeholder');
            wrap.innerHTML = '<table cellpadding="0" cellspacing="0" border="0" width="100%" height="30"><tr><td valign="top" id="cv-upload-widget-problem-td">' +
            '<div id="FileNameContainer"><div id="FileName"></div></div>' +
            '</td><td width="80">' +
            '<div class="fakeButton"><span style="margin:1px 0px 0px 18px; color:#e1dfd8; float: left;" class="cv-upload-widget-browsebtn">Обзор...</span></div>' +
            '</td></tr></table>';
  
  /*
            // creating fake input field
            var fileNameContainer = document.createElement('div');
            fileNameContainer.setAttribute('id','FileNameContainer');
            wrap.appendChild(fileNameContainer);
            
            //creating fake input field text block
            var fileName = document.createElement('div');
            fileName.setAttribute('id','FileName');
            fileNameContainer.appendChild(fileName);
            
            // creating fake button
            var button = document.createElement('div');
            button.className = 'fakeButton';
            button.innerHTML = '<span style="margin:6px 0px 0px 18px; float: left;">Обзор...</span>';   
            wrap.appendChild(button);
  */
            
            // Submit replacement
            document.getElementById('uplbtn').style.display = 'none';
            document.getElementById('fakeSubmit').style.display = 'block';
            
            //alert ('replacement done');
        };
      
      ////// end onload code
  
  }
  
  // ff, opera
  if (document.addEventListener) {
      document.addEventListener("DOMContentLoaded", init, false);
  }
  
  // ie
  /*@cc_on @*/
  /*@if (@_win32)
  document.write("<script id=__ie_onload defer src=javascript:void(0)>");
  document.write("<\/script>");
  var script = document.getElementById("__ie_onload");
  script.onreadystatechange = function() {
      if (this.readyState == "complete") {
          init();
      }
  };
  /*@end @*/
  
  // safari
  if (/WebKit/i.test(navigator.userAgent)) {
      var _timer = setInterval(function() {
          if (/loaded|complete/.test(document.readyState)) {
              clearInterval(_timer);
              delete _timer;
              init();
          }
      }, 10);
  }
  
  // others
  window.onload = init;
  
  
  



  
///////////////////  END /////////////////////
// CV upload widget: file input costomization  ///
//////////////////////////////////////////////

