SIV.addHandlers({	
	loggingIn : function(success, data) {
		if (success) {
			$('#login-container').html(data.html);
			
		} else {
			
			$('#login-result').html(data.error);
			 
			
			$('#login-result').dialog({draggable:false,resizable:false, modal:true, bgiframe:true,buttons: { "Ok": function() { $(this).dialog("close"); } },close: function() { $(this).dialog("destroy") }, zindex:3999});
			
		}
	},
	loggingOut : function(success, data) {
		if (success) {
			document.location.href = '/';
			
		} 
	}
});


$(function() {
	
	$('#login-button').live('click',function(){
		//console.log($('#password').val());
		SIV.ajaxCall({
			url: '/members/login',
			handler: 'loggingIn',
			form: 'login-form',
			postData: {'email':$('#email').val()}
		});
	});
	
	$('#logout').live('click',function(){
	
		SIV.ajaxCall({
			url: '/members/logout',
			handler: 'loggingOut'
		});
		
	});
	
	 
	 $('.supplier-box[href][title]').qtip({
			content: {
         	text: false // Use each elements title attribute
      },
     
      style: {
    	  tip: 'topMiddle',
	      border: {
	         width: 5,
	         radius: 6,
	         color: '#302F37'
	      },
	      width: {  	
	    	  min: 	0,	
	    	  max:	120
	      },
	      background: '#5B5869',
	      color: '#ffffff'
      },

        position: {
            corner: {
                target: 'bottomMiddle',
                tooltip: 'topMiddle'
            }
        }
// Give it some style

	 })
	
	/*$('#uk-comments').jcarousel({
	        vertical: true,
	        size:2000,
	        auto: 2,
	        wrap: 'last'
	    });*/

  scroller();
  setTimeout("scroller2()",5500);
		
});

function scroller(){
	var id=1;
	setInterval(function(){
	
		$('#uk-box').scrollTo('#uk-comment-'  + id,3000);
		/*id++;
		if(id == DataBridge.ukitems){
			id=1
		}else{*/
			
			id++;
			if(id == DataBridge.ukitems) id=1
		/*}*/
		
	},11000);
}
function scroller2(){
	var id2=1;
	setInterval(function(){
		
		$('#overseas-box').scrollTo('#overseas-comment-'  + id2,3000);
		id2++;
		
		if(id2 == DataBridge.overseasitems) id2=1
	},11000);
}


