/*
	JAVASCRIPT FUNCTION INCLUDE
	KevinSink.com	
	03.26.09
	Rebecca Adamson
	River City Studio
*/

var d = window.document;

//////////////////////////////////////
//  GENERIC RETURN ELEMENT FUNCTION //
//////////////////////////////////////

function getE( v ) {
  // e is for element!
  e = false;
  
  if ( d.getElementById ) {
    e = d.getElementById( v );
  }
  else if ( d.all ) {
    e = d.all[ v ];
  }

  return e;
}

function flipCat() {
	e = getE( "cats" );
	e.submit();
}


/*
	AJAX BASE FUNCTIONALITY
*/

function GetXmlHttpObject( url,func ) {
  xmlHttp=null;
	nextFunc = "";

		if ( func != false ) nextFunc = func;
	else nextFunc = "";

  try { xmlHttp=new XMLHttpRequest(); } // Firefox, Opera 8.0+, Safari 
  catch (e) {
    // Internet Explorer
    try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
  }
  
  if (xmlHttp!=null) {
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
  }  
}

function stateChanged( ) {
  if (xmlHttp.readyState==4) {
		if (xmlHttp.status==200) {
			if ( div == "_EVAL_" ) {
					eval( xmlHttp.responseText );
			}
			else {
				document.getElementById(div).innerHTML=xmlHttp.responseText;
			}
	
			if ( nextFunc != "" ) {
				eval( nextFunc );
			}
		}
  }
}

function showList(table, divElem) {
  div = divElem;

  var url="getList.php";
  url=url+"?table="+table;
	url=url+"&div="+div;
  url=url+"&sid="+Math.random();
  
  GetXmlHttpObject( url );
  
} 

function showForm(table, divElem, fields, values, id, note) {
  e = document.getElementById( divElem );
  newHTML = "<form method='POST'>"

	v = ""
	f= ""

	switch (values.length ) {
		case 0: v = new Array();break;
		case 1: v = values;break;
		default: v = values.split(",");
	}

	switch (fields.length ) {
		case 0: f = new Array();break;
		case 1: f = fields;break;
		default: f = fields.split(",");
	}

	for( i=0;i<f.length;i++) {
		if( v.length == 0 ){
			thisValue = "";
		}
		else {
			thisValue = v[i]
		}

		if( f[i].indexOf("ID") != -1  )
			newHTML += "<p><input type='hidden' name='" + f[i] + "' value='" + thisValue + "' size='12'/></p>"
		else
			newHTML += "<p>*" + f[i] + " <input type='text' name='" + f[i] + "' value='" + thisValue + "' size='12'/></p>"
	} // end for

	newHTML += "<input type='submit' value='Save' /></p>"
	newHTML += "<input type='hidden' name='table' value=" + table + " />"
	newHTML += "<h5>" + note + "</h5>"

	if( values.length == 0 ) {
		newHTML += "<input type='hidden' name='action' value='addData' />"
	}
	else {
		newHTML += "<input type='hidden' name='action' value='editData' />"
	}
	newHTML += "</form>"
	
	
	e.innerHTML = newHTML;
  
} 

function showOptions(formatID, divElem) {
  div = divElem;

	var url="getOptions.php";
  url=url+"?formatID="+formatID;
	url=url+"&div="+div;
  url=url+"&sid="+Math.random();

  GetXmlHttpObject( url );
  
} 

function addBrowse( divElem, num ) {
  e = document.getElementById( divElem );
	
	newHTML = "";
	for( i=1;i<=num;i++ ) {
  	newHTML += "<input type='file' name='ImageFileName_"+i+"' />"
	}

	e.innerHTML = newHTML;
  
}

function showAccountForm( divElem) {
  div = divElem;

	var url="getFormFields.php";
	url=url+"?div="+div;
	url=url+"&sid="+Math.random();

	GetXmlHttpObject( url );

} 

function showPasswordForm( divElem) {
  div = divElem;

	var url="getPWForm.php";
	url=url+"?div="+div;
	url=url+"&sid="+Math.random();

	GetXmlHttpObject( url );

} 

