if(Scraplr == undefined){
  var Scraplr = {};
} 

Scraplr.LoginObj ={
  postLoginData: function (){

  }
};

Scraplr.Observers = {
  domLoaded: function() {
    
    var parent = document.getElementsByTagName("html")[0];
    var strBrowser = Scraplr.UADetector.Browser.toLowerCase();  
    
    var strOS = Scraplr.UADetector.OS.toLowerCase();
    var strVersion = Scraplr.UADetector.Version;
    if((strBrowser == 'firefox')&&(strVersion =='3.5')){
       strVersion = '35';
       parent.className = strBrowser+strVersion +' '+strOS;
    }else{
      parent.className = strBrowser +' '+strOS+' '+strVersion;
    }

    if ((strBrowser == 'ie')||(strBrowser == 'opera')){
      $('browsersBox').show();
      $('loginBox').hide();
    }
    
    if (typeof window.innerWidth != 'undefined') {
      Scraplr.UI.viewportwidth = window.innerWidth;
      Scraplr.UI.viewportheight = window.innerHeight;
    }
    else if (typeof document.documentElement !== 'undefined' && typeof document.documentElement.clientWidth !== 'undefined' && document.documentElement.clientWidth !== 0) {
      Scraplr.UI.viewportwidth = document.documentElement.clientWidth;
      Scraplr.UI.viewportheight = document.documentElement.clientHeight;
    }
    else {
      Scraplr.UI.viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
      Scraplr.UI.viewportheight = document.getElementsByTagName('body')[0].clientHeight;
    }
    
    $('userDialog').setStyle('left:'+  Math.floor((Scraplr.UI.viewportwidth/2) - (440/2 )-10) + "px;");
    
    Scraplr.Utilities.disableRightClick(); 
    var strBuzzedCity = '', strBuzzedCountry = ''; 
    geofill.find(
      {
        callback:function(o){
          strBuzzedCity = o.city;
          strBuzzedCountry = o.country;
        }
      }
    );
    
    var parent = document.getElementsByTagName("html")[0];
    var strBrowser = Scraplr.UADetector.Browser.toLowerCase();
    var strOS = Scraplr.UADetector.OS.toLowerCase();
    var strVersion = Scraplr.UADetector.Version;
    if((strBrowser == 'firefox')&&(strVersion =='3.5')){
       strVersion = '35';
       parent.className = strBrowser+strVersion +' '+strOS;
    }else{
      parent.className = strBrowser +' '+strOS+' '+strVersion;
    }
 
    $('requestCodeButton').observe('click',function(event){
      var strEmail = $('requestMail').value;
      var emailIsValid = Scraplr.Utilities.isValidEmail(strEmail);    
      if(strEmail!=''){
        try{
          $('requestMail').removeClassName('loginInputBoxInvalid'); 
        }catch(ex){
          //
        }finally{
          if(emailIsValid){      	
            var strUrl = '../buzz.php?strEmail='+strEmail+'&strBuzzedCity='+strBuzzedCity+'&strBuzzedCountry='+strBuzzedCountry;
            new Ajax.Request(strUrl, {
              method: 'get',
              onCreate: function() {
                $('spinnerRequest').removeClassName('hidden');
              },
              onComplete: function(response) {
                $('spinnerRequest').addClassName('hidden'); 
                $('thanks').removeClassName('hidden');
                Scraplr.UI.showDialog ('alert', 'Thank you for your interest in scraplr','We will send you invite soon as we made it available',function (){
                }, function (){
                },true);
              }
            });     
          }else{
            Scraplr.UI.showDialog ('alert', 'Email address invalid','email should be in following format : name@domain.com',function (){
            }, function (){ 
              $('requestMail').focus();
            },true);
          }
        }  
      }else if(strEmail==''){	 
        $('requestMail').addClassName('loginInputBoxInvalid');
        $('requestMail').focus();
      }
    // end observe click
    });  
    
    new HotKey('enter',function(event){
      Scraplr.LoginObj.postLoginData();
  	});
       
    new Scraplr.InlineLabel('#formRequest');
    
    // do anything when DOM is loaded
  }
};        

document.observe('dom:loaded', Scraplr.Observers.domLoaded.bind(Scraplr.Observers)); 

