jQuery(document).ready(function(){
	oBrief = new Brief
	oBrief.init()
	oPreviews = new Previews
	oPreviews.init()
});

function Brief(){}

Brief.prototype = {
	init: function(){
		this.oBriefs = jQuery('.b-briefs .b-brief')
		this.oBriefs.removeClass('b-brief-show')
		jQuery(this.oBriefs.eq(Math.random() * 3)).addClass('b-brief-show')
	}
}

function Previews(){}

Previews.prototype = {
	init: function(){
		var $this = this;
		this.parent = jQuery('.b-previews')
		this.iphone = this.parent.find('.b-iphone')
		this.screen = this.iphone.find('.b-screen')
		this.close = this.iphone.find('.b-close a')
		this.underLayer = jQuery('.b-graystyle')
		
		
		this.previews = this.parent.find("ul li .preview a")
			.unbind("click")
			.click(function(evt){
				$this.showIphone()
				$this.screen.html(jQuery('.content', this.parentNode.parentNode).html())
				return false;
      })
		
		this.pluses = this.parent.find("ul li .open a")
			.unbind("click")
			.click(function(evt){
				$(this).parents("li").find(".preview a").click();
				return false;
      })
		
		this.close
			.unbind('click')
			.click(function(evt){
				$this.hideIphone()
				return false;
      })
	},
	showIphone:function(){
		this.iphone.addClass('b-iphone-show')
		this.underLayer.css({ opacity: 0.7 }).show();
	},
	hideIphone:function(){
		this.iphone.removeClass('b-iphone-show')
		this.underLayer.css({ opacity: 0.7 }).hide()
	}
}