var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height){
  if(popUpWin)  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=0,location=0,directories=0,status=0,menubar=no,scrollbars=0,resizable=0,copyhistory=0,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
function openTerms(url){
	popUpWindow(url,'50%','50%','350px','255px');
}
function openThumnail(URLStr){
	var width = '990px';
	var height = '700px';
	var left = '0px';
	var top = '0px';
		
	popUpWin = open(URLStr, 'popUpWin', 'toolbar=0,location=0,directories=0,status=0,menubar=no,scrollbars=1,resizable=1,copyhistory=0,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}

jQuery(function(){
	jQuery('#fmLogin').submit(function(){
		var params = null;
		var options = {
			show_inline_loader_for:null,
			loading:false,
			callBefore:function(){
				jQuery('#login_btn_submit').addClass('btn_login_go_loading').blur();
			},
			callAfter:function(data){
				jQuery('#login_btn_submit').removeClass('btn_login_go_loading');
			}
		}
		return Goingup.Form.Submit(this,params,options);	
	});
	
	jQuery('a[href$=#sendpassword]').click(function(){
		var data = {
			msg_title:'Request Password',
			loader_class:'inline_loader',
			html:'<div>\
					<form id="fmLoginForm" action="/p/do/sendpassword/login.html" method="post">\
					<input type="hidden" name="dinamic" value="1"> \
				    <table >\
				    	<tr>\
				        	<td>\
				    	<label style="width:50px;">Email Address:</label>\
				        </td><td>\
				        <input type="text" name="email" value="" size="20" />\
				</td>\
				        </tr>\
				    </table>\
				    </form>\
				</div>',
			buttons:[
					{onclick:'Goingup.Dialog.Hide()',value:'Close','class':'ko'},
					{onclick:'Goingup.Dialog.OK()',value:'OK'}
				]
		}
		Goingup.Dialog.Show(data);	
		
	});
	
	jQuery("a[href$='#terms']").click(function(){
		openTerms(this.rel);
	});
	
	jQuery("a[href$='#viewfull']").click(function(){
		openThumnail(this.rel);
	});
	
	jQuery('a[href$=#login]').click(function(){
		var params = null;
		var options = {
			url:this.rel
		}
		return Goingup.Request(options);	
	});
	jQuery('.codebar').click(function(){
		this.select();
	});
});
