var ljb=
(
	function() {
		var cookieTime = 2, //hour
			barCloseImg = 'http://creatives.livejasmin.com/awe_bottombar/images/close.png',
			bottomBarIframeUrl = 'http://promo.awempire.com/bottombar/index_bar.php?site='+site+'&flags='+flags+
				'&psid='+psid+'&pstool='+pstool+'&pstour='+pstour+'&psprogram='+psprogram+
				'&campaig_id='+campaign_id+
					((typeof cobrand_site_id != 'undefined')
						? '&cobrand_site_id='+cobrand_site_id
						: '') +
					((typeof bgcolor != 'undefined')
						? '&bgColor='+bgcolor
						: '')+
					((typeof textcolor1 != 'undefined')
						? '&textColor1='+textcolor1
						: '')+
					((typeof textcolor2 != 'undefined')
						? '&textColor2='+textcolor2
						: '')
			,
			chatIframeUrl = 'http://promo.awempire.com/bottombar/index_feed.php?site='+site+'&flags='+flags+
				'&psid='+psid+'&pstool='+pstool+'&pstour='+pstour+'&psprogram='+psprogram+
				'&campaig_id='+campaign_id+
					((typeof cobrand_site_id != 'undefined')
						? '&cobrand_site_id='+cobrand_site_id
						: '')+
					((typeof bgcolor != 'undefined')
						? '&bgColor='+bgcolor
						: '')+
					((typeof textcolor1 != 'undefined')
						? '&textColor1='+textcolor1
						: '')+
					((typeof textcolor2 != 'undefined')
						? '&textColor2='+textcolor2
						: '')
			,
			isIE6=(
				navigator.userAgent.indexOf('MSIE 6')!= -1
				&& typeof document.documentElement != 'undefined'
				&& typeof document.documentElement.clientHeight != 'undefined'
			),
			isIE=(
				navigator.userAgent.indexOf('MSIE') != -1
				&&
				document.compatMode == 'BackCompat'
			);

		if (isIE6) {
			return;
		}

		function createElement(elementType, definition, parentElementId) {
			var element=document.createElement(elementType);
			for(var def in definition) {
				if(def != 'style' && def != 'innerHTML') {
					element.setAttribute(def,definition[def]);
				}
			}

			if(definition.innerHTML) {
				element.innerHTML = definition['innerHTML'];
			}
			for(var def in definition['style']) {
				element.style[def]= definition.style[def];
			}

			if(typeof(parentElementId) != 'undefined') {
				document.getElementById(parentElementId).appendChild(element);
			}
			else {
				document.body.appendChild(element);
			}

			return element;
		}

		function windowMoveBottom() {
			if(isIE6&&!isIE){
				if(document.getElementById('bottomchat')) {
					document.getElementById('bottomchat').style.top =
							document.documentElement.clientHeight
							+ document.documentElement.scrollTop
							- document.getElementById('bottomchat').offsetHeight
							- 30;
				}
				if(document.getElementById('bottombar')) {
					document.getElementById('bottombar').style.top =
						document.documentElement.clientHeight
						+ document.documentElement.scrollTop
						- document.getElementById('bottombar').offsetHeight;
				}

				if(document.getElementById('bottomchat_close')) {
					document.getElementById('bottomchat_close').style.top =
							document.documentElement.clientHeight
							+ document.documentElement.scrollTop
							- document.getElementById('bottomchat_close').offsetHeight
							- 30;
				}
				if(document.getElementById('bottombar_close')) {
					document.getElementById('bottombar_close').style.top =
						document.documentElement.clientHeight
						+ document.documentElement.scrollTop
						- document.getElementById('bottombar_close').offsetHeight;
				}
			}
			else if(isIE) {
				if(document.getElementById('bottomchat')) {
					document.getElementById('bottomchat').style.top =
						document.body.clientHeight
						+ document.body.scrollTop
						- document.getElementById('bottomchat').offsetHeight
						- 30;
				}
				if(document.getElementById('bottombar')){
					document.getElementById('bottombar').style.top =
						document.body.clientHeight
						+ document.body.scrollTop
						- document.getElementById('bottombar').offsetHeight;
				}

				if(document.getElementById('bottomchat_close')) {
					document.getElementById('bottomchat_close').style.top =
						document.body.clientHeight
						+ document.body.scrollTop
						- document.getElementById('bottomchat').offsetHeight
						-30;
				}
				if(document.getElementById('bottombar_close')){
					document.getElementById('bottombar_close').style.top =
						document.body.clientHeight
						+ document.body.scrollTop
						- document.getElementById('bottombar_close').offsetHeight;
				}
			}
		}

		function readCookie(cookieName) {
			var str = cookieName + '=';
			var cookies = document.cookie.split(';');

			for (var i=0; i < cookies.length; i++) {
				var cookie=cookies[i];
				while (cookie.charAt(0)==' '){
					cookie=cookie.substring(1);
				}

				if(cookie.indexOf(str) === 0) {
					return cookie.substring(str.length);
				}
			}
			return null;
		}

		function writeCookie(name, value, expireHours){
			if(typeof(value) == 'undefined') {
				value = '1';
			}

			var expireString = '';
			if(typeof(expireHours) != 'undefined') {
				var date = new Date();
				date.setTime(date.getTime()+ (expireHours*60*60*1000) );
				expireString = '; expires=' + date.toGMTString();
			}
			document.cookie = name + '=' + value + expireString +'; path=/';
		}

		function createChatClose() {
			createElement('div',
					{
						'id': 'bottomchat_close',
						'style' :
						{
							'display': 'block',
							'width': '30px',
							'height': '30px',
							'margin': '0px',
							'zIndex': '9999',
							'position': ((isIE6||isIE) ? 'absolute' : 'fixed'),
							'bottom': '305px',
							'right': '0px'
						}
					}
				);

			createElement('a',
				{
					'id': 'closeBC',
					'style':
					{
						'display': 'block',
						'width': '30px',
						'height': '30px',
						'lineHeight': '30px',
						'margin': '0px',
						'textIndent': '-9999px',
						'zIndex': '9999',
						'position': 'fixed',
						'bottom': '305px',
						'right': '0px',
						'cursor': 'pointer',
						'background': 'url(' + barCloseImg + ')'
					},
					'innerHTML': 'livejasmin',
					'href': 'javascript:ljb.closeBC();'
				},
				'bottomchat_close'
			);
		}

		if(readCookie('ljbb') == null) {
			createElement('div',
				{
					'id': 'bottombar',
					'style' :
					{
						'display': 'block',
						'overflow': 'hidden',
						'width': '100%',
						'height': '30px',
						'margin': '0px',
						'zIndex': '9997',
						'position': ((isIE6||isIE) ? 'absolute' : 'fixed'),
						'bottom': '0px',
						'left': '0px'
					}
				}
			);

			createElement('iframe',
					{
						'id': 'bottombar_frame',
						'name': 'bottombar_frame',
						'src': bottomBarIframeUrl,
						'style': {
							'width': '100%',
							'height': '30px'
						},
						'scrolling': 'no',
						'frameBorder': 'no',
						'allowTransparency': 'true',
						'marginHeight': '0',
						'marginWidth': '0'
					},
					'bottombar'
				);

			createElement('div',
				{
					'id': 'bottombar_close',
					'style' :
					{
						'display': 'block',
						'width': '30px',
						'height': '30px',
						'margin': '0px',
						'zIndex': '19999',
						'position': ((isIE6||isIE) ? 'absolute' : 'fixed'),
						'bottom': '0px',
						'right': '0px'
					}
				}
			);

			createElement('a',
					{
						'id': 'closeBB',
						'style':
						{
							'display': 'block',
							'float': 'right',
							'width': '30px',
							'height': '30px',
							'lineHeight': '30px',
							'margin': '0px',
							'textIndent': '-9999px',
							'zIndex': '19999',
							'position': ((isIE6||isIE) ? 'absolute' : 'fixed'),
							'bottom': '0px',
							'right': '0px',
							'cursor': 'pointer',
							'background': 'url(' + barCloseImg + ')'
						},
						'innerHTML': 'livejasmin',
						'href': 'javascript:ljb.closeBB();'
					},
					'bottombar_close'
				);

			createElement('div',
				{
					'id': 'bottomchat',
					'style':
					{
						'display': 'block',
						'overflow': 'hidden',
						'width': '325px',
						'height': '305px',
						'margin': '0px',
						'zIndex': '9996',
						'position': ((isIE6||isIE) ? 'absolute' : 'fixed'),
						'bottom': ((isIE6||isIE) ? '30px' : '-325px'),
						'right': ((isIE6||isIE) ? '0px': '-4px'),
						'background-color': 'red'
					}
				}
			);

			createElement('iframe',
				{
					'id': 'bottomchat_frame',
					'name': 'bottomchat_frame',
					'src': chatIframeUrl,
					'style': {
						'width': '325px',
						'height': '305px',
						'overflow': 'hidden',
						'top': '1px',
						'left': '1px'
					},

					'scrolling': 'no',
					'frameBorder': 'no',
					'allowTransparency': 'true',
					'marginHeight': '0',
					'marginWidth': '0'
				},
				'bottomchat'
			);


			if (isIE6||isIE) {
				createChatClose();
				setInterval(windowMoveBottom, 50);

				document.getElementById('bottombar_close').style['background'] = 'url(' + barCloseImg + ')';
				document.getElementById('bottombar_close').attachEvent('onclick', function() {ljb.CloseBB();});

				document.getElementById('bottomchat_close').style['background'] = 'url(' + barCloseImg + ')';
				document.getElementById('bottomchat_close').attachEvent('onclick', function() {ljb.CloseBC();})
			}
			else {
				function shinUp() {
					if(parseInt(document.getElementById('bottomchat').style.bottom,10) >= chatBottom){
						clearInterval(document.getElementById('bottomchat').timer);
						document.getElementById('bottomchat').style.bottom = chatBottom+"px";
						createChatClose();
					}
					else {
						document.getElementById('bottomchat').style.bottom =
							(parseInt(document.getElementById('bottomchat').style.bottom, 10) + 5) + "px";
					}
				}

				chatBottom = 30;
				document.getElementById('bottomchat').timer=setInterval(shinUp,20);
			}
		}

		/* Public */
		function bottomchat_close() {
			if(navigator.userAgent.indexOf('MSIE') != -1) {
				if(document.getElementById('bottomchat_close')) {
					document.getElementById('bottomchat_close').style.display='none';
					document.body.removeChild(document.getElementById('bottomchat_close'));
				}
				if(document.getElementById('bottomchat')) {
					document.getElementById('bottomchat').style.display='none';
					document.body.removeChild(document.getElementById('bottomchat'));
				}
			}
			else {
				if(document.getElementById('bottomchat_close')) {
					document.body.removeChild(document.getElementById('bottomchat_close'));
				}
				if(document.getElementById('bottomchat')) {
					document.body.removeChild(document.getElementById('bottomchat'));
				}
			}
		}

		function bottombar_close() {
			writeCookie('ljbb', 1, cookieTime);
			if(navigator.userAgent.indexOf('MSIE') != -1) {
				if(document.getElementById('bottombar_close')) {
					document.getElementById('bottombar_close').style.display='none';
					document.body.removeChild(document.getElementById('bottombar_close'));
				}
				if(document.getElementById('bottombar')) {
					document.getElementById('bottombar').style.display='none';
					document.body.removeChild(document.getElementById('bottombar'));
				}
			}
			else {
				if(document.getElementById('bottombar_close')) {
					document.body.removeChild(document.getElementById('bottombar_close'));
				}
				if(document.getElementById('bottombar')) {
					document.body.removeChild(document.getElementById('bottombar'));
				}
			}
			bottomchat_close();
		}

		return {closeBB : bottombar_close, closeBC : bottomchat_close};
	}
)();

