function generatePropList(userId) {	
	//preset vars
	markup = '';
	url = 'http://www.french-property.com/affiliates/listProperties.php';
	getString = '';	
	previewHTML = document.getElementById('previewMarkup');
	previewIframe = document.getElementById('previewIframe');
	
	//empty vars from last generation
	bc = '';
	lc = '';
	tc = '';
	minPrice = '';
	maxPrice = '';
	key ='';
	
	//fill vars
	bc = document.options.bColour.value;
	lc = document.options.lColour.value;
	tc = document.options.tColour.value;
	minPrice = document.attributes.min.value;
	maxPrice = document.attributes.max.value;
	key = escape(document.attributes.keyword.value);
	
	//some useful vars
	pArray = Array();
	pStart = false;
	regionCap = 5;
	regionsUsed = 0;
	currentRegion = 0;
	
	//generate string
	count = 0;
	if(bc.length > 3){ pArray[count] = 'bg='+bc; count++; }
	if(lc.length > 3){ pArray[count] = 'lc='+lc; count++;}
	if(tc.length > 3){ pArray[count] = 'txt='+tc; count++;}
	//price
	if(minPrice.length > 0){ pArray[count] = 'pmn='+minPrice; count++;}
	if(maxPrice.length > 0){ pArray[count] = 'pmx='+maxPrice; count++;}
	if(key.length > 0){ pArray[count] = 'kwd='+key; count++;}
	
	for(currentRegion = 1;currentRegion <= regionCap;currentRegion++)
	{
		r = document.getElementById('r'+currentRegion);
		s = document.getElementById('d'+currentRegion);
		//decide which var to use		
		if(s.value > 0)
		{
			regionsUsed++;
			regionName = 'r'+regionsUsed;
			pArray[count] = regionName+'='+s.value; count++;
		}
		else if(r.value > 0)
		{
			regionsUsed++;
			regionName = 'r'+regionsUsed;
			pArray[count] = regionName+'='+r.value; count++;
		}
	}
	
	//build parametre string for url	
	for(x in pArray)
	{
		iur = '';
		if(pStart === false){ iur += '\?'; pStart =true;} else { iur += '\&';}
		iur += pArray[x];
		getString += iur;
	}
	//create html markup for the iframe
	markup = '<iframe\nwidth="460"\nheight="1300"\nframeborder="0"\nsrc="'+url+getString+'&affil='+userId+'"\n>Your browser must support frames to display the content of this <a href="http://www.french-property.com" title="Internet French Property">Internet French Property</a> module.\n</iframe>';
	//insert the markup as text
	
	previewHTML.value = markup;
	//refresh the iframe with the new values
	document.getElementById('previewIframe').src = url+getString;//markup;	
}
oAffiliates =  function()
{
	this.ajax = new sack();
	this.department = null;
	this.getDepartments = function()
	{
		tmpVar = affiliates.ajax.response;
		tmpVar = str_replaceAll(tmpVar, 'obj', 'affiliates.department');
		affiliates.department.innerHTML = '';
		eval(tmpVar);
		affiliates.department = null;
	};
	
	this.copy = copy;
	this.getLocale = null;
	this.checkRegionField = CheckRegionField;
};
function CheckRegionField(regionId)
{
		regionObj = null;
		regionInput = document.getElementById('r'+regionId);
		
		this.department = document.getElementById('d'+regionId);
		
		if(regionInput.value > 0){		
			this.department.disabled = false;
			this.ajax.onCompletion = this.getDepartments;	
			this.ajax.requestFile = 'http://www.french-property.com/template/js/ajax/getLocale2.php?localeID='+regionInput.value;	// Specifying which file to get
			this.ajax.runAJAX();		// Execute AJAX function
		}
		else
		{
			this.department.disabled = true;
			this.department.innerHTML = '';
		}
}
affiliates = new oAffiliates();
function str_replaceAll(subject, expression, newv)
{
	while(subject.indexOf(expression) >= 0)
	{
		subject = subject.replace(expression, newv);
	}
	return subject;
}
function copy()
{
	s = document.getElementById('previewMarkup').value;
	if( window.clipboardData && clipboardData.setData )
	{
		clipboardData.setData("Text", s);
	}
	else
	{
		alert('sorry! your browser does\'nt support this function\n\nYou will need to copy the text by hand.\nTo do so select the text then press CTRL and C similtaniously.')	;
	}
}
function generateClassified(userId) {	
	//preset vars
	markup = '';
	url = 'http://www.french-property.com/affiliates/create_classified.php';
	getString = '';	
	previewHTML = document.getElementById('previewMarkup');
	previewIframe = document.getElementById('previewIframe');
	
	//empty vars from last generation
	bc = '';
	lc = '';
	tc = '';

	
	//fil vars
	bc = document.options.bColour.value;
	lc = document.options.lColour.value;
	tc = document.options.tColour.value;
	
	//some useful vars
	pArray = Array();
	pStart = false;
	regionCap = 5;
	regionsUsed = 0;
	currentRegion = 0;
	
	//generate string
	count = 0;
	if(bc.length > 3){ pArray[count] = 'bg='+bc; count++; }
	if(lc.length > 3){ pArray[count] = 'lc='+lc; count++;}
	if(tc.length > 3){ pArray[count] = 'txt='+tc; count++;}
	
	//build parametre string for url	
	for(x in pArray)
	{
		iur = '';
		if(pStart === false){ iur += '\?'; pStart =true;} else { iur += '\&';}
		iur += pArray[x];
		getString += iur;
	}
	//create html markup for the iframe
	markup = '<iframe\nwidth="460"\nheight="400"\nframeborder="0"\nsrc="'+url+getString+'&affil='+userId+'"\n>Your browser must support frames to display the content of this <a href="http://www.french-property.com" title="Internet French Property">Internet French Property</a> module.\n</iframe>';
	//insert the markup as text
	
	previewHTML.value = markup;
	//refresh the iframe with the new values
	document.getElementById('previewIframe').src = url+getString;//markup;	
}
function generateMPU(userId) {	
	//preset vars
	markup = '';
	url = 'http://www.french-property.com/affiliates/mpu.php';
	getString = '';	
	previewHTML = document.getElementById('previewMarkup');
	previewIframe = document.getElementById('previewIframe');
	
	//empty vars from last generation
	bc = '';
	lc = '';
	tc = '';
	minPrice = '';
	maxPrice = '';
	key ='';
	
	//fil vars
	bc = document.options.bColour.value;
	br = document.options.bcColour.value;
	lc = document.options.lColour.value;
	tc = document.options.tColour.value;
	minPrice = document.attributes.min.value;
	maxPrice = document.attributes.max.value;
	key = escape(document.attributes.keyword.value);
	
	//some useful vars
	pArray = Array();
	pStart = false;
	regionCap = 5;
	regionsUsed = 0;
	currentRegion = 0;
	
	//generate string
	count = 0;
	if(bc.length > 3){ pArray[count] = 'bg='+bc; count++; }
	if(br.length > 3){ pArray[count] = 'bc='+br; count++; }
	if(lc.length > 3){ pArray[count] = 'lc='+lc; count++;}
	if(tc.length > 3){ pArray[count] = 'txt='+tc; count++;}
	//price
	if(minPrice.length > 0){ pArray[count] = 'pmn='+minPrice; count++;}
	if(maxPrice.length > 0){ pArray[count] = 'pmx='+maxPrice; count++;}
	if(key.length > 0){ pArray[count] = 'kwd='+key; count++;}
	
	for(currentRegion = 1;currentRegion <= regionCap;currentRegion++)
	{
		r = document.getElementById('r'+currentRegion);
		s = document.getElementById('d'+currentRegion);
		//decide which var to use		
		if(s.value > 0)
		{
			regionsUsed++;
			regionName = 'r'+regionsUsed;
			pArray[count] = regionName+'='+s.value; count++;
		}
		else if(r.value > 0)
		{
			regionsUsed++;
			regionName = 'r'+regionsUsed;
			pArray[count] = regionName+'='+r.value; count++;
		}
	}
	
	//build parametre string for url	
	for(x in pArray)
	{
		iur = '';
		if(pStart === false){ iur += '\?'; pStart =true;} else { iur += '\&';}
		iur += pArray[x];
		getString += iur;
	}
	//create html markup for the iframe
	markup = '<iframe\nwidth="100%"\nheight="250"\nframeborder="0"\nsrc="'+url+getString+'&affil='+userId+'"\n>Your browser must support frames to display the content of this <a href="http://www.french-property.com" title="Internet French Property">Internet French Property</a> module.\n</iframe>';
	//insert the markup as text
	
	previewHTML.value = markup;
	//refresh the iframe with the new values
	document.getElementById('previewIframe').src = url+getString;//markup;	
}
function generateSky(userId) {	
	//preset vars
	markup = '';
	url = null;
	if(document.options.useImages.value > 0)
	{
		url = 'http://www.french-property.com/affiliates/imageSkyscraper.php';
	}
	else
	{
		url = 'http://www.french-property.com/affiliates/skyscraper.php';
	}
	
	getString = '';	
	previewHTML = document.getElementById('previewMarkup');
	previewIframe = document.getElementById('previewIframe');
	
	//empty vars from last generation
	bc = '';
	lc = '';
	tc = '';
	minPrice = '';
	maxPrice = '';
	key ='';
	
	//fil vars
	bc = document.options.bColour.value;
	br = document.options.bcColour.value;
	lc = document.options.lColour.value;
	tc = document.options.tColour.value;
	minPrice = document.attributes.min.value;
	maxPrice = document.attributes.max.value;
	key = escape(document.attributes.keyword.value);
	
	//some useful vars
	pArray = Array();
	pStart = false;
	regionCap = 5;
	regionsUsed = 0;
	currentRegion = 0;
	
	//generate string
	count = 0;
	if(bc.length > 3){ pArray[count] = 'bg='+bc; count++; }
	if(br.length > 3){ pArray[count] = 'bc='+br; count++; }
	if(lc.length > 3){ pArray[count] = 'lc='+lc; count++;}
	if(tc.length > 3){ pArray[count] = 'txt='+tc; count++;}
	//price
	if(minPrice.length > 0){ pArray[count] = 'pmn='+minPrice; count++;}
	if(maxPrice.length > 0){ pArray[count] = 'pmx='+maxPrice; count++;}
	if(key.length > 0){ pArray[count] = 'kwd='+key; count++;}
	
	for(currentRegion = 1;currentRegion <= regionCap;currentRegion++)
	{
		r = document.getElementById('r'+currentRegion);
		s = document.getElementById('d'+currentRegion);
		//decide which var to use		
		if(s.value > 0)
		{
			regionsUsed++;
			regionName = 'r'+regionsUsed;
			pArray[count] = regionName+'='+s.value; count++;
		}
		else if(r.value > 0)
		{
			regionsUsed++;
			regionName = 'r'+regionsUsed;
			pArray[count] = regionName+'='+r.value; count++;
		}
	}
	
	//build parametre string for url	
	for(x in pArray)
	{
		iur = '';
		if(pStart === false){ iur += '\?'; pStart =true;} else { iur += '\&';}
		iur += pArray[x];
		getString += iur;
	}
	//create html markup for the iframe
	markup = '<iframe\nwidth="160"\nheight="600"\nframeborder="0"\nsrc="'+url+getString+'&affil='+userId+'"\n>Your browser must support frames to display the content of this <a href="http://www.french-property.com" title="Internet French Property">Internet French Property</a> module.\n</iframe>';
	//insert the markup as text
	
	previewHTML.value = markup;
	//refresh the iframe with the new values
	document.getElementById('previewIframe').src = url+getString;//markup;	
}


