// JavaScript Document
function goHome() {
   	window.scroll(0,0); // horizontal and vertical scroll targets
} // goHome



function setListMode(mode)
{
// texts
var today = new Date();
var expire = new Date();
var boogie = ""+mode+"";
var nDays=1;
expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = "listmode"+"="+escape(boogie)+ ";path="+escape("/")+";expires="+expire.toGMTString();
location.reload(true);
} // setListMode

function createPopup(url)
{
var options = 'scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no'; 
options += ',width=' + 600 + ',height=' + 800; 
options += ',screenX=0,screenY=0,top=0,left=0'; 
var win = window.open(url, 'Privacy', options); 
win.focus(); 
win.moveTo(0, 0);
} // createPopup

function closePopup()
{
if(thePopup!=null) {
	thePopup.hide();
	thePopup.close();
	thePopup=null;
	}
closeQuickPopup();
} //closePopup

function closeNewsPopup()
{
if(newsPopup!=null) {
	newsPopup.hide();
	newsPopup.close();
	newsPopup=null;
	}
closeQuickPopup();
} //closeNewsPopup

function closeQuickPopup()
{
if(quickPopup!=null) {
	quickPopup.hide();
	quickPopup.close();
	quickPopup=null;
	}
} //closeQuickPopup

var thePopup=null;
var newsPopup=null;
var quickPopup=null;
var viewportwidth=800;
var viewportheight=600;
var lastscreenwidth=0;
var lastscreenheight=0;
var CoreMap = null;
var CurrentMarkers=new Array();
var LastMarkerField=null;
var FocusMarker=null;
var FocusIcon='';

function ajaxRequest(){
	var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
	if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
		for (var i=0; i<activexmodes.length; i++){
			try{
			return new ActiveXObject(activexmodes[i])
		}
		catch(e){
		//suppress error
		}
		}
	}
	else if (window.XMLHttpRequest) // if Mozilla, Safari etc
	return new XMLHttpRequest()
	else
	return false
} // ajaxRequest

function getScreenSize()
{
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }
} // getScreenSize
 
 function ajaxlogin(){
	var mypostrequest=new ajaxRequest()
	mypostrequest.onreadystatechange=function(){
	if (mypostrequest.readyState==4){
		if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){
			if(mypostrequest.responseText=="OK") {
				closePopup();
				document.location = "/user/index.php";
				}
			else {
				document.getElementById("result").innerHTML=mypostrequest.responseText
				}
	}
	else{
		alert("An error has occured making the request")
	}
	}
	}
	var namevalue=encodeURIComponent(document.getElementById("username").value)
	var agevalue=encodeURIComponent(document.getElementById("password").value)
	var parameters="username="+namevalue+"&password="+agevalue
	mypostrequest.open("POST", "/scriptscore/pop/ajax-login.php", true)
	mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
	mypostrequest.send(parameters)
}  // ajaxlogin

function putLoginPopup()
{
closePopup();
thePopup=dhtmlmodal.open('ajaxbox', 'ajax', '/scriptscore/pop/login-popup.php', 'AHouse',  'width=660px,height=210px,left=200px,top=0px,resize=0,scrolling=0,center=1');
} //putLoginPopup

function putLogoutPopup()
{
closePopup();
thePopup=dhtmlmodal.open('ajaxbox', 'ajax', '/scriptscore/pop/logout-popup.php', 'AHouse', 'width=660px,height=210px,left=200px,top=0px,resize=0,scrolling=0,center=1');
} //putLogoutPopup

 function ajaxEditChoice(SourceQuestion){
	var mypostrequest=new ajaxRequest()
	mypostrequest.onreadystatechange=function(){
	if (mypostrequest.readyState==4){
		if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){
			if(mypostrequest.responseText=="OK") {
				closePopup();
				window.location.reload();
				}
			else {
				document.getElementById("result").innerHTML=mypostrequest.responseText
				}
	}
	else{
		alert("An error has occured making the request")
	}
	}
	}
	var choiceidvalue=encodeURIComponent(document.getElementById("choiceid").value)
	var namevalue=encodeURIComponent(document.getElementById("choicename").value)
	var precisvalue=encodeURIComponent(document.getElementById("precis").value)
	var valuevalue=encodeURIComponent(document.getElementById("choicevalue").value)
	var sequencegroupvalue=encodeURIComponent(document.getElementById("sequencegroup").value)
	var sequencevalue=encodeURIComponent(document.getElementById("sequence").value)
	var parameters="choiceid="+choiceidvalue+"&name="+namevalue+"&precis="+precisvalue+"&value="+valuevalue+"&sequencegroup="+sequencegroupvalue+"&sequence="+sequencevalue+"&SourceQuestion="+SourceQuestion
	mypostrequest.open("POST", "/admin/utils/ajax-editchoice.php", true)
	mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
	mypostrequest.send(parameters)
}  // ajaxEditChoice

