var server = 'apartments',
srcurl = 'http://webmedia.adperfect.com/apartmentsadmin/',
//srcurl = 'http://www.adperfect.com/apartmentsadmin/',
//srcurl = 'http://devapartmentsadmin.adperfect.com/apartments_flashlibrary/',
codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
pluginspage = 'http://www.macromedia.com/go/getflashplayer',
resizeFlashAdID = '';

var browser = navigator.userAgent;
browser = browser.toLowerCase();
if(browser.indexOf('macintosh') != -1){
	var isMac = true;
}else if(browser.indexOf('windows') != -1){
	var isWin = true;
}
if(browser.indexOf('firefox') != -1){
	var isFirefox = true;
}else if(browser.indexOf('safari') != -1){
	var isSafari = true;
}else if(browser.indexOf('opera') != -1){
	var isOpera = true;
}else if(browser.indexOf('netscape') != -1){
	var isNetscape = true;
}else if(browser.indexOf('msie') != -1){
	var isIE = true;
	if(browser.indexOf('msie 6') != -1){
		var isIEVersion6 = true;	
	}
}

function AP_getPos_v20080411_pcl_160x600_400x600_demo3(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curtop, curleft];
}

function Div(w,h,t,l,p,bg){
	this.div=document.createElement('div');
	this.w=w+'px';
	this.h=h+'px';
	this.pos='absolute';
	this.top=t+'px';
	this.left=l+'px';
	this.pad=p+'px';
	this.bord='none';
	//this.bg='#'+bg;
	this.display=function(stub,w,h,t,l){
		if(document.getElementById('AP_PP_v20080411')) {
			this.div.style.width=w+'px';
			this.div.style.height=h+'px';
			this.div.style.top=t+'px';
			this.div.style.left=l+'px';
		} else {
			this.div.id='AP_PP_v20080411';
			this.div.style.width=w+'px';
			this.div.style.height=h+'px';
			this.div.style.position=this.pos;
			this.div.style.top=t+'px';
			this.div.style.left=l+'px';
			this.div.style.padding=this.pad;
			this.div.style.border=this.bord;
			this.div.style.zIndex='1000001';
			this.div.style.overflow='visible';
			//this.div.style.background=this.bg;
			this.div.innerHTML=stub;
			document.getElementsByTagName('body')[0].appendChild(this.div);
		}
	}
}

function iFrame(w,h,t,l,p,bg){
	this.iframe=document.createElement('iframe');
	this.w=w+'px';
	this.h=h+'px';
	this.pos='absolute';
	this.top=t+'px';
	this.left=l+'px';
	this.pad=p+'px';
	this.bord='none';
	this.display=function(src,w,h,t,l){
		if(document.getElementById('AP_PP_v20080411_frame')) {
			this.iframe.style.width=w+'px';
			this.iframe.style.height=h+'px';
			this.iframe.style.top=t+'px';
			this.iframe.style.left=l+'px';
			this.iframe.src='';
		} else {
			this.iframe.id='AP_PP_v20080411_frame';
			this.iframe.style.width=w+'px';
			this.iframe.style.height=h+'px';
			this.iframe.style.position=this.pos;
			this.iframe.style.top=t+'px';
			this.iframe.style.left=l+'px';
			this.iframe.style.padding=this.pad;
			this.iframe.style.border=this.bord;
			this.iframe.style.zIndex='1000000';
			this.iframe.src='';
			document.getElementsByTagName('body')[0].appendChild(this.iframe);
		}
	}
}

var AP_floater;
AP_floater=new Div(500,450,200,200,0,'ff0000');

if(isWin && isIEVersion6){
	var AP_frame;
	AP_frame=new iFrame(500,450,200,200,0,'ff0000');
}

window.onresize = function(){	
	if(resizeFlashAdID != ''){
		var coors = AP_getPos_v20080411_pcl_160x600_400x600_demo3(document.getElementById('AP_C_'+resizeFlashAdID));
		if(isWin && isOpera){
			var coors = AP_getPos_v20080411_pcl_160x600_400x600_demo3('AP_C_'+resizeFlashAdID);
		}
		
		var tempTop = parseInt(coors[0]),
		tempLeft = parseInt(coors[1]);
		
		if(document.getElementById('AP_PP_v20080411')){
			document.getElementById('AP_PP_v20080411').style.top = tempTop+'px';
			document.getElementById('AP_PP_v20080411').style.left = tempLeft+'px';
		}
		
		if(isWin && isIEVersion6){
			if(document.getElementById('AP_PP_v20080411_frame')){
				document.getElementById('AP_PP_v20080411_frame').style.top = tempTop+'px';
				document.getElementById('AP_PP_v20080411_frame').style.left = tempLeft+'px';
			}
		}
	}
}