function switchFields( div, accountType) {
	e = getE( div );

	switch( accountType ) {
		case 'admin': case 'educator': 
			e.innerHTML = "<p>Email: <input type='text' name='username' /></p>";
			e.innerHTML += "<p>Password: <input type='password' name='password' /></p>";
			e.innerHTML += "<p><input type='submit' value='Log In'></p>";
			e.innerHTML += "</form>";
			e.innerHTML += "<p><a href='requestPW.php'>Retrieve my password</a></p>";
			break;
		case 'student':
			e.innerHTML = "<p>Username: <input type='text' name='username' /></p>";
			e.innerHTML += "<p>Teacher Number or Password: <input type='password' name='password' /></p>";
			e.innerHTML += "<p><input type='submit' value='Log In'></p>";
			e.innerHTML += "</form>";
			break;
	}


}

function showEducatorForm( divElem, acctFirstName, acctLastName) {
  div = divElem;
	e = getE( div );
	e.innerHTML = "<p>*<strong>First Name: </strong><input type='text' name='FirstName' onkeyup='personName.value=this.value' /></p>";
	e.innerHTML += "<p>*<strong>Last Name: </strong><input type='text' name='LastName' /></p>";
	e.innerHTML += "<p>*<strong>Organization: </strong><input type='text' name='Organization' /></p>";
	e.innerHTML += "<p>*<strong>Email: </strong><input type='text' name='User' /></p>";
	e.innerHTML += "<p><strong>Note:  </strong>Educators will set their own passwords upon logging in for the first time. They will use the link in the email provided, OR they can request their temporary password from the Dashboard log in screen.</p>";
	e.innerHTML += "<p><input type='checkbox' name='SendNewAccountEmail' value='1'> Send this person an email notification that you've created an account for them. (See copy below.)</p>";
	e.innerHTML += "<div style='border:1px solid silver;padding:10px;margin-bottom:10px;height:100px;'><p>Hello, <input type='text' name='personName' style='border:0;background-color:#CA5629;font-size:9pt'></p><p>"+ acctFirstName +  " " + acctLastName + " has created an American Careers Online Curriculum Account for you.</p><p>Please use the link below to log in to your account</p><p><a href='/ACOC/requestPW.php'>Log in to my American Careers Online Account</a></p></div>";
} 

function showStudentForm( divElem, acctFirstName, acctLastName, teacherNumber) {
  div = divElem;
	e = getE( div );
	e.innerHTML += "<p><strong>Note: </strong>It is not necessary to set up specific student accounts unless you prefer to.  The alternative is to provide your students with the following Teacher Number ( ).  They will log in for the first time using this number and will be prompted to complete their account setup.  This teacher number can only be used so many times, depending on the number of licenses in your account.  Once the licenses are used up, no more students may register under this Teacher Number.</p><p>Be sure that you have set up a teacher account and that you are logged into that account before";
	e.innerHTML += "<p>*<strong>First Name: </strong><input type='text' name='FirstName' onkeyup='personName.value=this.value' /></p>";
	e.innerHTML += "<p>*<strong>Last Name: </strong><input type='text' name='LastName' /></p>";
	e.innerHTML += "<p>*<strong>Username: </strong><input type='text' name='User' /></p>";
	e.innerHTML += "<p><strong>Note:  </strong>Students may set up their own usernames and passwords. Simply provide your student with your Teacher Number below.  </p>";
	e.innerHTML += "<p><input type='checkbox' name='SendNewAccountEmail' value='1'> Send this person an email notification that you've created an account for them. (See copy below.)</p>";
	e.innerHTML += "<div style='border:1px solid silver;padding:10px;margin-bottom:10px;height:100px;'><p>Hello, <input type='text' name='personName' style='border:0;background-color:#CA5629;font-size:9pt'></p><p>"+ acctFirstName +  " " + acctLastName + " has created an American Careers Online Curriculum Account for you.</p><p>Please use the link below to log in to your account</p><p><a href='/ACOC/requestPW.php'>Log in to my American Careers Online Account</a></p></div>";
} 

function updateStatus( divElem, currentStatus, acctID, manageStudents ) {
  div = divElem;

	
	var url = "/ACOC/updateStatus.php"
	url = url + "?status=" + currentStatus;
	url = url + "&id=" + acctID;
  url = url + "&sid="+Math.random();
  url = url + "&manageStudents=" + manageStudents;

	GetXmlHttpObject( url );
  
}