function putCheckChoicePopup(QuestionChoiceId, SourceQuestion, SourcePage, SourceSubCat, SourceCat)
{
closePopup();
if(document.getElementById("CheckText")) {
	var CheckText=encodeURIComponent(document.getElementById("CheckText").value)
	thePopup=dhtmlmodal.open('ajaxbox', 'ajax', '/admin/utils/check-choice.php?choice='+QuestionChoiceId+'&SourceQuestion='+SourceQuestion+'&SourcePage='+SourcePage+'&SourceSubCat='+SourceSubCat+'&SourceCat='+SourceCat+'&CheckText='+CheckText, 'Check Choices', 'width=820px,height=650px,left=0px,top=0px,resize=1,scrolling=1,center=1');
	}
} //putCheckChoicePopup

function putEditChoicePopup(QuestionChoiceId, SourceQuestion, SourcePage, SourceSubCat, SourceCat)
{
closePopup();
thePopup=dhtmlmodal.open('ajaxbox', 'ajax', '/admin/utils/edit-choice.php?choice='+QuestionChoiceId+'&SourceQuestion='+SourceQuestion+'&SourcePage='+SourcePage+'&SourceSubCat='+SourceSubCat+'&SourceCat='+SourceCat, 'Edit Choice Question', 'width=620px,height=450px,left=0px,top=0px,resize=0,scrolling=0,center=1');
} //putEditChoicePopup

 function ajaxMoveChoice(sourcechoiceid, objectchoiceid, objectquestionid)
 {
	var mypostrequest=new ajaxRequest()
	mypostrequest.onreadystatechange=function(){
	if (mypostrequest.readyState==4){
		if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){
			if(mypostrequest.responseText=="OK") {
				closePopup();
				window.location.reload();
				}
			else {
				document.getElementById("result").innerHTML=mypostrequest.responseText
				}
	}
	else{
		alert("Sorry. An error has occured making the request")
	}
	}
	}
/*	var choiceidvalue=encodeURIComponent(document.getElementById("choiceid").value)
	var namevalue=encodeURIComponent(document.getElementById("choicename").value)
	var valuevalue=encodeURIComponent(document.getElementById("choicevalue").value)
	var sequencegroupvalue=encodeURIComponent(document.getElementById("sequencegroup").value)
	var sequencevalue=encodeURIComponent(document.getElementById("sequence").value)
*/	var parameters="SourceChoiceId="+sourcechoiceid+"&ObjectChoiceId="+objectchoiceid+"&ObjectQuestionId="+objectquestionid
	mypostrequest.open("POST", "/admin/utils/ajax-movechoice.php", true)
	mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
	mypostrequest.send(parameters)
}  // ajaxMoveChoice

function putMoveChoicePopup(QuestionChoiceId, SourceCat, SourceSubCat, SourcePage, SourceQuestion, ObjectChoice)
{
closePopup();
thePopup=dhtmlmodal.open('ajaxbox', 'ajax', '/admin/utils/move-choice.php?choice='+QuestionChoiceId+'&SourceCat='+SourceCat+'&SourceSubCat='+SourceSubCat+'&SourcePage='+SourcePage+'&SourceQuestion='+SourceQuestion+'&ObjectChoice='+ObjectChoice, 'Move Choice Question', 'width=800px,height=720px,left=0px,top=0px,resize=0,scrolling=1,center=1');
} //ChoicePopup

function MM_jumpChoicePopup(targ,selObj,restore, QuestionChoiceId, SourceCat, SourceSubCat, SourcePage, SourceQuestion, ObjectChoice, Changer)
{ //v3.0
switch(Changer) {
	case 'SourceCat': SourceCat = selObj.options[selObj.selectedIndex].value; break;
	case 'SourceSubCat': SourceSubCat = selObj.options[selObj.selectedIndex].value; break;
	case 'SourcePage': SourcePage = selObj.options[selObj.selectedIndex].value; break;
	case 'SourceQuestion': SourceQuestion = selObj.options[selObj.selectedIndex].value; break;
	case 'ObjectChoice': ObjectChoice = selObj.options[selObj.selectedIndex].value; break;
}
 putMoveChoicePopup(QuestionChoiceId, SourceCat, SourceSubCat, SourcePage, SourceQuestion, ObjectChoice)
// eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"&SourceCat="+SourceCat+"&SourceSubCat="+SourceSubCat+"&SourcePage="+SourcePage+"&SourceQuestion="+SourceQuestion+"'");
//  if (restore) selObj.selectedIndex=0;
} // MM_jumpChoicePopup

 function ajaxregister(full){
	var mypostrequest=new ajaxRequest()
	mypostrequest.onreadystatechange=function(){
	if (mypostrequest.readyState==4){
		if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){
			if(mypostrequest.responseText=="OK") {
				closePopup();
				window.location.href = "/user/index.php";
//				putMiniHelpPopup('REGISTERED');
				}
			else {
				document.getElementById("result").innerHTML=mypostrequest.responseText
				}
	}
	else{
		alert("An error has occured making the request")
	}
	}
	}
	var emailvalue=encodeURIComponent(document.getElementById("email").value)
	var passwordvalue=encodeURIComponent(document.getElementById("password").value)
	var rpasswordvalue=encodeURIComponent(document.getElementById("rpassword").value)
	var usernamevalue=encodeURIComponent(document.getElementById("username").value)
	var firstnamevalue=encodeURIComponent(document.getElementById("firstname").value)
	var lastnamevalue=encodeURIComponent(document.getElementById("lastname").value)
	
	var xtraargs="";
	var headline = document.getElementById("Headline");
	if(headline) {
		xtraargs = xtraargs + "&headline=" + encodeURIComponent(headline.value);
		}
	var description = document.getElementById("Description");
	if(description) {
		xtraargs = xtraargs + "&description=" + encodeURIComponent(tinyMCE.activeEditor.getContent());
//		xtraargs = xtraargs + "&description=" + "test again";
		}
	var adlink = document.getElementById("AdLink");
	if(adlink) {
		xtraargs = xtraargs + "&adlink=" + encodeURIComponent(adlink.value);
		}
		
	var advalue="0";
	if(full) {
		advalue=encodeURIComponent(document.getElementById("ad").value)
		}
	var parameters="email="+emailvalue+"&password="+passwordvalue+"&rpassword="+rpasswordvalue+"&username="+usernamevalue+"&firstname="+firstnamevalue+"&lastname="+lastnamevalue+"&ad="+advalue+xtraargs
	mypostrequest.open("POST", "/scriptscore/pop/ajax-register.php", true)
	mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
	mypostrequest.send(parameters)
}  // ajaxregister

