function saveStoreOpenId()
{
  var  sCustom = $j("#openid_text").val().replace(/^\s+|\s+$/g, '');
  sUrl = "custom="+encodeURIComponent(sCustom); 
  $j.ajax({          
        url: '/settings/saveOpenId?'+sUrl,
        cache: false,          
        success: function(html){
        $j("#saveMessage").html(html);                   
        }
  });   
}

function clickOpenId()
{
	  $j.ajax({ 
                url: '/openid/index', 
                cache: false, 
                success: function(html){  
						                $j('#openidDiv') .html(html);         
						                
						              $j.blockUI({ message: $j('#openidDiv') ,
						              css: { 
						                  padding:          '1px',
						                  margin:              0,
						                  width:               '350px', 
						                  top:                    '20%', 
						                  left:                   '35%', 
						                  textAlign:          '', 
						                  color:                '#000', 
						                  border:             '2px solid #FF9933',
						                  backgroundColor:  'white',
						                  cursor:               'default'
						              }
						            
						    });
						    /*JQUERY HOVER EFFECT*/
						     $j("#clickHere").click(function () {
       //                $j("#openidAuthenticate").toggle();		
                  });
						       
						        $j('#openIdClose').hover(function() {
						          $j(this).attr("src","/images/icon_close1.gif");
						          }, function() {
						        $j(this).attr("src","/images/icon_close0.gif");
						      } ); 
						      
						       $j('#loginOpenidUI').hover(function() {
                      $j(this).attr("src","/images/bu_login_o.gif");
                      }, function() {
                    $j(this).attr("src","/images/bu_login.gif");
                  } );	  
						  $j('#openIdClose').click($j.unblockUI); 
					 }
        });
}

function hUserAuth()
{	
	if ($j('#openidAuthenticate').is(':visible')) 
	{
		$j('#openidAuthenticate').css("display","none")
		$j('#huserStatus').attr('checked', false);	
	}  
  else 
  {   
   $j('#huserStatus').attr('checked', true);
   $j('#openidAuthenticate').css("display","block")   
  }
}

function openIdAuth()
{
	
	var hUsername=$j("#hUsername").val().replace(/^\s+|\s+$/g, '');
  var hPassword=$j("#hPassword").val().replace(/^\s+|\s+$/g, '');
  var hOpenId=$j("#openid").val().replace(/^\s+|\s+$/g, '');
 
if(document.getElementById("huserStatus").checked)
    var hUser="on";
  else
    var hUser="off";
    
  
  if(hOpenId== "")
  {
    alert("OpenId url cannot be blank");
    $j("#openid").focus();
    return false;
  }  
   else if ( hUser=='on' )         // else if ( $j('#openidAuthenticate').is(':visible') )      
   {      
      if(hUsername== "")
		    {
		      alert("Username cannot be blank");
		      $j("#hUsername").focus();		      
		      return false;
		    }
		    else if(hPassword== "")
		    {
		      alert("Password cannot be blank");
		      $j("#hPassword").focus();
		      return false;
		    }
   }
   
     $j.ajax({ 
                url:'/openid/openIdAuth?username='+hUsername+'&password='+hPassword+'&openid='+hOpenId+"&huser="+hUser,                
                cache: false,                       
                success: function(html){      
                	if(html!="")
                	{               
                    $j('#openidMessage').html(html);
                    return;
                	}
                  document.getElementById("openidForm").submit();
                 //$j("#openidForm").submit();       
                                     
                }            
            });  
}

