jQuery(document).ready(function() { 
   jQuery('.ShowSignIn').click(function(e) {
		 
       e.preventDefault();
	   jQuery('#popup_signin').modal( { containerCss:{width:'220px',height:'200px',top:'22px',left:'350px',padding:'20px 23px 10px 25px',border:'#cccccc 1px solid' }, overlayClose:true});

   }); 
});

//document.onkeypress=keyPr; //function if press key anywhere in the window

/*
if (navigator.appName == 'Netscape') {
	window.captureEvents(Event.KEYPRESS);
	window.onKeyPress = keyPr;
}
*/

function html_remind_pass( ){
   html1='<u>Забыли пароль?</u> Пожалуйста, введите Ваш логин или адрес электронной почты:<input type="text" name="login_to_remind_password" value="" onKeyPress ="if (event.keyCode == 13) remind_pass();"/><input type="submit" value="OK" onclick="javascript:remind_pass();" />';
   jQuery.modal( html1 , { closeHTML:"<a title='Close' class='modalCloseX simplemodal-close' style='cursor:pointer;'><img src='"+HTTP_HOST+"images/x.png'></a>", containerCss:{ backgroundColor:"#fff", borderColor:"#fff", height:200, padding:0, width:250 }, overlayClose:true}); 
}

function remind_pass( ){
   varPOST = {};
   varPOST['remind_password'] = jQuery('input[name=login_to_remind_password]').attr("value");
   
   jQuery.ajax({
//    async:false,
	  type: 'post',
	  dataType: 'json',
	  url: HTTP_HOST_S+'api_smarty.php?json=yes&callback=?',
	  data: varPOST,
	  success: function(AllData){
         jQuery.modal.close();
         jQuery.modal( AllData['remind_password'] , { closeHTML:"<a title='Close' class='modalCloseImg' style='cursor:pointer;'><img src='"+HTTP_HOST+"images/x.png'></a>", containerCss:{ backgroundColor:"#fff", borderColor:"#fff", height:200, padding:0, width:250 }, overlayClose:true}); 
	  }
   });
}

function login( type ) {

if('http://'+location.host != HTTP_HOS){  // проверка fege.com.ua

  jQuery.modal.close();
  jQuery.modal('Вы будете перенаправленны на главный домен '+HTTP_HOST+', на котором нужно повторить процедуру авторизации.' , { closeHTML:"<a title='Close' class='modalCloseImg' style='cursor:pointer;'><img src='"+HTTP_HOST+"images/x.png'></a>", containerCss:{ backgroundColor:"#fff", borderColor:"#fff", height:140, padding:0, width:170 }, overlayClose:true});
  setTimeout( function() {
    window.location = HTTP_HOS;
  },5000); // half seconds
} else { // проверка fege.com.ua

   varPOST = {};
   varPOST['enter_login'] = 1;
   varPOST['productID'] = jQuery('input[name=productID]').attr("value");
   varPOST['categoryID'] = jQuery('input[name=categoryID]').attr("value");
   varPOST['login'] = jQuery('input[name=login_'+type+']').attr("value");
   varPOST['pass'] = jQuery('input[name=pass_'+type+']').attr("value");


   jQuery.ajax({
//    async:false,
	  type: 'post',
	  dataType: 'json',
	  url: HTTP_HOST_S+'api_smarty.php?json=yes&callback=?',
	  data: varPOST,
      beforeSend: function(a){
         jQuery.modal.close(); 
		 jQuery.modal("<div><h3>Вход на сайт под Вашим логином...</h3></div>", { closeHTML:"<a title='Close' class='modalCloseImg' style='cursor:pointer;'><img src='"+HTTP_HOST+"images/x.png'></a>", containerCss:{ backgroundColor:"#fff", borderColor:"#fff", height:100, padding:0, width:130 }, overlayClose:true}); 
      },
	  success: function(AllData){
         jQuery.modal.close();
		 if( AllData['enter_login']=='no') m_text='Неверный логин или пароль!';
		 if( AllData['enter_login'] == 'ok' ) m_text='Пара логин-пароль верна.';
		 if( AllData['enter_login'] == 'REGCONFIRMATION' ) m_text='Учетная запись не активированна.';
		 
         jQuery.modal( m_text , { closeHTML:"<a title='Close' class='modalCloseImg' style='cursor:pointer;'><img src='"+HTTP_HOST+"images/x.png'></a>", containerCss:{ backgroundColor:"#fff", borderColor:"#fff", height:100, padding:0, width:130 }, overlayClose:true}); 
                  
         setTimeout( function() {
            if( AllData['enter_login'] == 'ok' || AllData['enter_login'] == 'no' ) window.location = location;
			
            if( AllData['enter_login'] == 'REGCONFIRMATION' ){
               window.location = HTTP_HOST_S+'activation/'+jQuery('input[name=login_'+type+']').attr("value");
            } else {
               jQuery.modal.close();
            }
         },5000); // half seconds
	  }
   });

} // проверка fege.com.ua
}

function logout() {

	varPOST = {};
	varPOST['logout'] = 'yes';
		
	jQuery.ajax({
//		async:false,
		type: 'post',
//		dataType: 'json',
		url: HTTP_HOST_S,
		data: varPOST,
	       beforeSend: function(a){
                  jQuery.modal.close(); 
		  jQuery.modal("<div><h3>Выход из Вашей учетной записи...</h3></div>", { closeHTML:"<a title='Close' class='modalCloseImg' style='cursor:pointer;'><img src='"+HTTP_HOST+"images/x.png'></a>", containerCss:{ backgroundColor:"#fff", borderColor:"#fff", height:100, padding:0, width:130 }, overlayClose:true}); 
	       },
		success: function(AllData){  
			window.location = location;
		}
	});

}