function AP_updatePreview_v20080411_pcl_160x600_400x600_demo3(FlashAdID, elemWidth, elemHeight, offSetLeft){
	
	var stub = '';
	var coors = AP_getPos_v20080411_pcl_160x600_400x600_demo3(document.getElementById('AP_C_'+FlashAdID));
	if(isWin && isOpera){
		var coors = AP_getPos_v20080411_pcl_160x600_400x600_demo3('AP_C_'+FlashAdID);
	}
	
	var newTop = parseInt(coors[0]),
	newLeft = parseInt(coors[1]) - (240 - parseInt(offSetLeft));
	
	if(document.getElementById('AP_AdPanel_v20080411_pcl_160x600_400x600_demo3_'+FlashAdID)){
		var clipStyle = 'rect(0px, '+elemWidth+'px, '+elemHeight+'px, '+offSetLeft+'px)';
		document.getElementById('AP_AdPanel_v20080411_pcl_160x600_400x600_demo3_'+FlashAdID).style.clip = clipStyle;
	}	
	
	var tempWidth = parseInt(elemWidth) - parseInt(offSetLeft);
	
	if(isWin && isIEVersion6){
		AP_frame.display(stub,tempWidth,elemHeight,newTop,newLeft);
	}
}

function APL_v20080411_pcl_160x600_400x600_demo3(FlashAdID, layout, style, width, height, ColorComboID){
	var url = document.location.href;
	url = url.replace(/\?/g,"[qmark]");
	url = url.replace(/&/g,"[amp]");
	url = url.replace(/=/g,"[equal]");
	url = url.replace(/#/g,"[hash]");
	layout = layout.toLowerCase();
	
	resizeFlashAdID = FlashAdID;
	
	var rand_num = Math.round(Math.random()*100000000);
	var stub = '<div id="AP_AdPanel_v20080411_pcl_160x600_400x600_demo3_'+FlashAdID+'" style="position:absolute;top:0px;left:-228px;width:'+width+'px;height:'+height+';clip: rect(0px, '+width+'px, '+height+'px, 228px);z-index:10000002;"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+codebase+'" width="'+width+'" height="'+height+'"><param name="movie" value="'+srcurl+layout+'_'+style+'.swf?FlashAdID='+FlashAdID+'&Width='+width+'&Height='+height+'&url='+url+'&Server='+server+'&rand='+rand_num+'&ColorComboID='+ColorComboID+'" /><param name="quality" value="high"><param name="wmode" value="transparent"><param name="menu" value="false"><param name="left" value="right"><param name="salign" value="l"><param name="allowScriptAccess" value="always"><embed src="'+srcurl+layout+'_'+style+'.swf?FlashAdID='+FlashAdID+'&Width='+width+'&Height='+height+'&url='+url+'&Server='+server+'&rand='+rand_num+'&ColorComboID='+ColorComboID+'" quality="high" wmode="transparent" menu="false" align="left" salign="l" allowScriptAccess="always" pluginspage="'+pluginspage+'" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed></object></div>';
	
	var coors = AP_getPos_v20080411_pcl_160x600_400x600_demo3(document.getElementById('AP_C_'+FlashAdID));
	if(isWin && isOpera){
		var coors = AP_getPos_v20080411_pcl_160x600_400x600_demo3('AP_C_'+FlashAdID);
	}
	
	var newTop = parseInt(coors[0]),
	newLeft = parseInt(coors[1]),
	elemWidth = '172',
	elemHeight = '600';

	AP_floater.display(stub,elemWidth,height,newTop,newLeft);
	if(isWin && isIEVersion6){
		AP_frame.display(stub,elemWidth,height,newTop,newLeft);
	}
}

function checkAP_Loaded_v20080411_pcl_160x600_400x600_demo3(){
	try {
		if(APLoaded_v20080411_pcl_160x600_400x600_demo3) {
			DO_APL_v20080411_pcl_160x600_400x600_demo3();
		}
		else{
			setTimeout('checkAP_Loaded_v20080411_pcl_160x600_400x600_demo3()', 500);
		}
	} catch(e) {
		setTimeout('checkAP_Loaded_v20080411_pcl_160x600_400x600_demo3()', 500);
	} finally{
	}
}
setTimeout('checkAP_Loaded_v20080411_pcl_160x600_400x600_demo3()', 500);