function showFeatured( divElem ) {
	div = divElem;

	var url = "getFeatured.php"
	url = url + "?div="+div;
  url = url + "&sid="+Math.random();

	GetXmlHttpObject( url );

}

function showWeek( divElem ) {
	div = divElem;

	var url = "getWeek.php"
	url = url + "?div="+div;
  url = url + "&sid="+Math.random();

	GetXmlHttpObject( url );

}



/////
//	FOR DETERMING WHICH DIV IS CURRENTLY OPEN

var openDiv = "";

////////////////////////////////
//	CLOSE A DIV								//
////////////////////////////////

function closeDiv( div ) {
	e = getE( div );
	e.innerHTML = "";
}

//////////////////////////////////
//	GET A CUSTOMER'S FULL INFO	//
//////////////////////////////////

function getCustomerInfo( id ) {
	if ( openDiv.length ) closeDiv( openDiv );
	div = "cust_" + id;
	if ( openDiv != div ) {
		displayDiv = div;
		e = getE( div );
		e.innerHTML = "<div class='box'>Loading...</div>";
		getPage( "getCustomerInfo.php?id=" + id );
		openDiv = div;
	}
	else openDiv = "";
}








function imgSwap(img_name, img_src)
{
	getE(img_name).src = img_src;
}





/*
	PAGE ORDERING FUNCTIONS
*/


/////
//	FOR DETERMINING WHICH PAGE, IF ANY, HAS BEEN SELECTED
var selectedPage = false;
////////////////////////////////
//	REDRAW PAGE LIST FOR SUB	//
//	PAGE ORDERING							//
////////////////////////////////
function redrawPageList() {
	e = getE( "pageList" );
	e.innerHTML = "";
	for ( i=1, j=pages.length; i<j; i++ ) {
		var classStr = "";
		if ( selectedPage == i ) classStr = " class='selected'";
		s = "\n		<div style='border:thin black solid;width:120px;float:left;padding:5px;margin:1px;' onclick='selectPage( " + i + " );return false;'" + classStr + "><a href='#'>" + pageTitles[pages[i]] + "</a></div>";
		e.innerHTML+= s;
	}
}
////////////////////////////////
//	SELECT A PAGE TO MOVE			//
////////////////////////////////
function selectPage( i ) {
	
	if ( !selectedPage || selectedPage != i ) {
		selectedPage = i;	
	}
	else {
		selectedPage = false;
	}
	redrawPageList();
}
////////////////////////////////
//	MOVE A PAGE UP						//
////////////////////////////////
function up() {
	i = selectedPage;
	
	if ( i && i != 1 ) {
		p1 = pages[i];
		p2 = pages[i-1];
		
		pages[i-1] = p1;
		pages[i] = p2;
		
		selectedPage = i-1;
		redrawPageList();
	}
}
////////////////////////////////
//	MOVE A PAGE DOWN					//
////////////////////////////////
function down() {
	i = selectedPage;
	
	if ( i  && i != ( pages.length-1 ) ) {
		p1 = pages[i];
		p2 = pages[i+1];
		
		pages[i] = p2;
		pages[i+1] = p1;
		
		selectedPage = i+1;
		redrawPageList();
	}
}
////////////////////////////////
//	SAVE THE PAGE ORDER				//
////////////////////////////////
function savePages() {
	s = '';
	for ( i=1, j=pages.length; i<j; i++ ) {
		s+= pages[i] + "|" + i;
		if ( i < j-1 ) s+= "||";
	}

	d.forms['reorder'].pages.value = s;
	d.forms['reorder'].submit();
}







/*
	IMAGE GALLERY ORDERING FUNCTIONS
*/

/////
//	FOR DETERMINING WHICH CLASS, IF ANY, HAS BEEN SELECTED
var selectedImage = false;
////////////////////////////////
//	REDRAW IMAGE LIST FOR 
// IMAGE ORDERING	
////////////////////////////////
function redrawImageList() {
	e = getE( "imageList" );
	e.innerHTML = "";
	for ( i=0, j=imageArray.length; i<j; i++ ) {
		var pic = "";
		if ( selectedImage === i ) pic = " class='selected'";
		s = "\n		<p><a href='#'" + pic + " onclick='selectImage( " + i + " ); return false;'><img src='/_imgContent/thumb/" + urls[imageArray[i]] + "' alt='' /></a></p>";
		e.innerHTML+= s;
	}
}

