var ejs = {
	a_ini : {},
	isMoved : false,
	
	ini : function () {
		window.onscroll = ejs.onscroll;
		
		var id = 'sexy_girls';
		
		ejs.a_ini[id] = {};
		ejs.a_ini[id]['src'] = '/img/sexy_escort_girls.swf';
		
		id = 'footer';
		ejs.a_ini[id] = {};
		ejs.a_ini[id]['src'] = '/img/footer.jpg';	

		id = 'sexy_girl_one';
		ejs.a_ini[id] = {};
		ejs.a_ini[id]['src'] = '/img/girl.jpg';		
		ejs.a_ini[id]['hh']  = '1400';		
		
		id = 'most_popular_escorts';
		ejs.a_ini[id] = {};
		ejs.a_ini[id]['src'] = '/img/most-popular.swf';		
		
		id = 'featured_partners';
		ejs.a_ini[id] = {};
		ejs.a_ini[id]['src'] = '/img/featured_partners.png';

		id = 'start_search_here';
		ejs.a_ini[id] = {};
		ejs.a_ini[id]['src']  = '/img/button_starthere.swf';
		ejs.a_ini[id]['move'] = 'Y';		
		
		id = 'escorts-h-div';
		ejs.a_ini[id] = {};
		ejs.a_ini[id]['src']  = '/img/top_rated_header.swf';
		ejs.a_ini[id]['move'] = 'Y';

		id = 'news_image_home';
		ejs.a_ini[id] = {};
		ejs.a_ini[id]['src']  = '/img/photo-back.png';
		ejs.a_ini[id]['move'] = 'Y';
		
		id = 'bottompage';
		ejs.a_ini[id] = {};
		ejs.a_ini[id]['src']  = '/img/bottompage.png';
		ejs.a_ini[id]['move'] = 'Y';		
		
		var mass = document.getElementsByTagName('IMG');
		
// && mass[x].getAttribute('alt').indexOf('for download: ') > 0
		for (var x = 0; x < mass.length; x++) {
			
			if (String(mass[x].src).indexOf('blank.gif') > 0 && String(mass[x].getAttribute('alt')).indexOf('for download: ') > 0) {
			//alert(x)
				var a_tmp = mass[x].getAttribute('alt').split('for download: ');
				mass[x].setAttribute('alt', a_tmp[0]);
				if (!mass[x].id) {
					mass[x].id = 'escort_image_' + Math.round(10000 * Math.random());
				}
				id = mass[x].id;
				
				ejs.a_ini[id] = {};
				ejs.a_ini[id]['src']   = a_tmp[1];
				ejs.a_ini[id]['move']  = 'Y';
			}
		}
		
		//window.onmouseover = ejs.onmousemove;
		ejs.addListener(document.body, 'mousemove', ejs.onmousemove)
		setTimeout('ejs.onscroll()', 100);	
		//setTimeout('ejs.isMoved = true;ejs.onscroll()', 25000);	
	},
	
	onmousemove : function () {
		if (!ejs.isMoved) {
			ejs.isMoved = true;
			ejs.onscroll();
		}
	},
	 addListener : function(element, type, expression, bubbling) {
		bubbling = bubbling || false;
		if(window.addEventListener) { // Standard
			element.addEventListener(type, expression, bubbling);
			return true;
		} else if(window.attachEvent) { // IE
			element.attachEvent('on' + type, expression);
		return true;
		} else return false;
	},
	onscroll : function () {
		for (var x in ejs.a_ini) {
			if (ejs.a_ini[x]['move'] == 'Y' && !ejs.isMoved) continue;
			if (!ejs.a_ini[x]) continue;
			var aH = 0;
			if (ejs.a_ini[x]['hh']) aH = ejs.a_ini[x]['hh'];
	
			if (ejs.isVisible(x, aH)) {
				ejs.initilizeItem(x, ejs.a_ini[x]);
				ejs.a_ini[x] = false;
			}
		}
	},
	
	putFlash : function (inID, inArr) {
		var el = ejs.$(inID);
		if (!el) return;
		var w = parseInt(el.style.width);
		var h = parseInt(el.style.height);
		var src = inArr['src'];
		
		var html = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+w+"px' height='"+h+"px' id='SWF:"+inID+"' align='middle'>";
		    html += "<param name='FlashVars' value='' />";
		    html += "<param name='allowScriptAccess' value='always' />";
		    html += "<param name='wmode' value='transparent' />";
		    html += "<param name='bgcolor' value='white' />";
		    html += "<param name='salign' value='lt' />";
		    html += "<param name='movie' value='"+src+"' /><param name='quality' value='high' /><embed src='"+src+"' wmode='transparent' quality='high' FLashVars='' salign='lt' width='"+w+"px' height='"+h+"px' bgcolor='white' name='SWF:"+inID+"' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
		    html += "</object>"
		el.innerHTML = html;
		el.style.visiblity = 'hidden';
		el.style.visiblity = '';
		    
	},
	
	
	initilizeItem : function (inID, inArr) {
		var el = ejs.$(inID);
		if (!el) return;
		
		var src = inArr['src'];
		if (src.indexOf('.swf') > 0) {
			ejs.putFlash(inID, inArr);
		} else {
			if (el.tagName == 'DIV' || el.tagName == 'TD') {
				el.style.backgroundImage = "url("+inArr['src']+")"
			} else {
				el.src = src;
			}
		}
	},
	
	$ : function (inID) {
		return document.getElementById(inID);
	},
	
	isVisible : function (inID, aH) {
		var pos = ejs.getPos(ejs.$(inID));
		var scroll = ejs.getDocumentScroll();
		return Number(scroll[1]) + Number(1000) > Number(pos['T']) + Number(aH); 
	},
	
	getDocumentScroll : function(){
		return [
		self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) 
			|| (document.body && document.body.scrollLeft),
		self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) 
			|| (document.body && document.body.scrollTop)
		];
	},	
	
	getPos : function (inItem) {
		var l_result = {};
		var tmp_elem = inItem;
		    var offsetTop  = 0;
		    var offsetLeft = 0;
		    while (tmp_elem) {
		        offsetTop   = offsetTop + tmp_elem.offsetTop;
		        offsetLeft 	= offsetLeft + tmp_elem.offsetLeft;
				tmp_elem    = tmp_elem.offsetParent;
		    }
	
		    try {
		    l_result['L'] = offsetLeft;
		    l_result['T'] = offsetTop;
		    l_result['W'] = parseInt(inItem.offsetWidth);
		    l_result['H'] = parseInt(inItem.offsetHeight);
		    } catch(e) {}
		    return l_result;
	}		
	
	
	
	
}
window.onload = ejs.ini;
