var popUp = new Class({
	initialize: function(obj, props) {
		this.left = 0;
		this.top = 0;

		for(var prop in props) this[prop] = props[prop];
		
		var coor = obj.getCoordinates();
		this.height = coor.height;
		this.width = coor.width;
		this.startHeight = this.height - (this.height / 15);
		this.startWidth = this.width - (this.width / 15);
		this.startTop = this.top - (this.height / 30);
		this.startLeft = this.left - (this.width / 30);
		
		var oParent = new Element("div", {
			styles: {
				position: 'absolute',
				overflow: 'hidden',
				top: this.startTop,
				left: this.startLeft,
				width: this.startWidth,
				height: this.startHeight,
				opacity: 0
			}
		});
		obj.setStyle('display', 'block');
		oParent.inject(document.body);
		oParent.adopt(obj);
		
		this.fx = new Fx.Styles(oParent, {
			duration: 500, 
			transition: Fx.Transitions.Quad.easeIn,
			wait: false
		});
		var me = this;
	},
	show: function() {
		this.fx.start({
			top: this.top,
			left: this.left,
			width: this.width,
			height: this.height,
			opacity: 1
		});
	},
	hide: function() {
		this.fx.start({
			top: this.startTop,
			left: this.startLeft,
			width: this.startWidth,
			height: this.startHeight,
			opacity: 0
		});
	}
});

var shadow = new Class({
	initialize: function(obj, props) {
		this.offsetLeft = 3;
		this.offsetTop = 3;
		this.percent = 70;
	
		for(var prop in props) this[prop] = props[prop];

		var coor = obj.getCoordinates();
		if(obj.getStyles('position') == "static") obj.setStyles({position: 'relative'});
		var sdw = obj.clone(true).injectBefore(obj);
		sdw.id = "";
		sdw.setStyles(
			this.applyShadow({
				'background-color': null,
				'border-left-color': null,
				'border-right-color': null,
				'border-top-color': null,
				'border-bottom-color': null,
				'color': null
			}, obj)
		);
		sdw.setStyles({
			'position': 'absolute',
			left: coor.left + this.offsetLeft,
			top: coor.top + this.offsetTop
		});
	},
	applyShadow: function(items, obj) {
		var newItem = {};
		for(var i in items) {
			try {
				var sColor = new Color(obj.getStyle(i));
				newItem[i] = sColor.mix('#ffffff', this.percent);
			} catch(e) {
			}
		}
		return newItem;
	}
});

function showCirBlink(x, y) {
	var cirBlink = $("cirblink");
	cirBlink.setStyles({left: x, top: y, display: 'block'});
}
function hideCirBlink() {
	$("cirblink").setStyle('display', 'none');
}
$(document).addEvent("domready", function() {
	var a = $("bookmark");
	if(a) {
		if (window.ie) {
			a.href = "javascript:window.external.addFavorite('<%=mDealflowUrl%>', 'Deal Flow Connection')";
		} else if(window.opera || window.gecko || window.webkit) {
			a.setAttribute("rel", "sidebar");
			a.setAttribute("href", "<%=mDealflowUrl%>");
			a.setAttribute("title", "Dealflow Connection");
		}
	}

	var entTip = new popUp($('enttips'), {left: 80, top: 60});
	var intTip = new popUp($('inttips'), {left: 80, top: 280});
	var sofTip = new popUp($('softips'), {left: 410, top: 160});
	
	$$("div[class=keylink]").each(function(item) {
		new shadow(item);
	});
	
	$("ent").addEvents({
		mouseenter: function() {
			showCirBlink(15, 190);
			entTip.show();
		},
		mouseleave: function() {
			hideCirBlink();
			entTip.hide();
		},
		click: function() {
			window.location = "main/benefits_for_entrepreneurs.asp";
		}
	});
	$("int").addEvents({
		mouseenter: function() {
			showCirBlink(20, 400);
			intTip.show();
		},
		mouseleave: function() {
			hideCirBlink();
			intTip.hide();
		},
		click: function() {
			window.location = "main/benefits_for_intermediaries.asp";
		}
	});
	$("sof").addEvents({
		mouseenter: function() {
			showCirBlink(610, 70);
			sofTip.show();
		},
		mouseleave: function() {
			hideCirBlink();
			sofTip.hide();
		},
		click: function() {
			window.location = "main/benefits_for_sources.asp";
		}
	});
	$("log").addEvents({
		click: function() {
			window.location = "../admin/adminlogin.asp";
		}
	});
});