function putRegisterPopup(ad)
{
closePopup();
if(ad) {
	thePopup=dhtmlmodal.open('iframe', 'ajax', '/scriptscore/pop/reg-popup.php?ad='+ad, 'Add to this Ad', 'width=620px,height=550px,left=0px,top=0px,resize=0,scrolling=1,center=1');
}
else {
thePopup=dhtmlmodal.open('ajaxbox', 'ajax', '/scriptscore/pop/reg-popup.php', 'Register Here', 'width=620px,height=400px,left=0px,top=0px,resize=0,scrolling=0,center=1');
}
} //putRegisterPopup

function putAdvertisePopup()
{
closePopup();
thePopup=dhtmlmodal.open('ajaxbox', 'ajax', '/scriptscore/pop/reg-popup.php', 'Advertise Here', 'width=620px,height=330px,left=0px,top=0px,resize=0,scrolling=0,center=1');
} //putAdvertisePopup

function putMiniHelpPopup(helpcode)
{
closePopup();
thePopup=dhtmlwindow.open('ajaxbox', 'ajax', '/scriptscore/pop/showhelp.php?helpcode='+helpcode, 'AHouse', 'width=660px,height=340px,left=200px,top=0px,resize=0,scrolling=1,center=1');
} //putMiniHelpPopup



function ajaxlogout()
{
var mypostrequest=new ajaxRequest()
var parameters=""
mypostrequest.open("POST", "/scriptscore/pop/ajax-logout.php", true)
mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
mypostrequest.send(parameters)
closePopup()
window.location = "/index.php"
} // ajaxlogout

 function ajaxsendad(){
	var mypostrequest=new ajaxRequest()
	mypostrequest.onreadystatechange=function(){
	if (mypostrequest.readyState==4){
		if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){
			if(mypostrequest.responseText=="OK") {
				closePopup();
				putMiniHelpPopup('SENTAD');
				}
			else {
				document.getElementById("result").innerHTML=mypostrequest.responseText
				}
	}
	else{
		alert("An error has occured making the request")
	}
	}
	}
	var fromnamevalue=encodeURIComponent(document.getElementById("fromname").value)
	var fromemailvalue=encodeURIComponent(document.getElementById("fromemail").value)
	var tonamevalue=encodeURIComponent(document.getElementById("toname").value)
	var toemailvalue=encodeURIComponent(document.getElementById("toemail").value)
	var messagevalue=encodeURIComponent(document.getElementById("message").value)
	var advalue=encodeURIComponent(document.getElementById("ad").value)
	var uploadidvalue=encodeURIComponent(document.getElementById("uploadid").value)
	var chkcoddvalue=encodeURIComponent(document.getElementById("chkcodd").value)
	var parameters="fromname="+fromnamevalue+"&fromemail="+fromemailvalue+"&toname="+tonamevalue+"&toemail="+toemailvalue+"&message="+messagevalue+"&ad="+advalue+"&uploadid="+uploadidvalue+"&chkcodd="+chkcoddvalue
	mypostrequest.open("POST", "/scriptscore/pop/ajax-sendad.php", true)
	mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
	mypostrequest.send(parameters)
}  // ajaxsendad


function putSendAdPopup(adid)
{
closePopup();
thePopup=dhtmlmodal.open('ajaxbox', 'ajax', '/scriptscore/pop/sendad-popup.php?ad='+adid, 'Send Ad', 'width=600px,height=520px,left=200px,top=0px,resize=1,scrolling=0,center=1');
} //putSendAdPopup