//PreviewCode;
oPreview = function()
{
	this.position = null;
	this.wrapper = null;
	this.iframe = null;
	this.object = null;
	this.show = function(object, url)
	{
		try
		{				
			this.remove();
		}
		catch(e)
		{
			alert(e.message);
		}	
		imgObj = object.firstChild;
		cur = imgObj;
		if (cur.offsetParent)
		{
			curleft = cur.offsetLeft;
			curtop = cur.offsetTop;
			while (cur = cur.offsetParent)
			{
				curleft += cur.offsetLeft;
				curtop += cur.offsetTop;
			}
		}
		this.object = object;
		this.create();
		this.wrapper.style.left = (curleft + 16 + imgObj.clientWidth) +'px';
		this.wrapper.style.top = (curtop - ( imgObj.clientHeight / 2 )) +'px';
		this.iframe.src = url;
		this.wrapper.appendChild(this.iframe);
		document.body.appendChild(this.wrapper);
	};
	this.hide = function()
	{
		if(document.getElementById('en_iframe'))
		{
			document.body.removeChild(this.wrapper);
		}
	};
	this.create = function()
	{
		this.wrapper = null;
		this.iframe = null;
		this.wrapper = document.createElement('div');
		this.wrapper.id = "en_iframe";
		this.iframe = document.createElement('iframe');
		this.iframe.frameBorder = 0;
	};
	this.remove = function()
	{
		if(document.getElementById('en_iframe'))
		{
			document.body.removeChild(this.wrapper);
		}
		this.position = null;
		this.wrapper = null;
		this.iframe = null;
	};
};

iframePreview = new oPreview();
function getObjectPositionLeft(object)
{
	curleft = 0; 
	cur = object;
	if (cur.offsetParent)
	{
		curleft = cur.offsetLeft;
		while (cur = cur.offsetParent)
		{
			curleft += cur.offsetLeft;
		}
	}
	return curleft;
}
function getObjectPositionTop(object)
{
	curtop = 0;
	cur = object;
	if (cur.offsetParent)
	{
		curtop = cur.offsetTop;
		while (cur = cur.offsetParent)
		{
			curtop += cur.offsetTop;
		}
	}
	return curtop;
}
position = function()
{
	this.left = 0;
	this.top = 0;
};