////////////////////////////////
//	SELECT AN IMAGE TO MOVE			//
////////////////////////////////
function selectImage( i ) {
	
	if ( !selectedImage || selectedImage != i ) {
		selectedImage = i;	
	}
	else {
		selectedImage = false;
	}
	redrawImageList();
	
}


////////////////////////////////
//	MOVE AN IMAGE UP						//
////////////////////////////////
function upImage() {
	i = selectedImage;
	
	if ( i != 0 ) {
		ia1 = imageArray[i];
		ia2 = imageArray[i-1];
		
		imageArray[i-1] = ia1;
		imageArray[i] = ia2;
		
		selectedImage = i-1;
		redrawImageList();
	}
}
////////////////////////////////
//	MOVE AN IMAGE DOWN					//
////////////////////////////////
function downImage() {
	i = selectedImage;
	
	if ( i != ( imageArray.length-1 ) ) {
		ia1 = imageArray[i];
		ia2 = imageArray[i+1];
		
		imageArray[i] = ia2;
		imageArray[i+1] = ia1;
		
		selectedImage = i+1;
		redrawImageList();
	}
}
////////////////////////////////
//	SAVE THE IMAGE ORDER				//
////////////////////////////////
function saveImages() {
	s = "";
	for ( i=0, j=imageArray.length; i<j; i++ ) {
		s+= imageArray[i] + "|" + i;
		if ( i < j-1 ) s+= "||";
	}
	d.forms[1].imageOrder.value = s;
//	alert(d.forms[1].imageOrder.value);
	d.forms[1].submit();
}






////////////////////////////////
//	REDRAW IMAGE LIST FOR 
// ADVERTISERS
////////////////////////////////
function redrawAdvImageList() {
	e = getE( "imageList" );
	e.innerHTML = "";
	for ( i=0, j=imageArray.length; i<j; i++ ) {
		var pic = "";
		if ( selectedImage === i ) pic = " class='selected'";
		s = "\n		<p><a href='#'" + pic + " onclick='selectAdvImage( " + i + " ); return false;'><img src='/_imgAdvertisers/thumb/" + urls[imageArray[i]] + "' alt='' /></a></p>";
		e.innerHTML+= s;
	}
}

////////////////////////////////
//	SELECT AN ADVERTISER IMAGE TO MOVE			//
////////////////////////////////
function selectAdvImage( i ) {
	
	if ( !selectedImage || selectedImage != i ) {
		selectedImage = i;	
	}
	else {
		selectedImage = false;
	}
	redrawAdvImageList();
	
}

////////////////////////////////
//	MOVE AN ADVERTISER IMAGE UP						//
////////////////////////////////
function upAdvImage() {
	i = selectedImage;
	
	if ( i != 0 ) {
		ia1 = imageArray[i];
		ia2 = imageArray[i-1];
		
		imageArray[i-1] = ia1;
		imageArray[i] = ia2;
		
		selectedImage = i-1;
		redrawAdvImageList();
	}
}
////////////////////////////////
//	MOVE AN ADVERTISER IMAGE DOWN					//
////////////////////////////////
function downAdvImage() {
	i = selectedImage;
	
	if ( i != ( imageArray.length-1 ) ) {
		ia1 = imageArray[i];
		ia2 = imageArray[i+1];
		
		imageArray[i] = ia2;
		imageArray[i+1] = ia1;
		
		selectedImage = i+1;
		redrawAdvImageList();
	}
}












function removeElementById(remele) 
{
	remele = getE(remele);
	if (remele.parentNode && remele.parentNode.removeChild) 
	{
		remele.parentNode.removeChild(remele); 
	}
}


////////////////////////////////
//  SHOW / HIDE ELEMENT       //
////////////////////////////////

function toggleV(incoming_object_name,visibility) 
{
	g = getE(incoming_object_name);
	g.style.visibility = visibility;

  /*string = "";
  for ( a in g ) {
    string += a + "\n";
  } 
  alert( string );
  */		
}