function putSendImagePopup(uploadid)
{
closePopup();
thePopup=dhtmlmodal.open('ajaxbox', 'ajax', '/scriptscore/pop/sendad-popup.php?uploadid='+uploadid, 'Send Image', 'width=750px,height=520px,left=200px,top=0px,resize=1,scrolling=0,center=1');
} //putSendImagePopup

 function ajaxscore(){
	var mypostrequest=new ajaxRequest()
	mypostrequest.onreadystatechange=function(){
	if (mypostrequest.readyState==4){
		if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){
			if(mypostrequest.responseText=="OK") {
				closePopup();
				window.location.reload();
				}
			else {
				document.getElementById("result").innerHTML=mypostrequest.responseText
				}
	}
	else{
		alert("An error has occured making the request")
	}
	}
	}
	var Uploadvalue=encodeURIComponent(document.getElementById("upload").value)
	var SlideshowSequencevalue=encodeURIComponent(document.getElementById("SlideshowSequence").value)
	var Scorevalue=encodeURIComponent(document.getElementById("Score").value)
	var UploadCatIdvalue=encodeURIComponent(document.getElementById("UploadCatId").value)
	var UploadFavouriteIdvalue=encodeURIComponent(document.getElementById("UploadFavouriteId").value)
	var parameters="upload="+Uploadvalue+"&SlideshowSequence="+SlideshowSequencevalue+"&Score="+Scorevalue+"&UploadCatId="+UploadCatIdvalue+"&UploadFavouriteId="+UploadFavouriteIdvalue
	mypostrequest.open("POST", "/scriptscore/pop/ajax-score.php", true)
	mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
	mypostrequest.send(parameters)
}  // ajaxscore


function putScorePopup(uploadid)
{
closePopup();
thePopup=dhtmlmodal.open('ajaxbox', 'ajax', '/scriptscore/pop/score-popup.php?upload='+uploadid, 'Upload Score', 'width=600px,height=470px,left=200px,top=0px,resize=0,scrolling=0,center=1');
} //putScorePopup

function putSavePopup(adid)
{
closePopup();
var winW = 630, winH = 660;

if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}

width = 580;
height = 500;
var thing = document.getElementById("SV"+adid);
if(thing) {
	var savevalue=encodeURIComponent(thing.checked);
	thePopup=dhtmlwindow.open('ajaxbox', 'ajax', '/scriptscore/pop/savead-popup.php?ad='+adid+'&state='+savevalue, 'Saved Ads', 'width='+width+'px,height='+height+'px,left=0px,top=0px,resize=1,scrolling=1,center=0');
}
else {
	thePopup=dhtmlwindow.open('ajaxbox', 'ajax', '/scriptscore/pop/savead-popup.php?ad='+adid+'&state=true', 'Saved Ads', 'width='+width+'px,height='+height+'px,left=0px,top=0px,resize=1,scrolling=1,center=0');
}
} //putSavePopup

function putSaveImagePopup(uploadid)
{
closePopup();
var winW = 630, winH = 660;

if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}

width = 580;
height = 500;
if(uploadid<0) {
width = 240;
height = 100;
}
var thing=0;
if(uploadid) {
	thing = document.getElementById("SV"+uploadid);
}
if(thing) {
	var savevalue=encodeURIComponent(thing.checked);
	thePopup=dhtmlwindow.open('ajaxbox', 'ajax', '/scriptscore/pop/savead-popup.php?uploadid='+uploadid+'&state='+savevalue, 'Saved Ads', 'width='+width+'px,height='+height+'px,left=0px,top=0px,resize=1,scrolling=1,center=0');
}
else {
	thePopup=dhtmlwindow.open('ajaxbox', 'ajax', '/scriptscore/pop/savead-popup.php?uploadid='+uploadid+'&state=true', 'Saved Ads', 'width='+width+'px,height='+height+'px,left=0px,top=0px,resize=1,scrolling=1,center=0');
}
} //putSaveImagePopup

function putSaveRemoveImagePopup(uploadid)
{
closePopup();
var winW = 630, winH = 660;

if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}

width = 580;
height = 500;

var savevalue='false';
	thePopup=dhtmlwindow.open('ajaxbox', 'ajax', '/scriptscore/pop/savead-popup.php?uploadid='+uploadid+'&state='+savevalue, 'Saved Ads', 'width='+width+'px,height='+height+'px,left=0px,top=0px,resize=1,scrolling=1,center=0');
} //putSaveRemoveImagePopup

function putSaveList()
{
closePopup();
var winW = 630, winH = 660;

if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}

width = 480;
height = parseInt(winH)-165;
thePopup=dhtmlwindow.open('ajaxbox', 'ajax', '/scriptscore/pop/savead-popup.php', 'Saved Ads', 'width='+width+'px,height='+height+'px,left=0px,top=0px,resize=1,scrolling=1,center=0');
} //putSaveList

 function ajaxquestion(){
	var mypostrequest=new ajaxRequest()
	mypostrequest.onreadystatechange=function(){
	if (mypostrequest.readyState==4){
		if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){
			if(mypostrequest.responseText=="OK") {
				closePopup();
				putMiniHelpPopup('SENTQUESTION');
				}
			else {
				document.getElementById("result").innerHTML=mypostrequest.responseText
				}
	}
	else{
		alert("An error has occured making the request")
	}
	}
	}
	var fromnamevalue=encodeURIComponent(document.getElementById("fromname").value)
	var fromemailvalue=encodeURIComponent(document.getElementById("fromemail").value)
	var messagevalue=encodeURIComponent(document.getElementById("message").value)
	var advalue=encodeURIComponent(document.getElementById("ad").value)
	var chkcoddvalue=encodeURIComponent(document.getElementById("chkcodd").value)
	var parameters="fromname="+fromnamevalue+"&fromemail="+fromemailvalue+"&message="+messagevalue+"&ad="+advalue+"&chkcodd="+chkcoddvalue
	mypostrequest.open("POST", "/scriptscore/pop/ajax-question.php", true)
	mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
	mypostrequest.send(parameters)
}  // ajaxquestion

