jQuery(function($) {
	$('#gigya-socialize-update').submit(function(event) {
		event.preventDefault();
		if( $('#gigya-socialize-update-text').val() != '' ) {
			if( typeof( gigya ) != 'undefined' ) {
				gigya.services.socialize.setStatus(gsConf, {status:jQuery('#gigya-socialize-update-text').val()});
			}
			$('#gigya-socialize-update-text').val('What are you doing now?' );
		}
	});
	$('#gigya-socialize-update-text').click(function(event) {
		if( $(this).val() == 'What are you doing now?' ) {
			$(this).val('');
		}
	});
	$('#gigya-socialize-update-text').blur(function(event) {
		if( $(this).val() == '' ) {
			$(this).val('What are you doing now?' );
		}
	});
});


function processLogin(eventObject)
	    {

	    
            if (eventObject.user!=null && eventObject.user.isConnected)
            {
            
       	    jQuery('.gs-for-e107-login-widget').after('<div id=\"gs-for-e107-login-message-container\"><p id=\"gs-for-e107-login-message\" class=\"message\">Please wait &mdash; logging in...</p></div>'); 
      
     // if ( jQuery.cookie('gigyauth') == null ) {
      
      
     // var cockie_name = 'gigyauth';        
      var cockie_opt = { path: '/', expires: 10 };       
      var key_pairs =        
      'gigya-authenticate=' + 1 + 
			';gigya-timestamp=' + eventObject.timestamp + 
			';gigya-uid=' + eventObject.UID + 
			';gigya-signature=' + eventObject.signature + 
			';gigya-is-site-user=' + eventObject.user.isSiteUser + 
			';gigya-is-log-in-identity=' + eventObject.user.isLogInIdentity + 
			';gigya-is-connected=' + eventObject.user.isConnected + 
			';gigya-nickname=' + eventObject.user.nickname + 
			';gigya-login-provider=' + eventObject.user.loginProvider + 
			';gigya-photo-url=' + eventObject.user.photoURL + 
			';gigya-thumbnail-url=' + eventObject.user.thumbnailURL + 
			';gigya-first-name=' + eventObject.user.firstName + 
			';gigya-last-name=' + eventObject.user.lastName + 
			';gigya-gender=' + eventObject.user.gender + 
			';gigya-age=' + eventObject.user.age + 
			';gigya-birth-day=' + eventObject.user.birthDay + 
			';gigya-birth-month=' + eventObject.user.birthMonth + 
			';gigya-birth-year=' + eventObject.user.birthYear + 
			';gigya-email=' + eventObject.user.email + 
			';gigya-country=' + eventObject.user.country + 
			';gigya-state=' + eventObject.user.state + 
			';gigya-city=' + eventObject.user.city + 
			';gigya-zip=' + eventObject.user.zip + 
			';gigya-profile-url=' + eventObject.user.profileURL;         
      
     
      
      $.cookie('gigyauth', key_pairs, cockie_opt);
      
      setTimeout( 'window.location.reload( true );', 150 );
       
     // }
                  
     /*   jQuery.ajax({
                  type: 'POST',
                  url: gurl.loc() + 'gigya.php',
                  data: 
      'gigya-authenticate=' + 1 + 
			'&gigya-timestamp=' + eventObject.timestamp + 
			'&gigya-uid=' + eventObject.UID + 
			'&gigya-signature=' + eventObject.signature + 
			'&gigya-is-site-user=' + eventObject.user.isSiteUser + 
			'&gigya-is-log-in-identity=' + eventObject.user.isLogInIdentity + 
			'&gigya-is-connected=' + eventObject.user.isConnected + 
			'&gigya-nickname=' + eventObject.user.nickname + 
			'&gigya-login-provider=' + eventObject.user.loginProvider + 
			'&gigya-photo-url=' + eventObject.user.photoURL + 
			'&gigya-thumbnail-url=' + eventObject.user.thumbnailURL + 
			'&gigya-first-name=' + eventObject.user.firstName + 
			'&gigya-last-name=' + eventObject.user.lastName + 
			'&gigya-gender=' + eventObject.user.gender + 
			'&gigya-age=' + eventObject.user.age + 
			'&gigya-birth-day=' + eventObject.user.birthDay + 
			'&gigya-birth-month=' + eventObject.user.birthMonth + 
			'&gigya-birth-year=' + eventObject.user.birthYear + 
			'&gigya-email=' + eventObject.user.email + 
			'&gigya-country=' + eventObject.user.country + 
			'&gigya-state=' + eventObject.user.state + 
			'&gigya-city=' + eventObject.user.city + 
			'&gigya-zip=' + eventObject.user.zip + 
			'&gigya-profile-url=' + eventObject.user.profileURL, 
      //+ '&redirect-url=' + jQuery('#gs-for-e107-redirect-url').attr('href'),
			
                  complete: function(data, textStatus){
				jQuery('#gs-for-e107-login-message').html(data.responseText); 
					        
					        setTimeout( 'window.location.reload( true );', 150 );
					      
                  },
                  error: function(){
                  alert('Error occured during Ajax request...');
                    }
                  }); */
                  return false;
                 } 
               }; 
               


$.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};   