/////////////////////////////////////
//  DISABLE / ENABLE FORM ELEMENT  //
/////////////////////////////////////

function toggleD(incoming_object_name,enable_status) 
{
	e = getE(incoming_object_name);
	e.disabled=enable_status
	
	/*
	if (enable_status == false) // enable 
		e.disabled=false;
	if (enable_status == true ) //disable
		e.disabled=true;
	*/
}



///////////////////////////////
// RADIO CHECKED VALUES      //
///////////////////////////////

function setCheckedValue(radioObj, newValue) 
{
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) 
	{
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++)
	{
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) 
		{
			radioObj[i].checked = true;
		}
	}
}
function getCheckedValue(radioObj)
{
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) 
	{
		if(radioObj[i].checked) 
		{
			return radioObj[i].value;
		}
	}
	return "";
}


//////////////////////////////
// SELECT LIST VALUES       //
//////////////////////////////

function setSelectListVal(selectID,setVal) 
{
	sel = getE(selectID);
	for (i=0; i<sel.options.length; i++) 
		if (sel.options[i].text == setVal)
			sel.selectedIndex = i;
}

function getSelectListVal(selectID)
{
	sel = getE(selectID);
	index = sel.selectedIndex;
	return sel[index].value;
}

function getSelectListText(selectID)
{
	sel = getE(selectID);
	index = sel.selectedIndex;
	return sel[index].text;
}

function showHide(elem,display) {
	e = document.getElementById(elem);
	e.style.visibility = display;
	}
	
function getNav(elem,id) {
	div = elem;

	var url="/getChildren.php";
	url=url+"?div="+div;
	url=url+"&id="+id;
	url=url+"&sid="+Math.random();

// 	alert( url);
	GetXmlHttpObject( url );
	
	}

function closeNav(elem,id) {
	div = elem;

	div.innerHTML = "";

// 	alert( url);

// 	GetXmlHttpObject( url );
// 	alert(div.id);
	div.style.visibility = hidden;
	}
	
////////////////////////////
//  COUNT CHARACTERS      //
//  IN A FORM FIELD       //
//  UPDATE COUNT          //
//  ACCORDINGLY           //
////////////////////////////

function count( f ) {
//   alert( f );
  c = 8000 - d.forms[0][f].value.length;
  e = d.getElementById( f );
  e.innerHTML = "<p>Characters remaining: " + c + "</p>";
  if ( c < 0 ) {
    e.innerHTML = "<p class='red'>Out of Space!</p>";
  }
}

////////////////////////////
//  COUNT CHARACTERS 
//  IN A FORM FIELD  
//  AND CONTROL WHERE
//   COUNT DISPLAYS
////////////////////////////

function count( fld, display, lngth ) {
   sd = d.getElementById( fld ).value.length;
   c = lngth - sd;
   sdv = d.getElementById( fld ).value;
   sc =  d.getElementById( display ).innerHTML;
   msg = "";
   if( c < 0 ) 
      msg += "Maximum exceeded";
   else
      msg += " " + c + " characters left";
   d.getElementById( display ).innerHTML = sd + " ( " + msg + " ) ";
   d.getElementById( fld ).value = sdv;
 }
 
 
 
 


	////////////////////////////////////////
	//	GENERAL CHARACTER COUNTER
	////////////////////////////////////////
	
	function countChars(e, maximum) {
		var totalChars = e.value.length;
		if (totalChars > maximum) {
			e.style.border = "2px solid red";
			e.value = e.value.substr(0,maximum);
		}
	}
	
////////////////////////////
// CHECK ( checkboxes )
///////////////////////////
var checkflag = "false";

function check(f) {
  if (checkflag == "false") {
      for (i = 0; i < f.length; i++) {
          if (f[i].name != "Undecided" ) {
              f[i].checked = true;
          }
      }
      
      checkflag = "true";
      return "Uncheck All";     }
  
  else {
      for (i = 0; i < f.length; i++) {
          if (f[i].name != "Undecided" ) {
              f[i].checked = false;             }
      }
  
      checkflag = "false";
      return "Check All";     }
}



	/* ----------------------- General Click Function For Div Buttons ----------------------------- */
	