function putQuestionPopup(adid)
{
closePopup();
thePopup=dhtmlmodal.open('ajaxbox', 'ajax', '/scriptscore/pop/question-popup.php?ad='+adid, 'AHouse', 'width=600px,height=450px,left=200px,top=0px,resize=0,scrolling=0,center=1');
} //putQuestionPopup

/* function ajaxfeature(){
	var mypostrequest=new ajaxRequest()
	mypostrequest.onreadystatechange=function(){
	if (mypostrequest.readyState==4){
		if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){
			if(mypostrequest.responseText=="OK") {
				closePopup();
				putMiniHelpPopup('STOREDFEATURE');
				}
			else {
				document.getElementById("result").innerHTML=mypostrequest.responseText
				}
	}
	else{
		alert("An error has occured making the commando")
	}
	}
	}
	var fromnamevalue=encodeURIComponent(document.getElementById("fromname").value)
	var fromemailvalue=encodeURIComponent(document.getElementById("fromemail").value)
	var featuretypevalue=encodeURIComponent(document.getElementById("featuretype").value)
	var descriptionvalue=encodeURIComponent(document.getElementById("description").value)
	var urlvalue=encodeURIComponent(document.getElementById("url").value)
	var advalue=encodeURIComponent(document.getElementById("ad").value)
	var chkcoddvalue=encodeURIComponent(document.getElementById("chkcodd").value)  

//	var parameters="fromname="+fromnamevalue+"&fromemail="+fromemailvalue+"&description="+descriptionvalue+"&ad="+advalue+"&chkcodd="+chkcoddvalue+"&featuretype="+featuretypevalue+"&url="+urlvalue
	var parameters="fromname="+fromnamevalue+"&fromemail="+fromemailvalue
	mypostrequest.open("POST", "/scriptscore/pop/ajax-features.php", true)
	mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
	mypostrequest.send(parameters)
}  // ajaxfeature
*/

 function ajaxfeature(){
	var mypostrequest=new ajaxRequest()
	mypostrequest.onreadystatechange=function(){
	if (mypostrequest.readyState==4){
		if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){
			if(mypostrequest.responseText=="OK") {
				closePopup();
				putMiniHelpPopup('CREATEDFEATURE');
				}
			else {
				document.getElementById("result").innerHTML=mypostrequest.responseText
				}
	}
	else{
		alert("An error has occured making the request")
	}
	}
	}
	var fromnamevalue=encodeURIComponent(document.getElementById("fromname").value)
	var fromemailvalue=encodeURIComponent(document.getElementById("fromemail").value)
	var featuretypevalue=encodeURIComponent(document.getElementById("featuretype").value)
	var descriptionvalue=encodeURIComponent(document.getElementById("description").value)
	var titlevalue=encodeURIComponent(document.getElementById("title").value)
	var tagsvalue=encodeURIComponent(document.getElementById("tags").value)
	var urlvalue=encodeURIComponent(document.getElementById("url").value)
	var advalue=encodeURIComponent(document.getElementById("ad").value)
	var chkcoddvalue=encodeURIComponent(document.getElementById("chkcodd").value)
	var parameters="fromname="+fromnamevalue+"&fromemail="+fromemailvalue+"&ad="+advalue+"&title="+titlevalue+"&url="+urlvalue+"&description="+descriptionvalue+"&tags="+tagsvalue+"&featuretype="+featuretypevalue+"&chkcodd="+chkcoddvalue
	mypostrequest.open("POST", "/scriptscore/pop/ajax-features.php", true)
	mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
	mypostrequest.send(parameters)
}  // ajaxfeature



function putFeatureHerePopup(adid, uploadid)
{
closePopup();
thePopup=dhtmlmodal.open('ajaxbox', 'ajax', '/scriptscore/pop/feature-popup.php?view=EDIT&ad='+adid+'&uploadid='+uploadid, 'AHouse', 'width=700px,height=500px,left=200px,top=0px,resize=1,scrolling=1,center=1');
} //putFeatureHerePopup

function putFeatureHereHelp(adid, uploadid)
{
closePopup();
thePopup=dhtmlmodal.open('ajaxbox', 'ajax', '/scriptscore/pop/feature-popup.php?view=HELP&ad='+adid+'&uploadid='+uploadid, 'AHouse', 'width=700px,height=500px,left=200px,top=0px,resize=1,scrolling=1,center=1');
} //putFeatureHereHelp

