var myOverlay = function(obj) {
	
	this.mask ={color: '#cccccc',loadSpeed: 200,opacity: 0.7};
	this.defaultstyleobj={height:150,width:400,background:'#ffffff'};
	this.styleobj={};
	this.overrideclass = false;
	this.overridecontent = false;
 	this.init(obj);
 }
myOverlay.prototype.init = function(obj){
	this.elementID = obj.elementID;
	this.analytics = obj.analytics;
	
	
	// style details
	this.className = obj.style.classname;
	if(obj.style.overrideclass && obj.style.overrideclass==1)
		this.overrideclass = true;
	if(this.overrideclass)
	{
		if(	obj.style.height)
			this.styleobj.height = obj.height;
			
		if( obj.style.width)
			this.styleobj.width = obj.width;
			
		if( obj.style.backgroundcolor)
			this.styleobj.backgroundColor  = obj.style.backgroundcolor;
			
	}
	
	if(obj.content.overridecontent && obj.content.overridecontent==1)
		this.overridecontent = true;
		
	if(!this.overridecontent)
	{
		
		if(typeof(obj.content.contentID) !== 'undefined' && obj.content.contentID.length > 0) 
			var _loadurl= obj.content.pageurl + ' #' + obj.content.contentID;
		else
			var _loadurl= obj.content.pageurl;
	
		this.loadFile(_loadurl);
	}
	else
	{
		this.loadContent(obj.content.content);
	}
	jQuery("#dOverlayContent").css(this.defaultstyleobj);
	jQuery("#dOverlayContent").addClass(this.className);
	if(this.overrideclass)
	{
		jQuery("#dOverlayContent").css(obj.style);
	}
	this.show();
	
}

myOverlay.prototype.show = function(){
	var ele = jQuery("#"+this.elementID);
	jQuery(ele).overlay(	{	
					mask: this.mask,
					load: true,top: 'center',
					onBeforeLoad:function()
					{
						/*
						jQuery('body').mousewheel(function(event) {
     							event.preventDefault();
							});*/
						
						},
					onClose: function()
					{
						/*document.attachEvent('onmousewheel', function(event){
											 event.returnValue = true;
											}, false);*/
					}
				})
	this.track();
}

myOverlay.prototype.loadFile = function(_url)
{
	jQuery('#dOverlayContent').load(_url);
	}
	
myOverlay.prototype.loadContent = function(_content)
{
	jQuery('#dOverlayContent').html(_content);
	}
myOverlay.prototype.track = function()
{
	var _contentType='Overlay'
	var _title='Default';
	var _analytics= this.analytics;
	if(_analytics.ga_contentType !='')
		_contentType =_contentType + '_'+ _analytics.ga_contenttype;
		
	if(_analytics.ga_title !='')
		_title =_analytics.title;
		
	pageTracker._trackEvent('Content', _contentType,_title);	
	}

