var Storage = {
	container: false
}

//window.addEvent('domready', function(){
	//tooltip();
//});

function tooltip()
{
	var Tips2 = new Tips($$('.tips'));
	var Tip = new Tips($$('.skype'));
}

function injectMapFilter()
{
	if(jQuery('#mp').attr('src') != jQuery('#mp').attr('longdesc'))
	{
		jQuery('#mp').attr('src',jQuery('#mp').attr('longdesc'));
	}
}

jQuery(document).ready(function() {
	tooltip();
	
	if(Cookie.get('jobMap') !== 'show')
	{
		injectMapFilter();
		jQuery('#mmp').slideDown('slow').fadeIn('slow');
	}
	
	var $mt = jQuery('#mapToggler');
	$mt.click(function(){
		
		if($mt.attr('title') == 'hide')
		{
			$mt.attr('title','show').html('&#187; show map filter');
			jQuery('#mmp').slideUp('slow');
			
			Cookie.create('jobMap','show');
			pageTracker._trackPageview('/filter/jobmap/hide');
		}
		else
		{
			$mt.attr('title','hide').html('&#187; hide map filter');
			jQuery('#mmp').slideDown('slow',function(){
				injectMapFilter();
			});
			
			Cookie.create('jobMap','hide');
			pageTracker._trackPageview('/filter/jobmap/show');
		}
			
		return false;
	});
	
	I1 = new Image();
	I1.src = '/images/menu/long_bg_on.png';
	
	I2 = new Image();
	I2.src = '/images/menu/long_bg_clicked.png';
	
	I3 = new Image();
	I3.src = '/images/menu/small_bg_on.png';
	
	I4 = new Image();
	I4.src = '/images/menu/small_bg_clicked.png';
	
	I5 = new Image();
	I5.src = '/images/menu/saved-job_off.png';
	
	I6 = new Image();
	I6.src = '/images/menu/unapply_off.png';
	
	if(!jQuery.browser.msie)
	{
		jQuery('.res_menu').animate({
			opacity:0.1
		}, 100, function(){
			jQuery(this).animate({
				opacity:1
			}, 700);
		});
	}
	
	jQuery(document).bind('click',function(event){
        if(window.prevActionsId && !event.target.className && event.target.className != 'actions' && event.target.className != 'at')
        {
    		jQuery('#'+window.prevActionsId+' > .actions').attr('title','show');
    		jQuery('#'+window.prevActionsId+' > ul').slideUp('fast');
    		jQuery('#'+window.prevActionsId+' > .actions').html('options▼');
        }
	});
	
	
	jQuerysmall_buttons = jQuery('.b > a:not(.long)');
	jQuerysmall_buttons.live('mousedown',function(){jQuery(this).css({background:'url(/images/menu/small_bg_clicked.png)'});});
	jQuerysmall_buttons.live('mouseup',function(){jQuery(this).css({background:'url(/images/menu/small_bg_on.png)'});});
	jQuerysmall_buttons.live('mouseout',function(){jQuery(this).css({background:'url(/images/menu/small_bg_off.png)'});});
	jQuerysmall_buttons.live('mouseover',function(){jQuery(this).css({background:'url(/images/menu/small_bg_on.png)'});});
	
	jQuerysmall_buttons = jQuery('.b > a.long');
	jQuerysmall_buttons.live('mousedown',function(){jQuery(this).css({background:'url(/images/menu/long_bg_clicked.png)'});});
	jQuerysmall_buttons.live('mouseup',function(){jQuery(this).css({background:'url(/images/menu/long_bg_on.png)'});});
	jQuerysmall_buttons.live('mouseout',function(){jQuery(this).css({background:'url(/images/menu/long_bg_off.png)'});});
	jQuerysmall_buttons.live('mouseover',function(){jQuery(this).css({background:'url(/images/menu/long_bg_on.png)'});});

	actionsMenu();
	
	jQuery(".more").click(function () {    
		if(this.title=="more")
		{
			this.title="less";
			jQuery("#"+this.id+"_more").slideDown("slow",function(){
				jQuery("#"+this.id.replace(/_more/,"")).html("▲");
				jQuery("#"+this.id.replace(/_more/,"")+"_dd").css("background","#333333");
			});		   		
		}
		else
		{
			this.title="more";
										
			jQuery("#"+this.id+"_more").slideUp("slow",function(){
				jQuery("#"+this.id.replace(/_more/,"")).html("▼");
			});
							
			jQuery("#"+this.id+"_dd").css("background","url(/images/more_bg.gif)");
								
		}     	
	});
	
	jQuery('.detweet_button').live('mouseover',function(){
		jQuery(this).attr('src','/images/closeButton.png');
	});
	
	jQuery('.detweet_button').live('mouseout',function(){
		jQuery(this).attr('src','/images/closeButtonActive.png');
	});
	
	jQuery('.detweet_button').live('click',function(){
		detweet_box = '<div class="detweet_cont">'+
		'<a href="javascript:void(0)" onclick="SimpleBox.close(function(id){Refine.notForMe(id)},\''+jQuery(this).attr('id').replace('detweet_','')+'\')">Not for me</a>'+
		'<a href="javascript:void(0)" onclick="SimpleBox.close(function(id){Refine.notJob(id)},\''+jQuery(this).attr('id').replace('detweet_','')+'\')">Not a job</a>'+
		'<a href="javascript:void(0)" onclick="SimpleBox.close(function(id){Refine.notJob(id)},\''+jQuery(this).attr('id').replace('detweet_','')+'\')">Job Expired</a>'+
		'<a href="javascript:void(0)" onclick="SimpleBox.close(function(account){Refine.blockAccount(account)},\''+jQuery(this).attr('alt')+'\')" class="last">Block Account</a>'+
		'<div class="clear"></div></div>';
		
		SimpleBox.open(detweet_box,{
			directInput:true,
			bodyCss:{'padding':'0px','color':'#333','background':'#fff','padding':'1px'},
			showCaption:true,
			captionText:'DeTweet this job',
			captionCss:{'color':'#fff'},
			closeImageCss:{'margin':'5px 5px 0 0','top':'5px','right':'-25px','behavior':'url(/css/iepngfix.htc)'},
			bodyWebKitRoundCorners:1,
			showCloseImage:true,
			defaultCloseImageSrc: '/js/SimpleBox/closeButtonRed.png',
			hoverCloseImageSrc: '/js/SimpleBox/closeButtonRedActive.png'
		});
	});
	
	jQuery('a.skype').live('click',function(){
		
		var detweet_box = '<div style="margin:10px;"><button style="font-weight:bold;padding:5px;" id="skypeme">I am qualified for this job and want recruiters to call me via Skype. </button></div>';
		
		var $this = jQuery(this);
		
		SimpleBox.open(detweet_box,{
			directInput:true,
			bodyCss:{'padding':'0px','color':'#333','background':'#fff','padding':'1px'},
			showCaption:true,
			captionText:'Skype me',
			captionCss:{'color':'#fff'},
			closeImageCss:{'margin':'5px 5px 0 0','top':'5px','right':'-25px','behavior':'url(/css/iepngfix.htc)'},
			bodyWebKitRoundCorners:4,
			showCloseImage:true,
			defaultCloseImageSrc: '/js/SimpleBox/closeButtonRed.png',
			hoverCloseImageSrc: '/js/SimpleBox/closeButtonRedActive.png'
		});
		
		jQuery('#skypeme').click(function(){
			if(window.user && window.user_skype)
			{
				SimpleBox.close();
				var data = 'id='+$this.attr('rel');
				data += '&result_type='+$this.attr('type');
				data += '&display_type=public';
				data += '&is_prv=0';
		
				if(!iCan.__processing) 
				{
					iCan.__processing = true;
					msg.loader('Sending request...');
					jQuery.post('/user/i-can-do-that',data,iCan.applyHandler,'json');
				}
			}
			else
				top.location = '/user/login/?j='+$this.attr('rel')+'&a=i&r='+$this.attr('type')+'&d=public&s=1';
		});
		
		return false;
	});  
});