function putSiteAdminPopup(context, id)
{
closePopup();
thePopup=dhtmlmodal.open('ajaxbox', 'ajax', '/scriptscore/pop/siteadmin-popup.php?view=HELP&context='+context+'&id='+id, 'AHouse Site Admin', 'width=700px,height=500px,left=200px,top=0px,resize=1,scrolling=1,center=1');
} //putSiteAdminPopup

 function ajaxSiteAdmin(){
	var mypostrequest=new ajaxRequest()
	mypostrequest.onreadystatechange=function(){
	if (mypostrequest.readyState==4){
		if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){
			if(mypostrequest.responseText=="OK") {
				closePopup();
				location.reload(true);
				}
			else {
				document.getElementById("result").innerHTML=mypostrequest.responseText
				}
	}
	else{
		alert("An error has occured making the request")
	}
	}
	}
	var contextvalue=encodeURIComponent(document.getElementById("context").value)
	var idvalue=encodeURIComponent(document.getElementById("id").value)
	var precisvalue=encodeURIComponent(document.getElementById("precis").value)
	var titlevalue=encodeURIComponent(document.getElementById("title").value)
	var codevalue=encodeURIComponent(document.getElementById("code").value)
	var nicknamevalue=encodeURIComponent(document.getElementById("nickname").value)
	var tagsvalue=encodeURIComponent(document.getElementById("tags").value)
	var uploadcatidvalue=encodeURIComponent(document.getElementById("uploadcatid").value)
	var parameters="context="+contextvalue+"&id="+idvalue+"&precis="+precisvalue+"&title="+titlevalue+"&code="+codevalue+"&nickname="+nicknamevalue+"&tags="+tagsvalue+"&uploadcatid="+uploadcatidvalue
	mypostrequest.open("POST", "/scriptscore/pop/ajax-siteadmin.php", true)
	mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
	mypostrequest.send(parameters)
}  // ajaxSiteAdmin

function putImagePopup(adid, uploadid, imgwidth, imgheight, title)
{
var  left=0; // window.innerWidth-width;
var width = window.innerWidth-50;
var height = window.innerHeight-50;

var winW = 630, winH = 460;

var curwidth=0, curheight=0;
var dhtmlwindowholder = document.getElementById("dhtmlwindow");
if(dhtmlwindowholder) {
	curwidth=dhtmlwindowholder.style.width;
	curheight=dhtmlwindowholder.style.height;
	}


closePopup();

//if(!dhtmlwindowholder) {

		if (parseInt(navigator.appVersion)>3) {
		 if (navigator.appName=="Netscape") {
		  winW = window.innerWidth;
		  winH = window.innerHeight;
		 }
		 if (navigator.appName.indexOf("Microsoft")!=-1) {
		  winW = document.body.offsetWidth;
		  winH = document.body.offsetHeight;
		 }
		}
		
		width = winW;
		height = winH;
		getScreenSize();
		width=viewportwidth;
		height=viewportheight-50;
		scale=0;
		
		if((parseInt( imgheight))<height) {
			height=parseInt( imgheight) ;
		}
		scale= height / parseInt( imgheight);
		if((parseInt( imgwidth))<width) {
			width=parseInt( imgwidth) +30;
		}
		else if((parseInt( imgwidth))>width) {
			width=width-30;
		}
		width=(parseInt( imgwidth)*scale) +30;
		
		if((height + 200)<viewportheight) {
			height=height+200 ;
		}

//} // if(dhtmlwindowholder)


if(title!='') {
	// do it anyway !!
//	title=title+' - Image Viewer'+' width='+width+'px,height='+height+' imgwidth='+imgwidth+'px,imgheight='+imgheight;
//	title=title+' - Property Viewer s='+scale+' w='+width+' iw='+imgwidth+' h='+height+' ih='+imgheight;
	title=title+' - AHouse Viewer';
}
else {
	title='Image Viewer';
}
var center='1';
if(width<viewportwidth) {
	center='0';
//	left=(viewportwidth-width)-30;
	left=10;
	}
thePopup=dhtmlwindow.open('ajaxbox', 'ajax', '/scriptscore/pop/image-popup.php?view=HELP&ad='+adid+'&uploadid='+uploadid+'&viewportheight='+height, title, 'width='+width+'px,height='+height+'px,left='+left+'px,top=0px,resize=1,scrolling=1,center='+center);
} //putImagePopup


function putAdvancedPopup(page, screenheight, screenwidth)
{
closePopup();

var winW = 630, winH = 600;

if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}

width = 480;
height = winH;
if(screenheight>0) {
	height=screenheight-60;
	lastscreenheight=height;
}
else if(lastscreenheight) {
	height=lastscreenheight;
}
if(screenwidth>0) {
	width=screenwidth/2;
	lastscreenwidth=width;
}
else if(lastscreenwidth) {
	width=lastscreenwidth;
}
//height = 500;

thePopup=dhtmlwindow.open('ajaxbox', 'ajax', '/scriptscore/pop/search-popup.php?page='+page, 'AHouse Advanced Search', 'width='+width+'px,height='+height+'px,left=0px,top=0px,resize=1,scrolling=1');

} //putAdvancedPopup

function putEditAdPopup(ContextId)
{
closePopup();

var winW = 630, winH = 460;

if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}