function gotoTarget( incomingUrl ) {
	window.location = incomingUrl;
}



	/* ------------------------- Need 2 Know Function ----------------------------- */
	
// n2KArray is defined in the respective students and educators situation pages
	
function nextN2K() {
	n2kCount++;
	
	if(n2kCount > (n2kArray.length - 1)) {
		n2kCount = 0;
	}
	
	needBox = document.getElementById("need2KnowBox");
	needBox.innerHTML = n2kArray[n2kCount];
}

function prevN2K() {
	n2kCount--;
	
	if(n2kCount < 0) {
		n2kCount = (n2kArray.length - 1);
	}
	
	needBox = document.getElementById("need2KnowBox");
	needBox.innerHTML = n2kArray[n2kCount];
}



	/* --------------------- Tool Tip Function For the License Management Page ----------------------- */
	
function showToolTip(e, incomingParagraph) {
	toolTipVar = document.getElementById("toolTip");
	toolTipVar.innerHTML = incomingParagraph;
	toolTipVar.style.display = "block";
	
	var evt = window.event || e;
	
	toolTipVar.style.top = (evt.clientY - (toolTipVar.offsetHeight/2)) + "px";
	toolTipVar.style.left = (evt.clientX - (toolTipVar.offsetWidth/3)) + "px";
}

function hideToolTip () {
	document.getElementById("toolTip").style.display = "none";	;
}

/*------------------------- Progress Indicators for Student Downloads ------------------------------*/

function markDownloaded(studentID, downloadID, situationID, projectID) {

	divElem = getE("download"+downloadID);
	divElem.innerHTML = "<img src='/admin/_img/check_green.jpg'>";

	var url="/students/markProgress.php";
  url=url+"?downloaded=1";
	url=url+"&DownloadID="+downloadID;
	url=url+"&StudentID="+studentID;
	url=url+"&SituationID="+situationID;
	url=url+"&ProjectID="+projectID;	
	url=url+"&Downloaded=1";	
  url=url+"&sid="+Math.random();

  GetXmlHttpObject( url );
}

function markUploaded(studentID, downloadID, situationID, projectID) {
// 	divElem = getE("upload"+downloadID);
// 	divElem.innerHTML = "<img src='/admin/_img/check_green.jpg'>";

	divElem2 = getE("fileUpload"+downloadID);
	divElem2.innerHTML = "<form action='uploadFile.php' method='POST' enctype='multipart/form-data'><input type='hidden' name='StudentID' value='"+studentID+"'/><input type='hidden' name='DownloadID' value='"+downloadID+"'/><input type='hidden' name='SituationID' value='"+situationID+"'/><input type='hidden' name='ProjectID' value='"+projectID+"'/><input type='file' name='file' /><input type='submit' value='upload' /></form>";
// 	var url="/students/markProgress.php";
//   url=url+"?downloaded=1";
// 	url=url+"&DownloadID="+downloadID;
// 	url=url+"&StudentID="+studentID;
// 	url=url+"&SituationID="+situationID;
// 	url=url+"&ProjectID="+projectID;	
//   url=url+"&sid="+Math.random();
// 
//   GetXmlHttpObject( url );
}



	/* ------------------ sfHover function for the dropdown in IE ----------------------- */
	
sfHover = function() {
	var sfEls = document.getElementById("topNav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


/* Interactive Map functions */

function getSomething(pos) {
	alert(pos.x);
	//query db to get ranges

	//if any range is between pos x and y, that's the areaID we need
// 	var url="/admin/map/getAreaFromRange.php";
//   url=url+"?x=" + pos.x;
// 	url=url+"&y="+ pos.y;
//   url=url+"&sid="+Math.random();
// 
//   GetXmlHttpObject( url );
}

function deleteRegion(pos) {
// 	alert(pos.x);
	//query db to get ranges

	//if any range is between pos x and y, that's the areaID we need
	var url="/admin/map/delete.php";
  url=url+"?x=" + pos.x;
	url=url+"&y="+ pos.y;
  url=url+"&sid="+Math.random();

// 	alert(url);
  GetXmlHttpObject( url );
// 	location.href="/admin/map/map.php";
}