width = 600;
height = 400;
thePopup=dhtmlwindow.open('ajaxbox', 'ajax', '/scriptscore/pop/editad-popup.php?ad='+ContextId, 'AHouse Ad Editor', 'width='+width+'px,height='+height+'px,left=0px,top=0px,resize=0,scrolling=1,center=1');

} //putEditAdPopup

 function ajaxeditad(){
	var mypostrequest=new ajaxRequest()
	mypostrequest.onreadystatechange=function(){
	if (mypostrequest.readyState==4){
		if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){
			if(mypostrequest.responseText=="OK") {
				closePopup();
				putMiniHelpPopup('SENTAD');
				}
			else {
				document.getElementById("result").innerHTML=mypostrequest.responseText
				}
	}
	else{
		alert("An error has occured making the request")
	}
	}
	}
	alert("test1")
	var pricevalue=encodeURIComponent(document.getElementById("Q49-Value").value)
	alert("test2")
	var statusvalue=encodeURIComponent(document.getElementByName("Q56-0").value)
	alert("test3")
	var visibilityvalue=encodeURIComponent(document.getElementByName("Q100-395-0").value)
	alert("test4")
	var parameters="price="+pricevalue+"&status="+statusvalue+"&visibility="+visibilityvalue
	alert("extra"+parameters)
	mypostrequest.open("POST", "/scriptscore/pop/ajax-editad.php", true)
	mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
	mypostrequest.send(parameters)
}  // ajaxeditad

function putAdList(thediv, pageid)
{
	Spry.Utils.updateContent(thediv, '/scriptscore/pop/showads.php?page='+pageid+'&update='+thediv);
} // putAdList

function putMessagePopup(msg)
{
closePopup();
thePopup=dhtmlmodal.open('ajaxbox', 'ajax', '/scriptscore/pop/message-popup.php?msg='+msg, '', 'width=100px,height=50px,left=0px,top=0px,resize=0,scrolling=0,center=1');
} //putMessagePopup

function putNewsPopup(newscode)
{
closeNewsPopup();
newsPopup=dhtmlwindow.open('ajaxbox', 'ajax', '/scriptscore/pop/message-popup.php?newscode='+newscode, '', 'width=500px,height=500px,left=0px,top=0px,resize=1,scrolling=1,center=1');
} //putNewsPopup


function addSelectedQuestion(questionid, value, updatediv)
{
//alert('q='+questionid+' v='+value+' u='+updatediv);
closePopup();
var winW = 630, winH = 660;

if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}

width = 0;
height = 0;
//var savevalue=encodeURIComponent(document.getElementById("QS"+questionid).checked)
var savevalue=encodeURIComponent(document.getElementById("QS"+questionid+"x"+value).checked)
//alert('v='+savevalue);
thePopup=dhtmlwindow.open('ajaxbox', 'ajax', '/scriptscore/pop/select-popup.php?question='+questionid+'&value='+value+'&state='+savevalue, '', 'width='+width+'px,height='+height+'px,left=0px,top=0px,resize=0,scrolling=0,center=0');
} // addSelectedQuestion

 function ajaxSelectedQuestion(){
	var mypostrequest=new ajaxRequest()
	mypostrequest.onreadystatechange=function(){
	if (mypostrequest.readyState==4){
		if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){
			if(mypostrequest.responseText=="OK") {
				closePopup();
				Spry.Utils.updateContent(updatediv, '/scriptscore/pop/showads.php?update='+updatediv);
				}
			else {
				document.getElementById("result").innerHTML=mypostrequest.responseText
				}
	}
	else{
		alert("An error has occured making the request")
	}
	}
	}
}  // ajaxSelectedQuestion

function saveLastGalleryImage(img)
{
	var today = new Date();
    var expire = new Date();
    var nDays=1;
    expire.setTime(today.getTime() + 3600000*24*nDays);
    document.cookie = "galleryimage"+"="+escape(img)+ ";path="+escape("/")+";expires="+expire.toGMTString();
} // saveLastGalleryImage

function putQuickAdPopup(xid)
{
if(quickPopup) {
	if(!quickPopup.isClosed) {
		quickPopup.load('ajax', '/scriptscore/pop/quickad-popup.php?ad='+xid, '');
		return;
		}
}
closePopup();

var winW = 630, winH = 460;

if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}

width = 290;
height = 220;
quickPopup=dhtmlwindow.open('ajaxbox', 'ajax', '/scriptscore/pop/quickad-popup.php?ad='+xid, '', 'width='+width+'px,height='+height+'px,left=0px,top=0px,resize=1,scrolling=1,center=1');

} //putQuickAdPopup

 	  function refreshMapContent(map, ename, resultid, scriptname, width, height)
	  {
        var row = document.getElementById(resultid);
	    var center = map.getCenter();
		var lat = center.lat();
		var lng = center.lng();
		var zoom = map.getZoom();
		
		CoreMap=map;
		
			var mypostrequest=new ajaxRequest()
	mypostrequest.onreadystatechange=function(){
	if (mypostrequest.readyState==4){
		if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){
			if(mypostrequest.responseText=="OK") {
				closePopup();
				document.location = "/user/index.php";
				}
			else {
				var parts = mypostrequest.responseText.split('^');
				if(parts.length>1) {
					refreshMarkers(map, lat, lng, parts[1]);
					}
//				document.getElementById(resultid).innerHTML=parts[0];
				var resid = document.getElementById(resultid);
				if(resid) {
					resid.innerHTML=parts[0];
				}
				}
	}
	else{
		alert("An error has occured making the request")
	}
	}
	}
var parameters="event="+ename+"&lat="+lat+"&lng="+lng+"&zoom="+zoom+"&height="+height+"&width="+width;
mypostrequest.open("POST", scriptname, true)
mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
mypostrequest.send(parameters)
} // refreshMapContent
	  
      function setupMapListener(map, name) {
        google.maps.event.addListener(map, name, function() {
		  if(name=='idle' || name=='maptypeid_changed') {
//				document.getElementById('local').innerHTML="poos";
//				document.getElementById('result').innerHTML="dunk";
			  var theBounds = map.getBounds();
			  var theNorthEast = theBounds.getNorthEast();
			  var theSouthWest = theBounds.getSouthWest();
			  var width = (theNorthEast.lat() - theSouthWest.lat()) * 100;
			  var height = (theNorthEast.lng() - theSouthWest.lng()) * 100;
			  refreshMapContent(map, name, 'AdMap', '/scriptscore/maplist.php', width, height);
//			  refreshMapContent(map, name, 'PropertyMap', '/scriptscore/mapzoom.php', width, height);
			  refreshMapContent(map, name, 'LocalMap', '/scriptscore/maplocal.php', width, height);
		  	}
        });
  } // setupMapListener
  
  function addMapMarker(lat, lng, title)
  {
	  markObj=new Object();
  } // addMapMarker
  
  function createMarker(map, lat, lng, key, tit, ad, propertytype)
  {
		var myLatLng = new google.maps.LatLng(lat, lng);
		var image = 'http://www.ahouse.uk.net/ahhamedia/maps/' + propertytype + '.png';
		var beachMarker = new google.maps.Marker({
		  position: myLatLng,
	      icon: image,
		  map: map,
			  title:tit
			});
			google.maps.event.addListener(beachMarker, 'click', function(event) {
			var fld = document.getElementById('mark'+key);
			if(fld) {
		  if(FocusMarker) {
			  FocusMarker.setIcon(FocusIcon);
		  	}
				  FocusIcon=beachMarker.getIcon();
		    	  var image = 'http://www.ahouse.uk.net/ahhamedia/maps/' + 'star' + '.png';
				  beachMarker.setIcon(image);
				  FocusMarker=beachMarker;
				  if(ad>0) {
					refreshMapContent(map, name, 'PropertyMap', '/scriptscore/mapzoom.php?ad=' + ad);
				  }
//				document.getElementById('LocalMap').style.visibility = "hidden";
			fld.style.backgroundColor='#F0F';
				if(LastMarkerField) {
					LastMarkerField.style.backgroundColor='#bac4ce';
					}
					LastMarkerField=fld;
			} // if(fld)
//			putQuickAdPopup(ad);

//			document.getElementById('tester').innerHTML = key + "<br>" + document.getElementById('tester').innerHTML;
		});		
		CurrentMarkers[ad] = beachMarker;
		return(beachMarker);
  } // createMarker
  
  function refreshMarkers(map, lat, lng, markerlist)
  {
	for (m in CurrentMarkers) { 
		var theMarker = CurrentMarkers[m];
		theMarker.setMap(null);
	}
	LastMarkerField=null;
	var pm = document.getElementById('PropertyMap');
	if(pm) {
//		pm.innerHTML='';
		}
	pm = document.getElementById('LocalMap');
	if(pm) {
		pm.style.visibility = "visible";
		}
	CurrentMarkers.length=0;
	FocusMarker=null;
	if(markerlist!='') {
	var markers = markerlist.split('~');
	for(n=0;n<markers.length;n++) {
//		alert("createMarker1 (" + markerlist + ")")
		var marker = markers[n].split('|');
		var beachMarker = createMarker(map, marker[0], marker[1], marker[2], marker[3], marker[4], marker[5]);
//		alert("createMarker2")
		}
	} // if(markers<>'')
  } // addMapMarker
  
  function selectMapMarker(key, itemnr)
  {
	  if(CoreMap) {
		  var marker = CurrentMarkers[key];
		  if(FocusMarker) {
			  FocusMarker.setIcon(FocusIcon);
		  	}
		  FocusMarker=marker;
		  if(marker) {
    	  var image = 'http://www.ahouse.uk.net/ahhamedia/maps/' + 'star' + '.png';
		  FocusIcon=marker.getIcon();
		  marker.setIcon(image);
 			var fld = document.getElementById('mark'+itemnr);
			if(fld) {
				if(key>0) {
			 	    refreshMapContent(CoreMap, 'click', 'PropertyMap', '/scriptscore/mapzoom.php?ad=' + key);
					}
			fld.style.backgroundColor='#F0F';
				if(LastMarkerField) {
					LastMarkerField.style.backgroundColor='#bac4ce';
					}
				LastMarkerField=fld;
				}
		  } //  if(marker)
	  	} //  if(CoreMap)
  } // selectMapMarker
