//New main.js - replaces smartmenus.js Now uses Smartmenus 6.03
//Includes a bunch of parts - combined into one big JS file to reduce the number of objects.
//Includes: a large array of US county information.
//Might move smartmenus into a seperate JS file - now that our object count is very high (using lots of JS libraries for AJAX and other stuff).
//sBaseurl - used for tinyurls
//global variables
if (substr_count(window.location.href , 'energyjustice.net' , 0, 200))
{
var sServer="http://www.energyjustice.net/map/";
var sClienturl="http://www.energyjustice.net/map/";
var sBaseurl="http://www.energyjustice.net/";
}
else
{
var sServer="http://localhost/ejm/";
var sClienturl="http://localhost/ejm/";
var sBaseurl="http://localhost/ejm/";
}
var geoXml;
var toggleState = 1;
var iFacilitystep=1;
//hopefully makes it a global variable, so it can be access within function(data) in SaveData
var sHtml_id="test";
var sub_facility="";
var sub_childfacilities="";
var sub_corporation="";
var sub_people="";
var sub_groups="";
var sub_school="";
var sub_resource="";
var sub_link="";
var sub_videolink="";
var sub_tag="";
var sub_phile="";
var sub_control="";
var sub_unit="";
var sub_unitstatus="";
var sub_fuel="";
var sub_product="";
var datatable_search_facility="";
var datatable_search_groups="";
var datatable_search_people="";
var datatable_search_resource="";
var datatable_search_corporation="";
//For editing people/group to facility level of involvement
function EditInvolvement (iLevel, iSubid, sSubidname, iMainid, sMainidname, sRelatedtable)
{
var sLevel=$("#"+iSubid+"_level").html();
if (sLevel=='Interested') iLevel=1;
else if (sLevel=='Active') iLevel=0;
//gsRelatedtable - either people or groups
$.post(sServer+"server-test/webservice/ajax_editrelation.php",
{
'gsLoginhash': aEditarray['sLoginhash'],
'giSubid': iSubid,
'gsSubidname': sSubidname,
'giMainid': iMainid,
'gsMainidname': sMainidname,
'giLevel': iLevel,
'giUid': aEditarray['iUid'],
'giSuperuser': aEditarray['iSuperuser'],
'gsRelatedtable': sRelatedtable
},
function (data)
{
//error
if (data==0)
{
}
else if (data==1)
{
if (iLevel==0) $("#"+iSubid+"_level").html("Interested");
else $("#"+iSubid+"_level").html("Active");
}
}
);
//need to disable the regular form action... this works!
return false;
}
//For removing online account - for people and groups, based on editinvolvement
function RemoveOnlineAccount (iMainid, sMainidname)
{
$.post(sServer+"server-test/webservice/ajax_removeaccount.php",
{
'gsLoginhash': aEditarray['sLoginhash'],
'giMainid': iMainid,
'gsMainidname': sMainidname,
'giUid': aEditarray['iUid'],
'giSuperuser': aEditarray['iSuperuser']
},
function (data)
{
//error
if (data==0)
{
}
else if (data==1)
{
alert ("Account removed");
window.location.href='index.php?giLogout=1';
}
}
);
//need to disable the regular form action... this works!
return false;
}
//javascript passes objects by reference, but simpler variables by value - since aEditarray is an object this should work...
//copied from AddRelation
function Init_aEditarray(aEditarray)
{
//creates rest of editarray object (some of it is created earlier in php)
aEditarray['sUsername']='';
aEditarray['sPassword']='';
aEditarray['sAdd']='';
aEditarray['sEdit']='';
aEditarray['sDelete']='';
aEditarray['iAddRel']='0';
aEditarray['iAddRelid']='';
aEditarray['iAddRelTable']='';
aEditarray['iDeleteRel']='';
aEditarray['iUnsubscribe']='';
aEditarray['sAddstate']='';
aEditarray['iDeleteid']='';
aEditarray['sDeletetable']='';
//this serialize function causes spaces to be replaced with pluses
//I could server-side replace + with space, assumes that the user didn't add a + character for regular reasons...
aEditarray['sPost']=$("form").serialize();
aEditarray['sGet']='';
aEditarray['sFiles']='';
aEditarray['aiCurpage']=new Array();
aEditarray['iDownloadid']=0;
aEditarray['sIp']=0;
aEditarray['iTraffic']=0;
aEditarray['sSitedir']='';
aEditarray['sState']='';
}
//maintable and mainid - already set by php
//Adds a Relation - for subforms using automcomplete... based on DeleteRelation
//oDatatable - sub_facility or others...
//sDeleteidname - delete idname - eg. iFacilityid
function AddRelation(sAddtable, iAddid, oDatatable, sAddidname)
{
Init_aEditarray(aEditarray);
//overwrites some of the add related variables
aEditarray['iAddRel']='1';
aEditarray['iAddRelid']=iAddid;
aEditarray['iAddRelTable']=sAddtable;
//call webservice
//trying it without serializing aEditarray - as there doesn't appear to be a js serialize function!
var encoded = $.toJSON(aEditarray);
//giAjax might not need quotes
$.post(sServer+"server-test/webservice/ajax_addrelation.php",
{ 'giAjax': "1", 'aEditarray': encoded },
function (data)
{
var myObject = eval('(' + data + ')');
if (myObject['iExit']==1)
{
$('#'+sAddtable+'_message').show;
$('#'+sAddtable+'_message').html(myObject['sClient']);
}
else if (myObject['iExit']!=null)
{
//hide user message for that subtable_message
$('#'+sAddtable+'_message').hide();
var oSettings = oDatatable.fnSettings();
var aiNew = oDatatable.fnAddData(myObject['aRow']);
var nNewTr = oSettings.aoData[ aiNew[0] ].nTr;
oSettings.aoData[ aiNew[0] ].nTr.id=sAddidname+'_'+iAddid;
//show table - in case it was hidden before, if there were zero results
$('#sub-'+sAddtable).show();
$('#sub-'+sAddtable+'_wrapper').show();
$('#sub-'+sAddtable+'_info').show();
$('#sub-'+sAddtable+'_paginate').show();
//id=autocomplete_$sSubtable - hopefully sets the value of the input text box to ''
$('#autocomplete_'+aEditarray['iAddRelTable']).val('');
$('#autocomplete_'+aEditarray['iAddRelTable']).blur();
}
}
);
//need to disable the regular form action... this works!
return false;
}
//add links objects and add relation between the facility and the link
//get values from gsUrl_link, gsName_link and gsDescription_link
//based on addrelation
//Note: need to stripslashes or possibly jsondecoding will fix the sUrl value...
//Returns:
// {"sClient":" Link added. It will be listed publicly within a week (unless you requested privacy or it contradicts the network mission). ",
// "iExit":0,"sUrl":"http:\/\/tes65.org","sName":"asdfad"}
//set input fields to empty, once the AJAX has executed
function AddLink()
{
Init_aEditarray(aEditarray);
var sAddtable='link';
var iAddid='';
var sAddidname='iLinkid';
var oDatatable_addlink=sub_link;
//call webservice
//trying it without serializing aEditarray - as there doesn't appear to be a js serialize function!
var encoded = $.toJSON(aEditarray);
//giAjax might not need quotes
$.post(sServer+"server-test/webservice/ajax_addlink.php",
{ 'giAjax': "1", 'aEditarray': encoded, 'giAddlink' : "1" },
function (data)
{
var myObject = eval('(' + data + ')');
if (myObject['iExit']==1)
{
$('#'+sAddtable+'_message').show;
$('#'+sAddtable+'_message').html(myObject['sClient']);
}
else if (myObject['iExit']!=null)
{
//hide user message for that subtable_message
$('#'+sAddtable+'_message').hide();
var oSettings = oDatatable_addlink.fnSettings();
var aiNew = oDatatable_addlink.fnAddData(myObject['aRow']);
var nNewTr = oSettings.aoData[ aiNew[0] ].nTr;
//need to get iAddid out of myObject
iAddid=myObject['iAddid'];
oSettings.aoData[ aiNew[0] ].nTr.id=sAddidname+'_'+iAddid;
//show table - in case it was hidden before, if there were zero results
$('#sub-'+sAddtable).show();
$('#sub-'+sAddtable+'_wrapper').show();
$('#sub-'+sAddtable+'_info').show();
$('#sub-'+sAddtable+'_paginate').show();
}
//set input fields to empty
$('#url_link').val('');
$('#name_link').val('');
$('#description_link').val('');
}
);
//need to disable the regular form action... unsure if this works...
return false;
}
//based on AddLink
function AddVideoLink()
{
Init_aEditarray(aEditarray);
var sAddtable='videolink';
var iAddid='';
var sAddidname='iVid';
var oDatatable_addlink=sub_videolink;
//call webservice
//trying it without serializing aEditarray - as there doesn't appear to be a js serialize function!
var encoded = $.toJSON(aEditarray);
//giAjax might not need quotes
$.post(sServer+"server-test/webservice/ajax_addlink.php",
{ 'giAjax': "1", 'aEditarray': encoded, 'giAddvideolink' : "1" },
function (data)
{
var myObject = eval('(' + data + ')');
if (myObject['iExit']==1)
{
$('#'+sAddtable+'_message').show;
$('#'+sAddtable+'_message').html(myObject['sClient']);
}
else if (myObject['iExit']!=null)
{
//hide user message for that subtable_message
$('#'+sAddtable+'_message').hide();
var oSettings = oDatatable_addlink.fnSettings();
var aiNew = oDatatable_addlink.fnAddData(myObject['aRow']);
var nNewTr = oSettings.aoData[ aiNew[0] ].nTr;
//need to get iAddid out of myObject
iAddid=myObject['iAddid'];
oSettings.aoData[ aiNew[0] ].nTr.id=sAddidname+'_'+iAddid;
//show table - in case it was hidden before, if there were zero results
$('#sub-'+sAddtable).show();
$('#sub-'+sAddtable+'_wrapper').show();
$('#sub-'+sAddtable+'_info').show();
$('#sub-'+sAddtable+'_paginate').show();
}
//set input fields to empty
$('#url_link').val('');
$('#name_link').val('');
//$('#description_link').val('');
}
);
//need to disable the regular form action... unsure if this works...
return false;
}
//based on AddLink, loosely?
//add a photocaption
//send sLoginhash, sDescription, iPhoid
//aEditarray['sLoginhash'], - get sDescription from the user-entered field.
function AddPhotoCaption(iPhoid)
{
//get sDescription from the input field.
sDescription=$('#photo_description').val();
$.post(sServer+"server-test/webservice/ajax_addcaption.php",
{ 'giAjax': "1", 'gsLoginhash' : aEditarray['sLoginhash'], 'gsDescription': sDescription, 'giPhoid':iPhoid },
function (data)
{
var myObject = eval('(' + data + ')');
if (myObject['iExit']==1)
{
//error message
//alert ("fail");
}
else if (myObject['iExit']!=null)
{
//some success message, or change of display to make it obvious that it went through - should i leave the user in edit mode? I guess so.
//alert ("success");
//could change the Add Caption to say Edit Caption
//$('#addcaption-submit').val('Edit Caption');
//for photogallery need to do something else... like say "added" in alert or just simply on the screen
if (substr_count(window.location.href , 'photogallery' , 0, 200))
{
$('#added_caption_'+iPhoid).show();
}
else
{
//set display view caption - this only works for people/groups in editview
$('#photocaption_display').html(sDescription);
DisplayMode('photo');
}
}
}
);
//need to disable the regular form action... unsure if this works...
return false;
}
//based on addlink
//doesn't use datatable - just a list of tags - bulleted style
function AddTag(iDeletebutton)
{
//only executes if the add tag input box is non-null
if ($('#gsTag').val()!='')
{
Init_aEditarray(aEditarray);
var sAddtable='tag';
var iAddid='';
var sAddidname='iTagid';
var oDatatable_addlink=sub_tag;
//call webservice
//trying it without serializing aEditarray - as there doesn't appear to be a js serialize function!
var encoded = $.toJSON(aEditarray);
//giAjax might not need quotes
$.post(sServer+"server-test/webservice/ajax_addtag.php",
{ 'giAjax': "1", 'aEditarray': encoded, 'giAddtag' : "1", 'giDeletebutton':iDeletebutton },
function (data)
{
var myObject = eval('(' + data + ')');
if (myObject['iExit']==1)
{
$('#'+sAddtable+'_message').show;
$('#'+sAddtable+'_message').html(myObject['sClient']);
}
else if (myObject['iExit']!=null)
{
//hide user message for that subtable_message
$('#'+sAddtable+'_message').hide();
var oSettings = oDatatable_addlink.fnSettings();
var aiNew = oDatatable_addlink.fnAddData(myObject['aRow']);
var nNewTr = oSettings.aoData[ aiNew[0] ].nTr;
//need to get iAddid out of myObject
iAddid=myObject['iAddid'];
oSettings.aoData[ aiNew[0] ].nTr.id=sAddidname+'_'+iAddid;
//show table - in case it was hidden before, if there were zero results
$('#sub-'+sAddtable).show();
$('#sub-'+sAddtable+'_wrapper').show();
$('#sub-'+sAddtable+'_info').show();
$('#sub-'+sAddtable+'_paginate').show();
//empty tag input box
$('#gsTag').val('');
}
}
);
}
return false;
}
//based on addtag
function AddUnitStatus()
{
Init_aEditarray(aEditarray);
var sAddtable='unitstatus';
var iAddid='';
var sAddidname='iUsid';
var oDatatable_addlink=sub_unitstatus;
aEditarray['iAddRelTable']='unitstatus';
//call webservice
//trying it without serializing aEditarray - as there doesn't appear to be a js serialize function!
var encoded = $.toJSON(aEditarray);
//giAjax might not need quotes
$.post(sServer+"server-test/webservice/ajax_addunitstatus.php",
{ 'giAjax': "1", 'aEditarray': encoded, 'giAddunitstatus' : "1" },
function (data)
{
var myObject = eval('(' + data + ')');
if (myObject['iExit']==1)
{
$('#'+sAddtable+'_message').show;
$('#'+sAddtable+'_message').html(myObject['sClient']);
}
else if (myObject['iExit']!=null)
{
iAddid=myObject['iAddid'];
//hide user message for that subtable_message
$('#'+sAddtable+'_message').hide();
var oSettings = oDatatable_addlink.fnSettings();
var aiNew = oDatatable_addlink.fnAddData(myObject['aRow']);
var nNewTr = oSettings.aoData[ aiNew[0] ].nTr;
//need to get iAddid out of myObject
iAddid=myObject['iAddid'];
oSettings.aoData[ aiNew[0] ].nTr.id=sAddidname+'_'+iAddid;
//show table - in case it was hidden before, if there were zero results
$('#sub-'+sAddtable).show();
$('#sub-'+sAddtable+'_wrapper').show();
$('#sub-'+sAddtable+'_info').show();
$('#sub-'+sAddtable+'_paginate').show();
}
}
);
//need to disable the regular form action... unsure if this works...
return false;
}
//based on addunitstatus
function AddFuel()
{
Init_aEditarray(aEditarray);
var sAddtable='fuelproduct';
var iAddid='';
//note for products - use a different sAddidname - for use in datatables, in case the same thing goes in and out of the facility
var sAddidname='iFuel';
var oDatatable_addlink=sub_fuel;
aEditarray['iAddRelTable']='fuelproduct';
//call webservice
//trying it without serializing aEditarray - as there doesn't appear to be a js serialize function!
var encoded = $.toJSON(aEditarray);
//giAjax might not need quotes
$.post(sServer+"server-test/webservice/ajax_addfuel.php",
{ 'giAjax': "1", 'aEditarray': encoded, 'giAddfuel' : "1" },
function (data)
{
var myObject = eval('(' + data + ')');
if (myObject['iExit']==1)
{
$('#fuelproduct_message').html(myObject['sClient']);
$('#fuelproduct_message').show;
alert (myObject['sClient']);
}
else if (myObject['iExit']!=null)
{
iAddid=myObject['iAddid'];
//hide user message for that subtable_message
$('#fuelproduct_message').hide();
var oSettings = oDatatable_addlink.fnSettings();
var aiNew = oDatatable_addlink.fnAddData(myObject['aRow']);
var nNewTr = oSettings.aoData[ aiNew[0] ].nTr;
//need to get iAddid out of myObject
iAddid=myObject['iAddid'];
oSettings.aoData[ aiNew[0] ].nTr.id=sAddidname+'_'+iAddid;
//show table - in case it was hidden before, if there were zero results
$('#sub-fuel').show();
$('#sub-fuel_wrapper').show();
$('#sub-fuel_info').show();
$('#sub-fuel_paginate').show();
}
}
);
//need to disable the regular form action... unsure if this works...
return false;
}
//based on AddFuel
function AddProduct()
{
Init_aEditarray(aEditarray);
var sAddtable='fuelproduct';
var iAddid='';
//note for products - use a different sAddidname - for use in datatables, in case the same thing goes in and out of the facility
var sAddidname='iProduct';
var oDatatable_addlink=sub_product;
aEditarray['iAddRelTable']='fuelproduct';
//call webservice
//trying it without serializing aEditarray - as there doesn't appear to be a js serialize function!
var encoded = $.toJSON(aEditarray);
//giAjax might not need quotes
$.post(sServer+"server-test/webservice/ajax_addproduct.php",
{ 'giAjax': "1", 'aEditarray': encoded, 'giAddproduct' : "1" },
function (data)
{
var myObject = eval('(' + data + ')');
if (myObject['iExit']==1)
{
$('#fuelproduct_product_message').html(myObject['sClient']);
$('#fuelproduct_product_message').show;
alert (myObject['sClient']);
}
else if (myObject['iExit']!=null)
{
iAddid=myObject['iAddid'];
//hide user message for that subtable_message
$('#fuelproduct_product_message').hide();
var oSettings = oDatatable_addlink.fnSettings();
var aiNew = oDatatable_addlink.fnAddData(myObject['aRow']);
var nNewTr = oSettings.aoData[ aiNew[0] ].nTr;
//need to get iAddid out of myObject
oSettings.aoData[ aiNew[0] ].nTr.id=sAddidname+'_'+iAddid;
//show table - in case it was hidden before, if there were zero results
$('#sub-product').show();
$('#sub-product_wrapper').show();
$('#sub-product_info').show();
$('#sub-product_paginate').show();
}
}
);
//need to disable the regular form action... unsure if this works...
return false;
}
//Based on Addlink, note lots of repetition with how aEditarray is defined....
function AddAdmin()
{
Init_aEditarray(aEditarray);
var sAddtable='control';
var iAddid='';
var sAddidname='';
var oDatatable_addadmin=sub_control;
//call webservice
//trying it without serializing aEditarray - as there doesn't appear to be a js serialize function!
var encoded = $.toJSON(aEditarray);
//giAjax might not need quotes
$.post(sServer+"server-test/webservice/ajax_add_control.php",
{ 'giAjax': "1", 'aEditarray': encoded, 'giAddadmin' : "1" },
function (data)
{
var myObject = eval('(' + data + ')');
if (myObject['iExit']==1)
{
$('#'+sAddtable+'_message').show;
$('#'+sAddtable+'_message').html(myObject['sClient']);
}
else if (myObject['iExit']!=null)
{
//hide user message for that subtable_message
$('#'+sAddtable+'_message').hide();
var oSettings = oDatatable_addadmin.fnSettings();
var aiNew = oDatatable_addadmin.fnAddData(myObject['aRow']);
var nNewTr = oSettings.aoData[ aiNew[0] ].nTr;
//need to get iAddid out of myObject
iAddid=myObject['iAddid'];
oSettings.aoData[ aiNew[0] ].nTr.id=sAddidname+'_'+iAddid;
//show table - in case it was hidden before, if there were zero results
$('#sub-'+sAddtable).show();
$('#sub-'+sAddtable+'_wrapper').show();
$('#sub-'+sAddtable+'_info').show();
$('#sub-'+sAddtable+'_paginate').show();
}
}
);
return false;
}
//Oppose Facility - user states their opposition to facility, add to facility_people table
function OpposeFacility(iFacilityid, sLoginhash, iUid, iPid, sFname, sLname)
{
sAddtable='people';
oDatatable=sub_people;
//giAjax might not need quotes
$.post(sServer+"server-test/webservice/ajax_opposefacility.php",
{'giFacilityid': iFacilityid, 'gsLoginhash': sLoginhash, 'giUid': iUid},
function (data)
{
var myObject = eval('(' + data + ')');
//error message
if (myObject['iExit']==1)
{
$('#'+sAddtable+'_message').show;
$('#'+sAddtable+'_message').html(myObject['sClient']);
}
//add them to sub-people datatable
//so need their name - which is in session['user'], and could be used as function parameters...
//sAddidname = 'iPid'
//iAddid = $session['user']['giPid'];
else if (myObject['iExit']==0)
{
//hide user message for that subtable_message
$('#'+sAddtable+'_message').hide();
var oSettings = oDatatable.fnSettings();
var aiNew = oDatatable.fnAddData(myObject['aRow']);
//var aiNew = {"sFname": sFname, "sLname":sLname};
var nNewTr = oSettings.aoData[ aiNew[0] ].nTr;
oSettings.aoData[ aiNew[0] ].nTr.id='iPid_'+iPid;
//show table - in case it was hidden before, if there were zero results
$('#sub-'+sAddtable).show();
$('#subform370_'+sAddtable+'_wrapper').show();
$('#sub-'+sAddtable+'_wrapper').show();
$('#sub-'+sAddtable+'_info').show();
$('#sub-'+sAddtable+'_paginate').show();
}
}
);
//need to disable the regular form action... this works!
return false;
}
//maintable and mainid - already set by php
//Deletes a Relation - for subforms...
//oDatatable - sub_facility or others...
//sDeleteidname - delete idname - eg. iFacilityid
function DeleteRelation(sDeletetable, iDeleteid, oDatatable, sDeleteidname)
{
Init_aEditarray(aEditarray);
aEditarray['iDeleteid']=iDeleteid;
aEditarray['sDeletetable']=sDeletetable;
//we don't need sPost so it is set to empty
aEditarray['sPost']='';
//call webservice
//trying it without serializing aEditarray - as there doesn't appear to be a js serialize function!
var encoded = $.toJSON(aEditarray);
//var JSON_aEditarray=JSON.stringify(encoded);
//giAjax might not need quotes
$.post(sServer+"server-test/webservice/ajax_deleterelation.php",
{ 'giAjax': "1", 'aEditarray': encoded },
function (data)
{
var myObject = eval('(' + data + ')');
if (myObject['iExit']==1)
{
$('#'+sDeletetable+'_message').show;
$('#'+sDeletetable+'_message').html(myObject['sClient']);
}
else if (myObject['iExit']!=null)
{
$('#'+sDeletetable+'_message').hide();
if ((sDeleteidname=='iFuelproductid') && (oDatatable==sub_fuel))
{
sDeleteidname='ifuel';
}
else if ((sDeleteidname=='iFuelproductid') && (oDatatable==sub_product))
{
sDeleteidname='iproduct';
}
var position=oDatatable.fnGetPosition( $("#"+sDeleteidname+"_"+iDeleteid)[0])
oDatatable.fnDeleteRow(position);
}
//hide table if there are zero rows
if (oDatatable.fnSettings().fnRecordsDisplay()==0)
{
$('#sub-'+sDeletetable).hide();
$('#sub-'+sDeletetable+'_wrapper').hide();
$('#sub-'+sDeletetable+'_info').hide();
$('#sub-'+sDeletetable+'_paginate').hide();
}
}
);
//need to disable the regular form action... this works!
return false;
}
//Calls ajax service to save data
//sends sEditarray, as a serialized array
//need to create a editarray like object in javascript...
//returns: html for the section that was edited
//when finished: rewrite the html for the editview and displayview of sHtml_id
//if sHtml_id_new == 'privacy' then we are on the setprivacy.php page. Send a special setprivacy=1 to ajax_edit, so we can trigger a serverside function.
function SaveData(sHtml_id_new)
{
Init_aEditarray(aEditarray);
sHtml_id=sHtml_id_new;
aEditarray['sEdit']='1';
//call webservice
//trying it without serializing aEditarray - as there doesn't appear to be a js serialize function!
var encoded = $.toJSON(aEditarray);
if (sHtml_id_new=='privacy')
{
$.post(sServer+"server-test/webservice/ajax_edit.php",
{ 'giAjax_edit': "1", 'giSetprivacy':"1", 'aEditarray': encoded , 'sHtml_id': sHtml_id},
function (data)
{
var myObject = eval('(' + data + ')');
//if fail - write out error message, stay in editview - eg. if data['iExit']==1
//hmm, unsure how to get multiple variables returned... maybe return a json array, and then parse it
//haven't teseted this part yet...
if (myObject['iExit']==1)
{
$("#clientmessage_wide").html(myObject['sClient']).show;
}
else
{
//success - write out html to displayview and editview profileboxes - in which case data might be an array with two strings in it
//set clientmessage div to empty (if there isn't any error) - it is used by step 3 I think... tends to say "we updated the record."
$("#clientmessage_wide").html('Saved').show();
}
}
);
}
else
{
//giAjax might not need quotes
$.post(sServer+"server-test/webservice/ajax_edit.php",
{ 'giAjax_edit': "1", 'aEditarray': encoded , 'sHtml_id': sHtml_id},
function (data)
{
var myObject = eval('(' + data + ')');
//if fail - write out error message, stay in editview - eg. if data['iExit']==1
//hmm, unsure how to get multiple variables returned... maybe return a json array, and then parse it
//haven't teseted this part yet...
if (myObject['iExit']==1)
{
$("#clientmessage_wide").html(myObject['sClient']).show;
}
else
{
//success - write out html to displayview and editview profileboxes - in which case data might be an array with two strings in it
//set clientmessage div to empty (if there isn't any error) - it is used by step 3 I think... tends to say "we updated the record."
//if we do this, we need to increase the top margin - replace class='main_smalltopmargin' with 'main'
$("#clientmessage_wide").hide();
$(".main_smalltopmargin").removeClass('main_smalltopmargin').addClass('main');
$("#"+sHtml_id).html(myObject['sHtml']);
//these two lines are from displaymode, but I didn't want to use return false...
$("#"+sHtml_id+"_display").removeClass("hidebox").addClass("showbox");
$("#"+sHtml_id+"_edit").removeClass("showbox").addClass("hidebox");
//do stuff with a returned email/emailhash if we got one
//email goes into js_encoded_email
if (myObject['sEmail_first']!='')
{
$("#js_encoded_email").html("" + "Email" + "");
}
}
}
);
}
//need to disable the regular form action... this works!
return false;
}
function HideRemoveAccount()
{
$("#removeaccount").hide();
}
function RemoveAccount()
{
$("#removeaccount").show();
}
//For the layers on community map and other maps
function Toggle_Layer_System(id)
{
if (id==2)
{
$("#layer_system2").toggle();
$("#layer_system_show2").toggle();
}
$("#layer_system").toggle();
$("#layer_system_show").toggle();
//$("#layer_system_hide").toggle();
}
function Toggle_Layers(sLayer_name)
{
$("#"+sLayer_name+"_layer_system").toggle();
$("#"+sLayer_name+"_layer_system_show").toggle();
$("#"+sLayer_name+"_layer_system_hide").toggle();
}
//turns edit mode on, display mode off
//by setting style='display:none' or ''
function EditMode(sHtml_id)
{
$("#"+sHtml_id+"_edit").removeClass("hidebox").addClass("showbox");
$("#"+sHtml_id+"_display").removeClass("showbox").addClass("hidebox");
//show the cancel link
$("#editlink_cancel_"+sHtml_id).show();
//hide the edit link
$("#editlink_edit_"+sHtml_id).hide();
//for people/group (and maybe facilities?) init country, state, province, county drop downs.
if (sHtml_id=='address') Init_County_State_Province();
}
//If the user is in EditMode and hits "cancel" they call this function to get into displaymode
function DisplayMode(sHtml_id)
{
$("#"+sHtml_id+"_display").removeClass("hidebox").addClass("showbox");
$("#"+sHtml_id+"_edit").removeClass("showbox").addClass("hidebox");
//hide the cancel link
$("#editlink_cancel_"+sHtml_id).hide();
//show the edit link
$("#editlink_edit_"+sHtml_id).show();
return false;
}
//turns edit mode on, display mode off
//by setting style='display:none' or ''
function EditMode_subform(sSubtable)
{
$("#"+sSubtable+"_edit").removeClass("hidebox").addClass("showbox");
//$("#"+sSubtable+"_display").removeClass("showbox").addClass("hidebox");
//show the cancel link
$("#editlink_cancelsubform_"+sSubtable).show();
//hide the edit link
$("#editlink_editsubform_"+sSubtable).hide();
}
//If the user is in EditMode and hits "cancel" they call this function to get into displaymode
function DisplayMode_subform(sSubtable)
{
//$("#"+sSubtable+"_display").removeClass("hidebox").addClass("showbox");
$("#"+sSubtable+"_edit").removeClass("showbox").addClass("hidebox");
//hide the cancel link
$("#editlink_cancelsubform_"+sSubtable).hide();
//show the edit link
$("#editlink_editsubform_"+sSubtable).show();
return false;
}
//Return the user to their profile - displayperson-xx.htm from setprivacy.php
function ProfileReturn (iId, sTable)
{
window.location.href=sClienturl+'edit'+sTable+'-'+iId+ '.htm';
return false;
}
//checks username for duplicate. Eg. already existing account with that email address.
function DuplicateUsername ()
{
var sEmail=$('#gsEmail').val();
$.post(sServer+"server-test/webservice/signup_duplicateusername.php?gsEmail="+sEmail,
{ giAjax: "1"},
//write out data to the dom... perhaps below the email field - with a
//could make this an input text box, it would look more user-friendly in terms of copying
function (data)
{
if (data==1) $("#duplicate_username").html("That email already has an account. Forgot your password?
").show();
else if (data==0) $("#duplicate_username").html("");
else $("duplicate_username").html("That email already has an account. Verify your email
");
}
);
}
//unsure if this is in use... intended for use with a progressbar, which I'm not doing.
//function pausecomp(millis)
//{
// var date = new Date();
// var curDate = null;
//
// do { curDate = new Date(); }
// while(curDate-date < millis);
//}
//borrowed from google - http://gmaps-samples.googlecode.com/svn/trunk/geocoder/reverse.html
//if successful, ask the user if they want to use the result.
//if yes, then open the addfacility page - send address in GET (address, city, state, zip, country)
//what is the format of the address: so use throughfarename, localityname, administrativeareaname, postalcodenumber
//for country - I might need to convert it from USA to United States or the 251 country code
//Used to have this on local/national/global map - turned off since those maps are crowded and scrolling is hard
function clicked(overlay, latlng) {
if (latlng) {
geocoder.getLocations(latlng, function(addresses) {
if(addresses.Status.code != 200) {
alert("reverse geocoder failed to find an address for " + latlng.toUrlValue());
}
else {
address = addresses.Placemark[0];
var myHtml = address.address;
//sends the full address, explode with comma seperation and count the number of elements to determine
//whether the street address is included (and city too)
//should I replace spaces with + character? spaces in the url might not be good...
//sLocation='http://www.energyjustice.net/map-test/addobject.php?gsTable=facility&gsAddress_full='+myHtml;
sLocation=sClienturl+'addobject.php?gsTable=facility&gsAddress_full='+myHtml
if(confirm('Do you want to add a facility with this location?'+' '+myHtml)) self.location=sLocation;
}
});
}
}
//Initialize country, county, state, province
//used by onload_init, also used when the user clicks on edit, for addresses.
//Sets county to null, if the user changes the country.
function Init_County_State_Province ()
{
if (document.forms[0]!=undefined)
{
if (document.forms[0].giCounty!=undefined)
{
//old method - didn't work.
//AddCounties3 (document.forms[0].value, document.forms[0].giCounty.value);
AddCounties3 (document.forms[0].giState.value, document.forms[0].giCounty.value);
}
if (document.forms[0].giCountry!=undefined)
{
//The US is default
if (document.forms[0].giCountry[document.forms[0].giCountry.selectedIndex].value!=undefined)
{
var iSelectedvalue=document.forms[0].giCountry[document.forms[0].giCountry.selectedIndex].value
}
else iSelectedvalue=251;
//Canada
if (iSelectedvalue==44)
{
$("#canada_state").show();
$("#canada_state_prompt").show();
$("#us_state").hide();
$("#us_state_prompt").hide();
$("#intl_state").hide();
$("#intl_state_prompt").hide();
$("#county_search").hide();
$("#county_search_prompt").hide();
if (document.forms[0].giState!=undefined) document.forms[0].giState.value=0;
if (document.forms[0].gsState!=undefined) document.forms[0].gsState.value='';
if (document.forms[0].giCounty!=undefined) document.forms[0].giCounty.value=0;
}
//Other
else if ((iSelectedvalue!='') && (iSelectedvalue!=0) && (iSelectedvalue!=251))
{
$("#intl_state").show();
$("#intl_state_prompt").show();
$("#canada_state").hide();
$("#canada_state_prompt").hide();
$("#us_state").hide();
$("#us_state_prompt").hide();
$("#county_search").hide();
$("#county_search_prompt").hide();
if (document.forms[0].giState!=undefined) document.forms[0].giState.value=0;
if (document.forms[0].giProvince!=undefined) document.forms[0].giProvince.value=0;
if (document.forms[0].giCounty!=undefined) document.forms[0].giCounty.value=0;
}
//US
else
{
$("#us_state").show();
$("#us_state_prompt").show();
$("#county_search").show();
$("#county_search_prompt").show();
$("#canada_state").hide();
$("#canada_state_prompt").hide();
$("#intl_state").hide();
$("#intl_state_prompt").hide();
if (document.forms[0].giProvince!=undefined) document.forms[0].giProvince.value=0;
if (document.forms[0].gsState!=undefined) document.forms[0].gsState.value='';
}
}
}
}
//http://www.internetdoc.info/1internetdoc/javascript-php-equivalent/substr_count.htm
function substr_count(string,substring,start,length)
{
var c = 0;
if(start) { string = string.substr(start); }
if(length) { string = string.substr(0,length); }
for (var i=0;i's and
's - that didn't work
//for facilities we want 4 columns, for other objects (like resources), we only need 2 columns
if (substr_count(window.location.href , 'resource' , 0, 200))
{
sub_corporation=$("#sub-corporation").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"sDom": 'lfrtp',
"aoColumns": [{"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null] });
}
else
{
sub_corporation=$("#sub-corporation").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"sDom": 'lfrtp',
"aoColumns": [{"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null, null, null]
});
}
//4 columns - first name, last name, image, delete
sub_people=$("#sub-people").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"sDom": 'lfrtp',
"aoColumns": [{"bSortable":true}, {"bSortable":true}, {"bSortable":false}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null, null, null]
});
sub_groups=$("#sub-groups").dataTable({"iDisplayLength":20, "bLengthChange":false,"bFilter":false, "bAutoWidth":false,
"sDom": 'lfrtp',
"aoColumns": [{"bSortable":true}, {"bSortable":false}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null, null]
});
sub_school=$("#sub-school").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"sDom": 'lfrtp',
"aoColumns": [{"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null] });
sub_resource=$("#sub-resource").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"sDom": 'lfrtp',
"aoColumns": [{"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null] });
sub_link=$("#sub-link").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"sDom": 'lfrtp',
"aoColumns": [{"bSortable":true}, {"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null, null] });
sub_videolink=$("#sub-videolink").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"sDom": 'lfrtp',
"aoColumns": [{"bSortable":true}, {"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null, null] });
sub_tag=$("#sub-tag").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null] });
sub_phile=$("#sub-phile").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"sDom": 'lfrtp',
"aoColumns": [{"bSortable":true}, {"bSortable":false}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null, null]});
//two columns, date and type - could also have a delete one...
sub_unitstatus=$("#sub-unitstatus").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"sDom": 'lfrtp',
"aoColumns": [{"bSortable":true}, {"bSortable":true}, {"bSortable":false}],
"aoColumns": [null, null, null] });
sub_unit=$("#sub-unit").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"sDom": 'lfrtp',
"aoColumns": [{"bSortable":true}, {"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null, null] });
sub_fuel=$("#sub-fuel").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"sDom": 'lfrtp',
"aoColumns": [{"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null, null, null, null] });
sub_product=$("#sub-product").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"sDom": 'lfrtp',
"aoColumns": [{"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null, null, null, null] });
}
//search mode
//var datatable_search_facility="";
else if (substr_count(window.location.href , 'search' , 0, 200))
{
//TableToolsInit.sSwfPath = "js/TableTools/media/swf/ZeroClipboard.swf";
datatable_search_facility=$("#datatable-search-facility").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null, null, {"sType":"html"}],
"sDom": 'T<"clear">lfrtip',
"oTableTools": {"sSwfPath": "js/TableTools/media/swf/copy_cvs_xls_pdf.swf"}}
);
datatable_search_corporation=$("#datatable-search-corporation").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null, null, null],
"sDom": 'lfrtip'});
datatable_search_groups=$("#datatable-search-groups").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null, null, null, null, null, null],
"sDom": 'lfrtip'});
datatable_search_people=$("#datatable-search-people").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null, null, null, null, null, null, null],
"sDom": 'lfrtip'});
datatable_search_resource=$("#datatable-search-resource").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null, null, null],
"sDom": 'lfrtip'});
}
//display mode, one less column in datatables - necessary to avoid a sData javascript error
else
{
//need two facility tables - one for people/groups, where there are just 3 columns (name, interestlevel, delete)
//and one for corporations with 4 columns (name, ownership, subcorp, percent) or maybe 5 if we do delete...
sub_facility=$("#sub-facility").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}, {"bSortable":true}],
"aoColumns": [{"sType":"html"}, null] });
//used for corporations page - shows the facilities that are connected to the corporation and its (one generation) of child corps.
sub_childfacilities=$("#sub-childfacilities").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}],
"aoColumns": [{"sType":"html"}] });
// might need to define sType for these other ones too... Tentatively just added it to the first column, second is null, hopefully the other columns will autodetect
//hmm, unsure if other columns can autodetect... might need to specify length?
//I had a problem where sub-facility was defined as 4 columns, but I only gave it 3
's and
's - that didn't work
//for facilities we want 4 columns, for other objects (like resources), we only need 2 columns
if ((substr_count(window.location.href , 'resource' , 0, 200)) || (substr_count(window.location.href , 'corporation' , 0, 200)))
{
sub_corporation=$("#sub-corporation").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}],
"aoColumns": [{"sType":"html"}],
"fnDrawCallback": function() {
if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) < 2)
{ RemovePagination('corporation');
}} });
}
else
{
sub_corporation=$("#sub-corporation").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}, {"bSortable":true}, {"bSortable":true}],
"aoColumns": [{"sType":"html"}, null, null],
"fnDrawCallback": function() {
if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) < 2)
{ RemovePagination('corporation');
}} });
}
//4 columns - first name, last name, image, delete
sub_people=$("#sub-people").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}, {"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null, null],
"fnDrawCallback": function() {
if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) < 2)
{ RemovePagination('people');
}} });
sub_groups=$("#sub-groups").dataTable({"iDisplayLength":20, "bLengthChange":false,"bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null],
"fnDrawCallback": function() {
if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) < 2)
{ RemovePagination('groups');
}} });
sub_school=$("#sub-school").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}],
"aoColumns": [{"sType":"html"}],
"fnDrawCallback": function() {
if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) < 2)
{ RemovePagination('school');
}} });
sub_resource=$("#sub-resource").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}],
"aoColumns": [{"sType":"html"}],
"fnDrawCallback": function() {
if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) < 2)
{ RemovePagination('resource');
}} });
sub_link=$("#sub-link").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}, {"bSortable":true} ],
"aoColumns": [{"sType":"html"}, null],
"fnDrawCallback": function() {
if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) < 2)
{ RemovePagination('link');
}} });
sub_videolink=$("#sub-videolink").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}, {"bSortable":true} ],
"aoColumns": [{"sType":"html"}, null],
"fnDrawCallback": function() {
if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) < 2)
{ RemovePagination('videolink');
}} });
sub_tag=$("#sub-tag").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}],
"aoColumns": [{"sType":"html"}],
"fnDrawCallback": function() {
RemovePagination('tag');
}
});
sub_phile=$("#sub-phile").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}, {"bSortable":false}],
"aoColumns": [{"sType":"html"}, null],
"fnDrawCallback": function() {
if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) < 2)
{ RemovePagination('phile');
}} });
sub_unitstatus=$("#sub-unitstatus").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}, {"bSortable":true}],
"aoColumns": [null, null],
"fnDrawCallback": function() {
if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) < 2)
{ RemovePagination('unitstatus');
}} });
sub_unit=$("#sub-unit").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}, {"bSortable":true}],
"aoColumns": [{"sType":"html"}, null],
"fnDrawCallback": function() {
if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) < 2)
{ RemovePagination('unitstatus');
}} });
sub_fuel=$("#sub-fuel").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":true}],
"aoColumns": [{"sType":"html"}, null, null, null],
"fnDrawCallback": function() {
if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) < 2)
{ RemovePagination('fuel');
}} });
sub_product=$("#sub-product").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}, {"bSortable":true}, {"bSortable":true}, {"bSortable":true}],
"aoColumns": [{"sType":"html"}, null, null, null],
"fnDrawCallback": function() {
if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) < 2)
{ RemovePagination('product');
}} });
//end of if statement
}
//same size in both cases - no delete column
//since there is unlikely to be more than 20 controllers, I'm removing pagination
sub_control=$("#sub-control").dataTable({"iDisplayLength":20, "bLengthChange":false, "bFilter":false, "bAutoWidth":false,
"aoColumns": [{"bSortable":true}],
"aoColumns": [{"sType":"html"}],
"fnDrawCallback": function() {
RemovePagination('control');
} });
//this would work if I added the class "dataTable" to all my tables...
//$('.dataTable').dataTable({"iDisplayLength":20, "bLengthChange":false});
//for each datatable, hide it if there are zero rows.
//actually hide the datatables wrapper - do this if we aren't in search view
if (!substr_count(window.location.href , 'search' , 0, 200))
{
if ((sub_facility.fnSettings()!=null) && (sub_facility.fnSettings().fnRecordsDisplay()==0))
{
$('#sub-facility_wrapper').hide();
}
if ((sub_groups.fnSettings()!=null) && (sub_groups.fnSettings().fnRecordsDisplay()==0))
{
$('#sub-groups_wrapper').hide();
}
if ((sub_people.fnSettings()!=null) && (sub_people.fnSettings().fnRecordsDisplay()==0))
{
$('#sub-people_wrapper').hide();
}
if ((sub_school.fnSettings()!=null) && (sub_school.fnSettings().fnRecordsDisplay()==0))
{
$('#sub-school_wrapper').hide();
}
if ((sub_resource.fnSettings()!=null) && (sub_resource.fnSettings().fnRecordsDisplay()==0))
{
$('#sub-resource_wrapper').hide();
}
if ((sub_corporation.fnSettings()!=null) && (sub_corporation.fnSettings().fnRecordsDisplay()==0))
{
$('#sub-corporation_wrapper').hide();
}
if ((sub_link.fnSettings()!=null) && (sub_link.fnSettings().fnRecordsDisplay()==0))
{
$('#sub-link_wrapper').hide();
}
if ((sub_videolink.fnSettings()!=null) && (sub_videolink.fnSettings().fnRecordsDisplay()==0))
{
$('#sub-videolink_wrapper').hide();
}
if ((sub_tag.fnSettings()!=null) && (sub_tag.fnSettings().fnRecordsDisplay()==0))
{
$('#sub-tag_wrapper').hide();
}
if ((sub_phile.fnSettings()!=null) && (sub_phile.fnSettings().fnRecordsDisplay()==0))
{
$('#sub-phile_wrapper').hide();
}
if ((sub_control.fnSettings()!=null) && (sub_control.fnSettings().fnRecordsDisplay()==0))
{
$('#sub-control_wrapper').hide();
}
}
if (substr_count(window.location.href , '/admin' , 0, 200))
{
$('#admin_user').focus();
}
if (substr_count(window.location.href , 'verify_account' , 0, 200))
{
$('#verify_password').focus();
}
if (substr_count(window.location.href , 'signup.php?giStep=1' , 0, 200))
{
$("input[name=gsFname]").focus();
}
});
//adding a facility - hide some of the steps until they are needed
if ((substr_count(window.location.href , 'addfacility' , 0, 200)) ||
((substr_count(window.location.href , 'addobject' , 0, 200)) && (substr_count(window.location.href , 'facility' , 0, 200)) ))
{
/*step 2 hide*/
//$('#giBfactype').hide();
//$('#giFacility_status').hide();
//$('#Step2').hide();
/* step 3 hide*/
//$('#giFacility_fueltype').hide();
//$('#giFacility_producttype').hide();
//$('#Step3').hide();
/*step 4 hide*/
//$('#msWebsite').hide();
//$('#facility_msNotes_public').hide();
//$('#msPhone_addfacility').hide();
//$('#Step4').hide();
//attach js function to #gsSubmit
$('#gsAdd_control').click(function ()
{
//initialize exit/error
var iExit=0;
/*
if (iFacilitystep==1)
{
//fuzzy name match
//serializes form data - really I just need sName, but I might want other fields in the future
//var aEdittarray = array();
//aEditarray['sPost']=$("form").serialize();
//var encoded = $.toJSON(aEditarray);
var sFacilityname=$("input[name=gsName]").val();
if (sFacilityname.length ==0)
{
alert ("Error - you must enter a facility name.");
iExit=1;
}
if ($("select[name=giCountry]").val()==0)
{
alert ("Error - you must enter a country.");
iExit=1;
}
if (iExit==0)
{
//minimum length of 4 triggers a match
if (sFacilityname.length>3)
{
$.post(sServer+"server-test/webservice/ajax_facilitymatch.php",
{ 'giAjax': "1", 'gsFacilityname': sFacilityname },
function (data)
{
var myObject = eval('(' + data + ')');
//match found - show request control link
if (myObject['iFacilityid']>=1)
{
//requestcontrol.php?g".$this->GetIDName()."=".$this->GetID()
$('#fuzzymatch').html(" If you are adding "+myObject['sName']+", we already have it listed. You should " + "Request Control of that Facility").show();
}
else
{
$('#fuzzymatch').hide();
}
}
);
}
$('#giBfactype').show();
$('#giFacility_status').show();
$('#Step2').show();
}
}
else if (iFacilitystep==2)
{
//require a basfacility type - otherwise, give an error...
if ($('#giBfactype').val() !=0)
{
alert ("Error - you must enter a facility type.");
iExit=1;
}
else
{
//generate a list of fuels based on $GLOBALS['gasFacilitytypetofuelproduct']
$('#giFacility_fueltype').show();
$('#giFacility_producttype').show();
$('#Step3').show();
}
}
else if (iFacilitystep==3)
{
$('#Step4').show();
$('#msWebsite').show();
$('#facility_msNotes_public').show();
$('#msPhone_addfacility').show();
}
//call the webservice... using nusoap
else if (iFacilitystep==4)
{
}
//alert ("Hi");
//show
if (iExit==0) iFacilitystep++;
//will this cause the form to submit on step 4?
if (iFacilitystep!=5) return false;
else return true;
*/
}
);
}
//Initialize country, county, state, province
Init_County_State_Province ();
//might want to do this only if they exist...
$('#stateenergymix').visualize();
$('#stateemissionschart_iCo2').visualize({barGroupMargin: '2', width:370});
$('#stateemissionschart_iSo2').visualize({barGroupMargin: '2', width:370});
$('#stateemissionschart_iNox').visualize({barGroupMargin: '2', width:370});;
//kml init, only if on search object
if (substr_count(window.location.href , 'searchobject' , 0, 200))
{
kml_init();
}
}
//canada chosen - turn canada prompt and dropdown on, turn others off
//us chosen - turn us prompt and dropdown on, turn others off
//other country chosen (that isn't empty string) - turn other country textbox on, turn others off
//document.forms[0].giCountry.selectedIndex - look for Canada (44), or US (251)
//this handles things that are already selected, but doesn't handle values from past searches that would be stored
//in SESSION - but it still might work, so long as iCountry is marked as "selected" and OnLoad_Init is designed
//to handle that...
//This "forgets" the value that the user already entered. So if they have US selected, then choose Canada, then choose
//the US, it won't remember the state they had selected for the US. On the other hand, how often will users do this?
//We're setting the other values to null, so as to avoid sending them to the server...
//Instead: we could have a "on submit" function that would set them to null if their form fields were hidden...
//be sure that if the user switches from the US to another country it sets giState=0.
//if the user switches from Canada to another country set iProvince=0
function StateBoxToggle()
{
//it is undefined if we're doing a user signup and are at step 1
if (document.forms[0].giCountry!=undefined)
{
var iSelectedvalue=document.forms[0].giCountry[document.forms[0].giCountry.selectedIndex].value
//Canada
if (iSelectedvalue==44)
{
$("#canada_state").show();
$("#canada_state_prompt").show();
$("#us_state").hide();
$("#us_state_prompt").hide();
$("#intl_state").hide();
$("#intl_state_prompt").hide();
$("#county_search").hide();
$("#county_search_prompt").hide();
document.forms[0].giState.value=0;
document.forms[0].gsState.value='';
}
//other country, non-US, non-Canada
else if ((iSelectedvalue!='') && (iSelectedvalue!=0) && (iSelectedvalue!=251))
{
$("#intl_state").show();
$("#intl_state_prompt").show();
$("#canada_state").hide();
$("#canada_state_prompt").hide();
$("#us_state").hide();
$("#us_state_prompt").hide();
$("#county_search").hide();
$("#county_search_prompt").hide();
document.forms[0].giState.value=0;
document.forms[0].giProvince.value=0;
}
//USA
else
{
$("#us_state").show();
$("#us_state_prompt").show();
$("#county_search").show();
$("#county_search_prompt").show();
$("#canada_state").hide();
$("#canada_state_prompt").hide();
$("#intl_state").hide();
$("#intl_state_prompt").hide();
document.forms[0].giProvince.value=0;
document.forms[0].gsState.value='';
}
}
}
//Sets giProvince, giState, gsState to null - based on which country is selected
function SubmitForm()
{
var iSelectedvalue=document.forms[0].giCountry[document.forms[0].giCountry.selectedIndex].value
if (iSelectedvalue==44)
{
document.forms[0].giState.value=0;
document.forms[0].gsState.value='';
}
else if ((iSelectedvalue!='') && (iSelectedvalue!=0) && (iSelectedvalue!=251))
{
document.forms[0].giState.value=0;
document.forms[0].giProvince.value=0;
}
else
{
document.forms[0].giProvince.value=0;
document.forms[0].gsState.value='';
}
}
//reset button - in case the layers get messed up from clicking on them too fast before ajax requests are processed.
//also resets localmap - for local map we have giLayer_98_1 (the "other" layer, which doesn't exist on national map)
//I could modify it so it only sets them to false if they exist, but this seems to work fine - no javascript errors in firebug
function ResetNationalMap()
{
for (var k=1; k<=20; k++)
{
for (var j=1; j<=4; j++)
{
var sCheckname='giLayer_'+k+'_'+j;
if (document.forms[0][sCheckname]!=undefined)
{
document.forms[0][sCheckname].checked=false;
}
//layerstatus is only used for local map - i think
if (layerstatus!=undefined) layerstatus[j][k]=0;
}
var sCheckname='giLayer_'+k+'_'+99;
document.forms[0][sCheckname].checked=false;
}
for (var j=1; j<4; j++)
{
if (document.forms[0]['giLayer_98_'+j]!=undefined)
{
document.forms[0]['giLayer_98_'+j].checked=false;
}
}
for (var j=1; j<=4; j++)
//for (var j=2; j<=4; j++)
{
var sCheckname='giLayer_'+99+'_'+j;
if (document.forms[0][sCheckname]!=undefined)
{
document.forms[0][sCheckname].checked=false;
}
var sCheckname='giLayer_'+98+'_'+j;
if (document.forms[0][sCheckname]!=undefined)
{
document.forms[0][sCheckname].checked=false;
}
}
if (document.forms[0]['giLayer_98_99']!=undefined)
{
document.forms[0]['giLayer_98_99'].checked=false;
}
if (document.forms[0]['giLayer_99_99']!=undefined)
{
document.forms[0]['giLayer_99_99'].checked=false;
}
map.clearOverlays();
if (substr_count(window.location.href , 'heat' , 0, 200))
{
map.addOverlay(myTileLayer);
}
//sets iLayervisible to 0, also reset gmarkers - unsure if that is needed.
ToggleAllMarkersOff ();
$("span#iCount").html("Total Results: 0");
}
//enables or disables all checkboxes
//NOTE: "disable" variable is true or false. If it is false, then this Enables all checkboxes.
function CheckboxDisable(disable)
{
if (disable==true)
{
$("span#waiting").html("Fetching Data...");
}
else
{
$("span#waiting").html("");
}
//Alternatively, I could go through the DOM and find all checkboxes... If there was a direct DOM pointer to checkboxes.
for (var ik=1; ik<=20; ik++)
{
for (var ij=1; ij<=4; ij++)
{
var sCheckname10='giLayer_'+ik+'_'+ij;
if (document.forms[0][sCheckname10]!=undefined)
{
document.forms[0][sCheckname10].disabled=disable;
}
}
var sCheckname10='giLayer_'+ik+'_99';
if (document.forms[0][sCheckname10]!=undefined)
{
document.forms[0][sCheckname10].disabled=disable;
}
}
//all of the same status - only exists for statuses other than "operating", hmm, unsure what this really does...
document.forms[0]['giLayer_99_2'].disabled=disable;
document.forms[0]['giLayer_99_3'].disabled=disable;
document.forms[0]['giLayer_99_4'].disabled=disable;
if (document.forms[0]['giLayer_99_1']!=undefined)
{
document.forms[0]['giLayer_99_1'].disabled=disable;
}
if (document.forms[0]['giLayer_99_99']!=undefined)
{
document.forms[0]['giLayer_99_99'].disabled=disable;
}
if (document.forms[0]['giLayer_98_99']!=undefined)
{
document.forms[0]['giLayer_98_99'].disabled=disable;
}
for (var ij=1; ij<=4; ij++)
{
var sCheckname10='giLayer_98_'+ij;
if (document.forms[0][sCheckname10]!=undefined)
{
document.forms[0][sCheckname10].disabled=disable;
}
}
}
//event - onchange - will the dom be changed then? so then i can use the dom's values for the checkboxes?
//creates layer checkbox array - sends to server
//gets list of facilities
//runs initlayers to display them
//if they choose an "all" statuses or all facility types - then toggle the related checkboxes
//if they choose "proposed" (iStatus=2) then select "expanding" (iStatus: 4) as well, except for 99 (all layers)
//added iOn, iLayerid, iStatus parameters
function NationalMapToggle(iOn, iLayerid, iStatus)
{
//creates layer checkbox array - sends to server
//for every unit status -
//it'd be nice if I could get the number of layers dynamically, instead of using the 20 constant
//If we are going to display too many markers - toggle off high marker layers.
//these include: hydro/oil/gas/coal - operating/all
//only do this for the US - eg do not do it for national-xx
if (substr_count(window.location.href , 'national-' , 0, 200)==0)
{
var aStatus=new Array (2, 3, 4, 17);
if ( ((iLayerid==2) || (iLayerid==3) || (iLayerid==4) || (iLayerid==17)) &&
((iStatus==1) || (iStatus==99)))
{
for (key in aStatus)
{
if (aStatus[key]!=iLayerid)
{
var sCheckname5='giLayer_'+aStatus[key]+'_';
document.forms[0][sCheckname5+'1'].checked=false;
document.forms[0][sCheckname5+'99'].checked=false;
}
}
}
}
//handle turning on/off all layers/statuses first (does this placement matter?)
if ((iLayerid==99) && (iStatus==99))
{
for (var ikey=1; ikey<=4; ikey++)
{
for (var isubkey=1; isubkey<=20; isubkey++)
{
var sCheckname5='giLayer_'+isubkey+'_'+ikey;
if (document.forms[0][sCheckname5]!=undefined)
{
document.forms[0][sCheckname5].checked=iOn;
}
}
var sCheckname5='giLayer_99_'+ikey;
if (document.forms[0][sCheckname5]!=undefined)
{
document.forms[0][sCheckname5].checked=iOn;
}
}
}
//user is turning off a layer
if (iOn==false)
{
//test for the user turning off a layer that breaks an "all" - so the all should be unchecked
//look at the iLayerid - does that break an all?
//instead of testing for it - I just set it to false
//all/all does not exist
if (iLayerid!=99)
{
var sCheckname5='giLayer_'+iLayerid+'_99';
document.forms[0][sCheckname5].checked=false;
}
//look at the iStatus -- does that break an all?
//instead of testing for it - I just set it to false
//exceptions are operating and all status - which do not exist in nationalmap
//if ((iStatus!=99) && (iStatus!=1))
//{
//now changed, as all operating status is possible for nonUS
var sCheckname5='giLayer_99_'+iStatus;
if (document.forms[0][sCheckname5]!=undefined)
{
document.forms[0][sCheckname5].checked=false;
}
//}
}
//user is turning on a layer
else
{
//if the user turns on proposed (iStatus:2) then turn on expanding (iStatus:4)
if ((iStatus==2) && (iLayerid!=99))
{
var sCheckname_expanding='giLayer_'+iLayerid+'_4';
document.forms[0][sCheckname_expanding].checked=true;
}
//test for the user turning on a layer that causes all to be selected - so the all should be checked
//look at the iLayerid - does that create an all?
var iAll=true;
var iStart=0;
//starts at "2" for iStatus=1, operating, as there is no select all for that status.
if (iStatus==1) iStart=2;
else iStart=1;
for (var n=iStart; n<=4; n++)
{
var sCheckname5='giLayer_'+iLayerid+'_'+n;
if (document.forms[0][sCheckname5]!=undefined)
{
if (document.forms[0][sCheckname5].checked==false) iAll=false;
}
}
if (iAll==true)
{
var sCheckname5='giLayer_'+iLayerid+'_99';
if (document.forms[0][sCheckname5]!=undefined) document.forms[0][sCheckname5].checked=true;
}
if (iStatus!=-99)
{
//look at the iStatus -- does that create an all?
var iAll=true;
for (var n=1; n<=20; n++)
{
var sCheckname5='giLayer_'+n+'_'+iStatus;
if (document.forms[0][sCheckname5].checked!=undefined)
{
if (document.forms[0][sCheckname5].checked==false) iAll=false;
}
}
if (iAll==true)
{
var sCheckname5='giLayer_99_'+iStatus;
if (document.forms[0][sCheckname5].checked!=undefined)
{
document.forms[0][sCheckname5].checked=true;
}
}
}
}
var aCheck = new Array();
//parses to build the checkbox array to send to the server
for (var m=1; m<=20; m++)
{
aCheck[m] = new Array();
//possible statuses, 1, 2, 3, 4, 99
var sCheckname='giLayer_'+m+'_';
//if all is checked - don't include the other parameters, to make the sql simpler
if (document.forms[0][sCheckname+'99'].checked)
{
aCheck[m][99]=true;
aCheck[m][1]=false;
aCheck[m][2]=false;
aCheck[m][3]=false;
aCheck[m][4]=false;
//if the user just clicked on the all status checkbox, then set the checkbox fields to on/off
if ((iLayerid==m) && (iStatus==99))
{
document.forms[0][sCheckname+'1'].checked=true;
document.forms[0][sCheckname+'2'].checked=true;
document.forms[0][sCheckname+'3'].checked=true;
document.forms[0][sCheckname+'4'].checked=true;
}
}
//if all isn't selected - collect all the checkbox values for the array
else
{
//if the user just clicked on the all status checkbox - and turned layers off... then set the boxes to off
if ((iLayerid==m) && (iStatus==99))
{
document.forms[0][sCheckname+'1'].checked=false;
document.forms[0][sCheckname+'2'].checked=false;
document.forms[0][sCheckname+'3'].checked=false;
document.forms[0][sCheckname+'4'].checked=false;
}
aCheck[m][1]=document.forms[0][sCheckname+'1'].checked;
aCheck[m][2]=document.forms[0][sCheckname+'2'].checked;
aCheck[m][3]=document.forms[0][sCheckname+'3'].checked;
aCheck[m][4]=document.forms[0][sCheckname+'4'].checked;
aCheck[m][99]=document.forms[0][sCheckname+'99'].checked;
}
}
aCheck[99]=new Array();
var sCheckname3='giLayer_99_';
//if the user just toggled the all factypes of one status
if (iLayerid==99)
{
for (var k=1; k<=20; k++)
{
var sCheckname2='giLayer_'+k+'_'+iStatus;
document.forms[0][sCheckname2].checked=iOn;
}
if (document.forms[0]['giLayer_'+98+'_'+iStatus]!=undefined)
{
document.forms[0]['giLayer_'+98+'_'+iStatus].checked=iOn;
}
}
//aCheck[99][1]=document.forms[0][sCheckname3+'1'].checked;
aCheck[99][1]=false;
aCheck[99][2]=document.forms[0][sCheckname3+'2'].checked;
aCheck[99][3]=document.forms[0][sCheckname3+'3'].checked;
aCheck[99][4]=document.forms[0][sCheckname3+'4'].checked;
//this shouldn't ever be checked - as it won't work - it'd display too many results (9000+)
//so it should be disabled
aCheck[99][99]=false;
//remove markers - do it before the AJAX request so the cpu can work on it while we're waiting for the AJAX response
//hmm, we want to clear only the non-kml overlays...
//if (iStatus!=-99) map.clearOverlays();
if (iStatus!=-99) ToggleAllMarkersOff();
//gets list of facilities
//using post because I cannot use GET and send aCheck - as it is too long.
//note: I might need to change my handling of giAjax
//try serializing the entire form contents as a way of sending aCheck
//if aCheck is null - all checkboxes are off, then just set facilities to an empty array without running the service
var str = $("form").serialize();
if ((str=="") || (substr_count(str, 'giLayer',0,200)==0))
{
//do nothing - we already cleared the overlays...
//set the number of results to zero
$("span#iCount").html("Number of Results: 0");
}
else
{
//first disable all checkboxes
CheckboxDisable (true);
//alert("test");
var sSearchtype='';
if (substr_count(window.location.href , 'globalmap' , 0, 200)==1)
{
sSearchtype="globalmap";
}
else sSearchtype="nationalmap";
//probably need to add code for LOCAL MAP and global map...
var sUrl='';
//should only do this if there is some layer... so str contains 'giLayer' and sSearchtype='nationalmap'
if ( (substr_count(str, 'giLayer')>=1) && (sSearchtype=='nationalmap'))
{
//Test for cases where we can use caching...
//if there is only one layer... so count the instances of giLayer
var sUrl='';
if (substr_count(str, 'giLayer')==1)
{
//alert (str);
var iFirstunderscore=str.indexOf('_');
//this only works for ONE layer
var iLastunderscore=str.lastIndexOf('_');
var iLastequal=str.lastIndexOf('=');
var iLayer=str.substr(iFirstunderscore+1, iLastunderscore-iFirstunderscore-1);
//after the second underscore (iStatus length could be 1 or 2 chars (for 99) - next char is an "="
var iStatus=str.substr(iLastunderscore+1, iLastequal-iLastunderscore-1);
//sUrl=sServer+"js/json/json-"+iLayer+"-"+iStatus;
sUrl=sServer+"js/json/json-"+iLayer+"-"+iStatus+".php";
}
//check for proposed and expanding of each type...
else if (substr_count(str, 'giLayer')==2)
{
for (var iJ=1; iJ<=20; iJ++)
{
if ((substr_count(str,'giLayer_'+iJ+'_2')==1) && (substr_count(str, 'giLayer_'+iJ+'_4')==1))
{
sUrl=sServer+"js/json/json-"+iJ+"-2and4.php";
}
}
}
//so if there are 5 layers, and one of them is an "all" layer - then they are probably all for the same type
else if ((substr_count(str, 'giLayer')==5) && (substr_count(str, '99')==1))
{
for (var iJ=1; iJ<=20; iJ++)
{
if (substr_count(str,'giLayer_'+iJ+'_99')==1)
{
sUrl=sServer+"js/json/json-"+iJ+"-99.php";
}
}
}
}
//might also happen if we have two layers and they aren't proposed and expanding, in which case the else if statement will execute but not create a Url value.
if (sUrl=='')
{
sUrl=sServer+"server-test/webservice/searchserver-new.php?"+str;
}
$.post(sUrl,{ giAjax: "1", gsSearchtype: sSearchtype },
function (data)
{
var tempfacilities = eval('(' + data + ')');
facilities=tempfacilities.facilities;
//Enable all the checkboxes
CheckboxDisable (false);
$("span#waiting").html("Adding Data to Map...");
//runs initlayers to display them -- runs this only after the data is fetched.
//need to make sure this doesn't deactivate any kml layers that are on
InitLayers();
$("span#iCount").html("Total Results: "+facilities[0]['iCount']+" Mapped Results: "+facilities[0]['iMapcount']);
//writes over the "adding to map" notice
$("span#waiting").html("");
if (facilities[0]['fLat']!=undefined)
{
map.setCenter(new GLatLng(facilities[0]['fLat'],facilities[0]['fLong']), parseInt(facilities[0]['iZoom']), G_NORMAL_MAP);
}
}
);
}
}
//Shows facilities where facilities[key][iLayervisible]<>0
//For use in debugging layers system
//also provide a count of them
//builds up a string and then writes it out to a div or span
function ShowVisibleFacilities ()
{
var facility_list='';
var visible_count=0;
for (keyVar5 in facilities)
{
if (keyVar5!=0)
{
if (facilities[keyVar5]['iLayervisible']!=0)
{
visible_count++;
facility_list=facility_list+' '+keyVar5;
}
}
}
$("span#Debug").html("Number of Visible Results: "+visible_count+facility_list);
}
//create a tinyurl - calls ajax webservice
//uses sUrl - which should be in global scope
//iFormdata - if 1, then serialize form data
//sShare= '', twitter, or facebook : if we're doing this to create url for FB or twitter sharing, then we don't write it out the screen
function GetTinyUrl (iFormdata, sShare)
{
var formstr='';
//clears the old tinyurl...
$("span#tinyurl").html("");
//for national and localmap - fetches form results - and adds to the string
if (iFormdata==1)
{
formstr = $("form").serialize();
}
//get center point: long/lat, zoom level, and map type (map, satellite, or hybrid)- add to url
//point.lat() point.lng - return values
var point=new GLatLng(0,0);
point=map.getCenter();
//getsize unfortunately returns the original map size - if you use jquery resize, it won't be updated
var size=new GSize(0,0);
size=map.getSize();
//only difference is miCountry=0
var sTinyserviceurl=sServer+"server-test/webservice/tinyurl-service.php?gsUrl="+sUrl+"&"+formstr+"&gsAddress_facility="+sAddress_facility+"&gfLat="+point.lat()+"&gfLng="+point.lng()+"&giZoom="+map.getZoom()+"&gsMaptype="+map.getCurrentMapType().getName()+"&giWidth="+size.width+"&giHeight="+size.height;
if (substr_count(window.location.href , 'globalmap' , 0, 200))
{
sTinyserviceurl=sTinyserviceurl+"&miCountry=0";
}
if (substr_count(window.location.href , 'adm' , 0, 200))
{
var miAdmid_get = window.location.pathname.replace(/[^0-9]/g, '');
sTinyserviceurl=sTinyserviceurl+"&giAdmid="+miAdmid_get;
}
$.post(sTinyserviceurl,
{ giAjax: "1", gsClienturl: sBaseurl},
//write out data to the dom...
//could make this an input text box, it would look more user-friendly in terms of copying
function (data)
{
if (sShare=='')
{
$("span#tinyurl").html("");
$("#tinyurl-text").focus();
}
else if (sShare=='facebook')
{
window.location.href='http://www.facebook.com/share.php?u=http://'+data;
}
else if (sShare=='twitter')
{
//this shares a nonclickable url - or maybe only because it is localhost...
window.location.href='http://twitter.com/home?status=http://'+data;
//this shares a clickable url - problem is that it needs a good name...
//window.location.href='http://twitter.com/home?status=link';
}
}
);
}
//A function that reuses values for the basic/advanced facility search when the user toggles between them
//reuse: facility name, company name, city, state, county, zip, radius
//sFormtype = advanced or basic - the type of the form that we are linking to - for use in the open window
//this might be a problem - it should only do this for basic/adv fac search, it shouldn't do it for
//adding a person then doing a search
function ReuseFormFields (sFormtype)
{
var sList='';
//for each possible reuse value - check if it is non-null, if so, add it to a string variable
if (document.forms[0].gsName.value!=undefined) sList+='&gsName='+ document.forms[0].gsName.value;
if (document.forms[0].gsCompanyname.value!=undefined) sList+='&gsCompanyname='+ document.forms[0].gsCompanyname.value;
if (document.forms[0].gsCity.value!=undefined) sList+='&gsCity='+ document.forms[0].gsCity.value;
if (document.forms[0].giState.value!=undefined) sList+='&giState='+ document.forms[0].giState.value;
if (document.forms[0].giCounty.value!=undefined) sList+='&giCounty='+ document.forms[0].giCounty.value;
if (document.forms[0].giRadius.value!=undefined) sList+='&giRadius='+ document.forms[0].giRadius.value;
if (document.forms[0].gsZip.value!=undefined) sList+='&gsZip='+ document.forms[0].gsZip.value;
window.location.href=sClienturl+'searchobject.php?gsTable=facility&gsSearchtype='+sFormtype+sList;
}
//Disables part of the Advanced Facility Search form - if they enter a non-null value
//excecute this "onchange"
function TogglePowerField ()
{
//if facility min or max power is nonnull - disable unit min and max power
if (((document.forms[0].gfFacilitymwminrange.value!=undefined) || (document.forms[0].gfFacilitymwmaxrange.value!=undefined))
&& ((document.forms[0].gfFacilitymwminrange.value!=0) || (document.forms[0].gfFacilitymwmaxrange.value!=0)))
{
document.forms[0].gfUnitmwmaxrange.disabled=1;
document.forms[0].gfUnitmwminrange.disabled=1;
document.forms[0].gfUnitmwmaxrange.style.backgroundColor="#cccccc";
document.forms[0].gfUnitmwminrange.style.backgroundColor="#cccccc";
}
else
{
document.forms[0].gfUnitmwmaxrange.disabled=0;
document.forms[0].gfUnitmwminrange.disabled=0;
document.forms[0].gfUnitmwmaxrange.style.backgroundColor="#ffffff";
document.forms[0].gfUnitmwminrange.style.backgroundColor="#ffffff";
}
//if unit min or max power is nonnull - disable facility min and max power
if (((document.forms[0].gfUnitmwminrange.value!=undefined) || (document.forms[0].gfUnitmwmaxrange.value!=undefined))
&& ((document.forms[0].gfUnitmwminrange.value!=0) || (document.forms[0].gfUnitmwmaxrange.value!=0)))
{
document.forms[0].gfFacilitymwmaxrange.disabled=1;
document.forms[0].gfFacilitymwminrange.disabled=1;
document.forms[0].gfFacilitymwmaxrange.style.backgroundColor="#cccccc";
document.forms[0].gfFacilitymwminrange.style.backgroundColor="#cccccc";
}
else
{
document.forms[0].gfFacilitymwmaxrange.disabled=0;
document.forms[0].gfFacilitymwminrange.disabled=0;
document.forms[0].gfFacilitymwmaxrange.style.backgroundColor="#ffffff";
document.forms[0].gfFacilitymwminrange.style.backgroundColor="#ffffff";
}
}
//If the user selects the "all" option for unit types - deselect the other options.
function UnitTypeAll()
{
if (document.getElementsByName('gasUnittype[]')[0].options[0].selected==true)
{
for (i=1; i'+ title + '';
if ((aFacility['fLatitude']!=undefined) && (aFacility['fLatitude']!=''))
{
if (aFacility['sCity']!='') sTexturl+=' '+aFacility['sCity'];
if (aFacility['sCity']!='' && aFacility['sState']!='') sTexturl+=', ';
if (aFacility['sCity']=='' && aFacility['sState']!='') sTexturl+=' ';
if (aFacility['sState']!='') sTexturl+=aFacility['sState'];
}
else
{
if (aFacility['sCi']!='') sTexturl+=' '+aFacility['sCi'];
if (aFacility['sCi']!='' && aFacility['sSt']!='') sTexturl+=', ';
if (aFacility['sCi']=='' && aFacility['sSt']!='') sTexturl+=' ';
if (aFacility['sSt']!='') sTexturl+=aFacility['sSt'];
}
//add power plant type
if (sFactype!='other') sTexturl+=' '+sFacname;
sTexturl+='';
createMarker_themap(point, sTexturl, title, aicon[sMarkercolor][sFactype], iFacilityid);
//setTimeout ("createMarker_themap(point, sTexturl, title, aicon[sMarkercolor][sFactype], iFacilityid)", 1);
}
//for local map - when giLayer is in the URL - we need to set facilities[keyvar][iTempstatus]
//is this going to give us a status type of 1..20 or 1..4? we want 1..4
function InitTempStatus()
{
for (keyVar3 in facilities)
{
//alert ("keyvar3:"+keyVar3);
//initialize to zero to avoid trouble
facilities[keyVar3]['iTempstatus']=0;
//gets the first tempstatus from the aiUnitstatus_factype array
if (facilities[keyVar3]['aiUnitstatus_factype']!=undefined)
{
for (keystatustype in facilities[keyVar3]['aiUnitstatus_factype'])
{
facilities[keyVar3]['iTempstatus']=facilities[keyVar3]['aiUnitstatus_factype'][keystatustype];
break;
}
}
}
}
//for facility search - the map - initialize the layers and display the markers
//also used by Toggle All Markers On
//need to make sure this doesn't deactivate kml - if called during nationalmaptoggle (after the ajax fetch)
function InitLayers ()
{
//var iMarkercount=0;
for (keyVar2 in facilities)
{
var iLayer=0;
//gets the iLayervisible value from the first element stored in the aiLayer array
for (keyfactype in facilities[keyVar2]['aiLayer'])
{
iLayer=keyfactype;
break;
}
//if we have all layers selected, then only show a marker if it isn't already being shown - eg. iLayervisible==0
//so checked and visible==0, or not checked
if (keyVar2!=0)
{
createMarker_shell(facilities[keyVar2], keyVar2, iLayer);
}
}
//works for national map
if (facilities[0]['iCount']!=undefined)
{
$("span#iCount").html("Total Results: "+facilities[0]['iCount']+" Mapped Results: "+facilities[0]['iMapcount']);
}
else
{
//for local map - count number of facilities with iLayervisible>=1 and fLatitude and fLongitude non-zero
//count number of markers
//note: for local map, only geocoded facilities will show up in results as we use long/lat to see if they are local.
//Thus we don't need to do the "total results" vs "mapped results" distinction
var iCount_local=0;
var iCount_localmapped=0;
for (keyvar_count in facilities)
{
if (keyvar_count!=0)
{
if (facilities[keyvar_count]['iLayervisible']!=0) iCount_local++;
if ((facilities[keyvar_count]['iLayervisible']!=0) && (facilities[keyvar_count]['fLatitude']!='')) iCount_localmapped++;
}
}
$("span#iCount").html("Total Results: "+iCount_local);
//$("span#iCount").html("Total Results: "+iCount_local+" Mapped Results: "+iCount_localmapped);
}
}
//Internal function for ToggleMarkers - turns a single layer/status combination off
//For "other" (98) - turn off all the markers with "other" in their factype string.
function ToggleMarkersOff (iLayerid, iStatus)
{
layerstatus[iStatus][iLayerid]=0;
//loop through facilitie array
for (keyVar in facilities)
{
if (keyVar!=0)
{
//if this layer is visible and matches the layer to remove, or if there is no layer visible AND status matches
//Why would there be no layer visible? that's weird!
//either the layervisible fields matches iLayerid, or it is 98, and "other_" is in iLayervisible string
var sFactype=facilities[keyVar]['iLayervisible'].toString();
//if (((facilities[keyVar]['iLayervisible']==iLayerid) || ((iLayerid==98) && (sFactype.indexOf('other_')!=-1))
// || (facilities[keyVar]['iLayervisible']==0))
// && (facilities[keyVar]['iTempstatus']==iStatus))
//removed part of if statement, because the other layer now uses a iLayerid==98
if (((facilities[keyVar]['iLayervisible']==iLayerid)
|| (facilities[keyVar]['iLayervisible']==0))
&& (facilities[keyVar]['iTempstatus']==iStatus))
{
//check all the layers in layerstatus - see if there is another layer that exists for this facility
//if so, show it
//make sure to show the layer that is on top, this is possible if you do a foreach on facilities[keyVar]
//and exit when you find the first one that matches layerstatus
//for it to be found it has to be a layer that is turned on
var iFoundlayer=0;
for (key in facilities[keyVar]['aiLayer'])
{
//we should be testing not iStatus, but the status of the newly found layer...
//which might be in facilities[keyVar]['aiUnitstatus_factype'][key]
//weird some facilities have layers associated with them that don't have a status - so this ignores them
if (facilities[keyVar]['aiUnitstatus_factype'][key]!=undefined)
{
//the status that we are testing, comparing to the list of layers that are on display
var iStatustest=facilities[keyVar]['aiUnitstatus_factype'][key];
//if Layerid=98 and we find an "other_" in the key - the we haven't found a layer - it's another other layer
//if (((facilities[keyVar]['aiLayer'][key]['iLayer']!=undefined) && (layerstatus[iStatustest][key]==1))
// && (!((iLayerid==98) && (key.indexOf('other_')!=-1))))
//removed the other check since we now use ilayerid==98
if ((facilities[keyVar]['aiLayer'][key]['iLayer']!=undefined) && (layerstatus[iStatustest][key]==1))
{
//get the iLayerid and the layer-rank and store in variables
iFoundlayer=key;
facilities[keyVar]['iLayervisible']=key;
break;
}
}
}
//whether a replacement layer was found or not, remove the existing point from the overlay
//would it be faster to do a bulk remove of markers? Maybe, but I do not see any supported api functions that
//do this.
if (gMarkers[keyVar]!=null) map.removeOverlay(gMarkers[keyVar]);
gMarkers[keyVar]=null;
//if Found - then move new icon to the front - by creating a new marker
if (iFoundlayer>0)
{
createMarker_shell(facilities[keyVar], keyVar, iFoundlayer);
}
//stores in facilities array that there is nothing showing
//it looks like this could be happening, when we fail to remove the marker - thus leaving markers on
//the screen
else
{
facilities[keyVar]['iLayervisible']=0;
}
}
}
}
//set the checkbox to off - in case this was part of a "toggle all" task
var sCheckname='giLayer_'+iLayerid+'_'+iStatus;
document.forms[0][sCheckname].checked=false;
//turns off 99,99
var sCheckname='giLayer_99_99';
document.forms[0][sCheckname].checked=false;
//turns off anything that is iLayerid, 99
var sCheckname='giLayer_'+iLayerid+'_99';
document.forms[0][sCheckname].checked=false;
//turns off anything that is 99, iStatus
var sCheckname='giLayer_99_'+iStatus;
document.forms[0][sCheckname].checked=false;
}
//toggles all the markers off - for use with the layer system, to get at the other layers that aren't in the 20
//basic facility types
function ToggleAllMarkersOff ()
{
//loop through facilities array
for (keyVar in facilities)
{
if (keyVar!=0)
{
if (gMarkers[keyVar]!=null) map.removeOverlay(gMarkers[keyVar]);
gMarkers[keyVar]=null;
facilities[keyVar]['iLayervisible']=0;
}
}
}
//Internal function for ToggleMarkers - turns a single layer/status combination on
function ToggleMarkersOn (iLayerid, iStatus)
{
layerstatus[iStatus][iLayerid]=1;
//alert("layer: "+iLayerid+" status: "+iStatus);
var prevKey=0;
//loop through facilities array
for (keyVar in facilities)
{
prevKey=keyVar;
//skips element #0 which is just used for a center point
if (keyVar!=0)
{
//if there is no layer currently displayed - then if this facility matches facilitytype and status - then add it
//alert ("layervisible:"+facilities[keyVar]['iTempstatus']);
if ((facilities[keyVar]['iLayervisible']==0) && (facilities[keyVar]['iTempstatus']==iStatus))
{
//now we only check the aiLayer[iLayerid] if it is defined
if (facilities[keyVar]['aiLayer']!=undefined)
{
if (facilities[keyVar]['aiLayer'][iLayerid]!=undefined)
{
if (facilities[keyVar]['aiLayer'][iLayerid]['iLayer']!=0)
{
createMarker_shell(facilities[keyVar], keyVar, iLayerid);
}
}
//or we could be adding a "other_" layer in which case we need to do a for loop thorugh aiLayer
//and add the first matching one that has "other_" in the key slot [aiLayer][key]
//else if (iLayerid==98)
//{
// for (iOtherfactype in facilities[keyVar]['aiLayer'])
// {
// if (iOtherfactype.indexOf('other_')!=-1)
// {
// //hopefully iOtherfactype works ok as the iLayerid - it's actually a string - like Other_22
// createMarker_shell(facilities[keyVar], keyVar, iOtherfactype);
// //hopefully this breaks us out of the for loop
// break;
// }
// }
// }
}
}
//else if there is currently a layer, check to see if this one get precedence
//if so - remove the icon, add the new one
else if ((facilities[keyVar]['iLayervisible']!=0) && (facilities[keyVar]['iTempstatus']==iStatus))
{
if ((facilities[keyVar]['aiLayer']!=undefined) && (facilities[keyVar]['aiLayer'][iLayerid]!=undefined))
{
if (facilities[keyVar]['aiLayer'][iLayerid]['iLayer']>facilities[keyVar]['iLayervisible'])
{
if (gMarkers[keyVar]==null)
{
alert ("error");
}
map.removeOverlay(gMarkers[keyVar]);
//we don't need to set gMarkers[keyVar]==undefined because that spot is filled in the next line
createMarker_shell(facilities[keyVar], keyVar, iLayerid);
}
}
}
//we're adding the "other" layer - need to check the priority for each "other" layer to see if
//we should bring that layer to the front.
//else if (iLayerid==98)
//{
// var iOtherfactype='';
// for (iOtherfactype in facilities[keyVar]['aiLayer'])
// {
//
// //this seems to execute even when it is false...
// if (iOtherfactype.indexOf('other_')!=-1)
// {
// if ((facilities[keyVar]['aiLayer'][iOtherfactype]['iLayer']>facilities[keyVar]['iLayervisible']) && (facilities[keyVar]['iLayervisible']!=0))
// {
// if (gMarkers[keyVar]==null)
// {
// alert ("error");
// }
// map.removeOverlay(gMarkers[keyVar]);
//we don't need to set gMarkers[keyVar]==undefined because that spot is filled in the next line
// createMarker_shell(facilities[keyVar], keyVar, iOtherfactype);
// }
// }
// }
// }
}
}
var sCheckname='giLayer_'+iLayerid+'_'+iStatus;
document.forms[0][sCheckname].checked=true;
//Check to see if we need to turn on 99,99 - if all layers/statuses are on
var iAll=1;
for (var iStatus_i=1; iStatus_i<=4; iStatus_i++)
{
for (var iLayer_i=1; iLayer_i<=20; iLayer_i++)
{
if (layerstatus[iStatus_i][iLayer_i]==0) iAll=0;
}
if (layerstatus[iStatus_i][98]==0) iAll=0;
}
if (iAll==1)
{
var sCheckname='giLayer_99_99';
document.forms[0][sCheckname].checked=true;
}
//Test for turning on iLayerid, 99
var iAll=1;
for (var iStatus_i=1; iStatus_i<=4; iStatus_i++)
{
if (layerstatus[iStatus_i][iLayerid]==0) iAll=0;
}
if (iAll==1)
{
var sCheckname='giLayer_'+iLayerid+'_99';
document.forms[0][sCheckname].checked=true;
}
//Test for turning on 99, iStatus
var iAll=1;
for (var iLayer_i=1; iLayer_i<=20; iLayer_i++)
{
if (layerstatus[iStatus][iLayer_i]==0) iAll=0;
}
if (layerstatus[iStatus][98]==0) iAll=0;
if (iAll==1)
{
var sCheckname='giLayer_99_'+iStatus;
document.forms[0][sCheckname].checked=true;
}
}
//Toggle a Layer on/off
//iOn - 1 is turn on, 0 is turn off
//iLayerid - facility id of the layer to toggle - if 99 then toggle on/off all of them
//iStatus - unitstatus of the layer to toggle - if 99 that toggle on/off all of them
//Note: this does not handle having multiple unit statuses - eg when you hide one unit status, to check to for others
//that should be displayed. I have one main unit status assigned to each facility-type, and only display that.
//This means if you search for closed facilities - it will only show them if all of the units are closed.
function ToggleMarkers (iOn, iLayerid, iStatus)
{
if (iOn==0)
{
//turning off layers - could be written to turn them on or off, and reused as a function
//turns off all layers
if ((iLayerid==99) && (iStatus==99))
{
for (var ikey=1; ikey<=4; ikey++)
{
for (var isubkey=1; isubkey<=20; isubkey++)
{
ToggleMarkersOff (isubkey, ikey);
}
//toggles off the other layer
ToggleMarkersOff (98, ikey);
}
//also need to togglemarkersoff that are not in the regular 20 layers - all the other_nn ones
ToggleAllMarkersOff ();
for (var iI=1; iI<=4; iI++)
{
var sCheckname='giLayer_99_'+iI;
document.forms[0][sCheckname].checked=false;
}
for (var iI=1; iI<=20; iI++)
{
var sCheckname='giLayer_'+iI+'_99';
document.forms[0][sCheckname].checked=false;
}
var sCheckname='giLayer_98_99';
document.forms[0][sCheckname].checked=false;
}
//turns off all layers that have the same single status
else if (iLayerid==99)
{
for (var ilayer=1; ilayer<=20; ilayer++)
{
ToggleMarkersOff (ilayer, iStatus);
}
ToggleMarkersOff (98, iStatus);
}
//turn off all unitstatuses for a single layer
else if (iStatus==99)
{
for (var istatus=1; istatus<=4; istatus++)
{
ToggleMarkersOff (iLayerid, istatus);
}
}
//turn off a single status for one layer
else
{
ToggleMarkersOff (iLayerid, iStatus);
}
}
//turn layer on
else if (iOn==1)
{
//if the user turns on proposed (iStatus:2) then turn on expanding (iStatus:4) - except for all layers (99)
if ((iStatus==2) && (iLayerid!=99))
{
var sCheckname_expanding='giLayer_'+iLayerid+'_4';
document.forms[0][sCheckname_expanding].checked=true;
}
//turn all layers on
if ((iLayerid==99) && (iStatus==99))
{
//why don't i just use turnmarkerson - I could turn on all the layers that weren't on yet using togglemarkerson, then set the appropriate values for
//layerstatus - or will that mess up togglemarkerson?
for (var ilayer=1; ilayer<=20; ilayer++)
{
for (var istatus=1; istatus<=4; istatus++)
{
ToggleMarkersOn (ilayer, istatus);
}
}
//InitLayers();
for (var ikey=1; ikey<=4; ikey++)
{
for (var isubkey=1; isubkey<=20; isubkey++)
{
layerstatus[ikey][isubkey]=1;
var sCheckname='giLayer_'+isubkey+'_'+ikey;
document.forms[0][sCheckname].checked=true;
}
layerstatus[ikey][98]=1;
var sCheckname='giLayer_98_'+ikey;
document.forms[0][sCheckname].checked=true;
}
//also need to togglemarkers-on that are not in the regular 20 layers - all the other_nn ones
//instead of iSubkey - we have other_nn
for (var iI=1; iI<=4; iI++)
{
var sCheckname='giLayer_99_'+iI;
document.forms[0][sCheckname].checked=true;
}
for (var iI=1; iI<=20; iI++)
{
var sCheckname='giLayer_'+iI+'_99';
document.forms[0][sCheckname].checked=true;
}
var sCheckname='giLayer_98_99';
document.forms[0][sCheckname].checked=true;
}
//turns On all layers that have the same single status
else if (iLayerid==99)
{
for (var ilayer=1; ilayer<=20; ilayer++)
{
ToggleMarkersOn (ilayer, iStatus);
}
ToggleMarkersOn (98, iStatus);
}
//turn On all unitstatuses for a single layer
else if (iStatus==99)
{
for (var istatus=1; istatus<=4; istatus++)
{
ToggleMarkersOn (iLayerid, istatus);
}
}
//turn On a single status for one layer
else
{
ToggleMarkersOn (iLayerid, iStatus);
}
}rkers
//count number of markers
//parses document.images to actually count number of images with 'marker' in their file name.
//test how fast this is
//ignore the markers for the layers - eg. http://www.energyjustice.net/map-test/images/whitemarker-gas.png
//var iCount=0;
//var iLength=document.images.length;
//for (var n=0; n<=iLength; n++)
//{
// if (document.images[n]!=undefined)
// {
// if ((document.images[n].src.indexOf('marker')!=-1) && (document.images[n].src.indexOf('whitemarker')==-1)) iCount++;
//}
//}
//$("span#iCount").html("Total Results: "+iCount);
var iCount_local=0;
for (keyvar_count in facilities)
{
if (keyvar_count!=0)
{
if (facilities[keyvar_count]['iLayervisible']!=0) iCount_local++;
}
}
$("span#iCount").html("Total Results: "+iCount_local);
}
//I put counties array in its own js file - so it won't cause zend studio to freeze by being a very long line
//addcounties3 is for editview - people, for populating the counties drop down
//differs from addcounties2 in that there is no "all" option
function AddCounties3 (iStatevar, iCountyvar)
{
ClearOptions(document.forms[0].giCounty);
AddToOptionList(document.forms[0].giCounty, 0, '--Select--');
for (i=1; i<100000; i++)
{
if (counties[i]!=undefined)
{
if (counties[i]['iStateid']==iStatevar)
{
AddToOptionList(document.forms[0].giCounty, i, counties[i]['sName']);
}
//mark as selected
if (i==iCountyvar)
{
document.forms[0].giCounty[document.forms[0].giCounty.length-1].selected=1;
}
}
}
}
//addcounties2 is for populating using the values from the last search
function AddCounties2 (iStatevar, iCountyvar)
{
ClearOptions(document.forms[0].giCounty);
AddToOptionList(document.forms[0].giCounty, 0, '-All-');
for (i=1; i<100000; i++)
{
if (counties[i]!=undefined)
{
if (counties[i]['iStateid']==iStatevar)
{
AddToOptionList(document.forms[0].giCounty, i, counties[i]['sName']);
}
//mark as selected
if (i==iCountyvar)
{
document.forms[0].giCounty[document.forms[0].giCounty.length-1].selected=1;
}
}
}
}
//When the user chooses a state - populate the county dropdown
//Also use this when initializing the form - for EditView where a state may already be selected
//note: looping through counties is slightly slow - 90ms according to firebug profiler
function AddCounties ()
{
var StateTypeList = document.forms[0].giState;
ClearOptions(document.forms[0].giCounty);
//loop through counties - doing a foreach would be better (eg checking 32,000 comparisons, instead of 100,000)...
//maybe start off by clearing all the options
AddToOptionList(document.forms[0].giCounty, 0, '-All-');
for (i=1; i<100000; i++)
{
if (counties[i]!=undefined)
{
if (counties[i]['iStateid']==StateTypeList[StateTypeList.selectedIndex].value)
{
AddToOptionList(document.forms[0].giCounty, i, counties[i]['sName']);
}
}
}
}
/* Based on AddCounties
*/
function AddFuels ()
{
//hmm I don't think FacTypeList is actually used?
var FacTypeList = document.forms[0].giBfactype;
ClearOptions(document.forms[0].giFacility_fueltype);
//could say "select", but they don't have to select one - so this is the less pushy version
AddToOptionList(document.forms[0].giFacility_fueltype, 0, '--Select--');
//selected factype
var iFactype=document.forms[0].giBfactype.value;
for (i=0; iC)');
AddToOptionList(document.forms[0].FuelProduct, '38', 'High-Level Radioactive Waste');
AddToOptionList(document.forms[0].FuelProduct, '39', 'Mixed Waste');
AddToOptionList(document.forms[0].FuelProduct, '40', 'Trans-Uranic Waste');
AddToOptionList(document.forms[0].FuelProduct, '41', 'Depleted Uranium');
AddToOptionList(document.forms[0].FuelProduct, '42', 'NORM/NARM');
document.forms[0].FuelProduct.style.visibility='visible';
}
else if (FacTypeList[FacTypeList.selectedIndex].value == "14")
{
AddToOptionList(document.forms[0].FuelProduct, '0', 'All');
AddToOptionList(document.forms[0].FuelProduct, '3', 'Blast Furnace Gas');
AddToOptionList(document.forms[0].FuelProduct, '5', 'Jet Fuel');
AddToOptionList(document.forms[0].FuelProduct, '6', 'Kerosene');
AddToOptionList(document.forms[0].FuelProduct, '15', 'Petroleum Coke');
AddToOptionList(document.forms[0].FuelProduct, '16', 'Propane');
AddToOptionList(document.forms[0].FuelProduct, '17', 'Residual Fuel Oil');
AddToOptionList(document.forms[0].FuelProduct, '25', 'Waste Oil');
AddToOptionList(document.forms[0].FuelProduct, '33', 'Oil');
AddToOptionList(document.forms[0].FuelProduct, '59', 'Diesel Fuel');
AddToOptionList(document.forms[0].FuelProduct, '65', 'Heavy Oil');
document.forms[0].FuelProduct.style.visibility='visible';
}
else if (FacTypeList[FacTypeList.selectedIndex].value == "15")
{
AddToOptionList(document.forms[0].FuelProduct, '1', 'Natural Gas');
document.forms[0].FuelProduct.style.visibility='visible';
}
else
{
document.forms[0].FuelProduct.style.visibility='hidden';
}
//this seems to fix the problem where it looked like you could select multiple fuels.
document.forms[0].FuelProduct.size=1;
}
function PopulateDropDownUnitType() {
var FacTypeList = document.forms[0].giPpmap_type;
// Clear out the list of giPrimaryfacilitytype
ClearOptions(document.forms[0].giPrimaryfacilitytype);
//based on the chosen value - run a php script that writes out javascript (addtopoptionlist) to add the relevant
//fuel products - whether coal, nuke, gas or other
if (FacTypeList[FacTypeList.selectedIndex].value == "13" || FacTypeList[FacTypeList.selectedIndex].value == "14" || FacTypeList[FacTypeList.selectedIndex].value == "15" || FacTypeList[FacTypeList.selectedIndex].value == "18")
{
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '0', 'All');
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '6', 'Boiler');
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '7', 'Circulating Fluidized Bed');
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '9', 'Gasification');
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '8', 'Inclined Fluidized Bed');
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '5', 'Internal Combustion Engine - Combined Cycle');
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '4', 'Internal Combustion Engine - Simple Cycle');
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '2', 'Mass Burn');
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '44', 'Organic Rankine Cycle');
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '10', 'Plasma Arc');
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '56', 'Pressurized Fluidized Bed');
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '45', 'Reciprocating Engine');
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '46', 'Supercritical');
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '55', 'Supercritical');
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '48', 'Thermal Depolymerization');
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '3', 'Turbine');
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '11', 'Unknown Type');
AddToOptionList(document.forms[0].giPrimaryfacilitytype, '47', 'Utility Boiler');
document.forms[0].giPrimaryfacilitytype.style.visibility='visible';
}
else
{
document.forms[0].giPrimaryfacilitytype.style.visibility='hidden';
}
}
function ClearOptions(OptionList) {
// Always clear an option list from the last entry to the first
for (x = OptionList.length; x >= 0; x = x - 1) {
OptionList[x] = null;
}
}
function AddToOptionList(OptionList, OptionValue, OptionText) {
// Add option to the bottom of the list
OptionList[OptionList.length] = new Option(OptionText, OptionValue);
}
//array of basic20factypes to possible fuels - based on fuel-to-unit-types-new.xls
//coal products: 8, 18, 20, 22, 32
//only doing the "must include" part - as the user can only add one fuel when they add a facility, in edit facility view they can add other fuels
//not in use
/*
var basicfactypes_to_fuel= {'1' :(26, 27),
'2' : (8, 18, 20, 22, 32),
'3' : (3,5,6,15,16,17,25,33,59,65),
'4' : (1),
//oil refinery - notes say oilpetro =-1 which are the fields below
'5' : (3, 5, 6, 15, 16, 17, 25, 33, 59, 65),
'6' : (2,8,9,15,20,21,22,24,32,56),
'7' : (1),
'8' : (63),
'9' : (2,9,12,19,23,24,46,47,48,51,52,53,54,56,57,61,62),
'10' : (9),
'11' : (2,4,12,23,24,46,51,52,53,54,56,57),
'12': (47),
'13': (21),
//cement kiln - has no fuel
'14': (0),
//landfills - I skipped adding a bunch of nuclear wastes - emailed Mike about them.
'15': (10, 19, 21, 24, 49, 51, 52, 53, 66, 67),
'16': (7),
'17': (29)};
*/
//populate the fuel type drop down based on the value in giBfactype.. strange doesn't seem in use...
function Populate_Fuels()
{
ClearOptions(document.forms[0].giFacility_fueltype);
//add options
var iType=$("giBfactype").value;
//AddToOptionList(document.forms[0].giPrimaryfacilitytype, '0', 'All');
}
function mainSites(x)
{
if (x != '')
{
self.location=x;
}
}
function s_show(){return false}
function s_hide(){return false}
if(window.event+''=='undefined')event=0
function DeleteInfo(sLocation)
{
//if (iUser='1') document.write ("");
//else
document.write ("");
}
function MassDeleteConfirm()
{
document.write ("");
}
function jereverselink(x, y)
{
document.write("" + "Email" + "");
}
//I don't think this is in use, except for some test html files like ri.html
function toggleMyKml()
{
if (toggleState == 1) {
map.removeOverlay(geoXml);
toggleState = 0;
} else {
map.addOverlay(geoXml);
toggleState = 1;
}
}
//var kmlarray=array();
//Initialize KML layers - based on GET
//If it finds the key in GET, then it calls the toggle function and turns the layer on
//if (substr_count(window.location.href , 'energyjustice.net' , 0, 200))
function kml_init()
{
if (substr_count(window.location.href , 'giIncome' , 0, 5000))
{
toggleIncome();
}
if (substr_count(window.location.href , 'giPoverty' , 0, 5000))
{
togglePoverty();
}
if (substr_count(window.location.href , 'giBlack' , 0, 5000))
{
toggleBlack();
}
if (substr_count(window.location.href , 'giHispanic' , 0, 5000))
{
toggleHispanic();
}
if (substr_count(window.location.href , 'giAsian' , 0, 5000))
{
toggleAsian();
}
if (substr_count(window.location.href , 'giNative' , 0, 5000))
{
toggleNative();
}
if (substr_count(window.location.href , 'giWhite' , 0, 5000))
{
toggleWhite();
}
if (substr_count(window.location.href , 'giElection2008' , 0, 5000))
{
toggleElection();
}
if (substr_count(window.location.href , 'giCounty_boundaries' , 0, 5000))
{
toggleCountyBoundaries();
}
if (substr_count(window.location.href , 'giCd' , 0, 5000))
{
toggleCD();
}
if (substr_count(window.location.href , 'giCoaldeath' , 0, 5000))
{
toggleCoalDeaths();
}
if (substr_count(window.location.href , 'giCoalwaste' , 0, 5000))
{
toggleCoalWaste();
}
if (substr_count(window.location.href , 'giCoalimpoundhazard' , 0, 5000))
{
toggleCoalImpoundHazard();
}
if (substr_count(window.location.href , 'giCoalimpoundrivers' , 0, 5000))
{
toggleCoalImpoundRivers();
}
if (substr_count(window.location.href , 'giEastwindcapacity' , 0, 5000))
{
toggleEastWindCapacity();
}
if (substr_count(window.location.href , 'giEastwindpower' , 0, 5000))
{
toggleEastWindPower();
}
if (substr_count(window.location.href , 'giEastwindoffshort' , 0, 5000))
{
toggleEastWindOffshore();
}
if (substr_count(window.location.href , 'giWestwindpotential' , 0, 5000))
{
toggleWestWind();
}
if (substr_count(window.location.href , 'giSolartilted' , 0, 5000))
{
toggleSolarPotential();
}
if (substr_count(window.location.href , 'giMarcellus' , 0, 5000))
{
toggleMarcellus();
}
//18 biomass layers...
var aField=new Array(9);
aField[0]='Forest';
aField[1]='PrimMill';
aField[2]='CropRes';
aField[3]='Wastewater';
aField[4]='Landfill';
aField[5]='ManureMgmt';
aField[6]='UrbanWood';
aField[7]='SecMillRes';
aField[8]='Total';
for (var i=0; i<9; i++)
{
//use the afield variables with a leading 'gi' and afield+'_sqmile'
//test for gi+afield
if (substr_count(window.location.href , 'gi'+aField[i] , 0, 5000))
{
toggleBiomassLayer(aField[i], i, 0)
}
//test for gi+afield+sqmile
if (substr_count(window.location.href , 'gi'+aField[i]+'_sqmile' , 0, 5000))
{
toggleBiomassLayer(aField[i], i, 1)
}
}
//=array (0=>'Forest', 1=>'PrimMill', 2=>'CropRes', 3=>'Wastewater', 4=>'Landfill', 5=>'ManureMgmt', 6=>'UrbanWood', 7=>'SecMillRes', 8=>'Total');
//vulcan co2 layers
var aField=new Array(9);
aField[0]='Total';
aField[1]='Commercial';
aField[2]='Industrial';
aField[3]='Residential';
aField[4]='ElectricityProd';
aField[5]='Onroad';
aField[6]='Cement';
aField[7]='Aircraft';
aField[8]='Nonroad';
for (var i=0; i<9; i++)
{
//use the afield variables with a leading 'gi' and afield+'_percapita'
//test for gi+afield
if (substr_count(window.location.href , 'gi'+aField[i] , 0, 5000))
{
toggleCarbonLayer(aField[i], i, 0)
}
//test for gi+afield+sqmile
if (substr_count(window.location.href , 'gi'+aField[i]+'_percapita' , 0, 5000))
{
toggleCarbonLayer(aField[i], i, 1)
}
}
}
var toggleStateCoalDeath=0;
var geoXmlCoalDeath;
function toggleCoalDeaths()
{
if (!geoXmlCoalDeath)
{
geoXmlCoalDeath=new GGeoXml("http://www.energyjustice.net/map/kml/Toll_from_Coal-Existing_Plants.kmz");
}
if (toggleStateCoalDeath == 1) {
map.removeOverlay(geoXmlCoalDeath);
toggleStateCoalDeath = 0;
} else {
map.addOverlay(geoXmlCoalDeath);
toggleStateCoalDeath = 1;
}
}
var toggleStateCoalWaste=0;
var geoXmlCoalWaste;
function toggleCoalWaste()
{
if (!geoXmlCoalWaste)
{
geoXmlCoalWaste=new GGeoXml("http://www.energyjustice.net/map/kml/coal-ash/coalplant_waste_in_tons_out22.kmz");
}
if (toggleStateCoalWaste == 1) {
map.removeOverlay(geoXmlCoalWaste);
toggleStateCoalWaste = 0;
} else {
map.addOverlay(geoXmlCoalWaste);
toggleStateCoalWaste = 1;
}
}
var toggleStateCoalImpoundHazard=0;
var geoXmlCoalImpoundHazard;
function toggleCoalImpoundHazard()
{
if (!geoXmlCoalImpoundHazard)
{
geoXmlCoalImpoundHazard=new GGeoXml("http://www.energyjustice.net/map/kml/coal-ash/coalimpound-hazard-out.kmz");
}
if (toggleStateCoalImpoundHazard == 1) {
map.removeOverlay(geoXmlCoalImpoundHazard);
toggleStateCoalImpoundHazard = 0;
} else {
map.addOverlay(geoXmlCoalImpoundHazard);
toggleStateCoalImpoundHazard = 1;
}
}
var toggleStateCoalImpoundRivers=0;
var geoXmlCoalImpoundRivers;
function toggleCoalImpoundRivers()
{
if (!geoXmlCoalImpoundRivers)
{
geoXmlCoalImpoundRivers=new GGeoXml("http://www.energyjustice.net/map/kml/coal-ash/coalimpound-rivers-out.kmz");
}
if (toggleStateCoalImpoundRivers == 1) {
map.removeOverlay(geoXmlCoalImpoundRivers);
toggleStateCoalImpoundRivers = 0;
} else {
map.addOverlay(geoXmlCoalImpoundRivers);
toggleStateCoalImpoundRivers = 1;
}
}
//note: we are referring to the state/staus of the election, not elections at the state level!
var toggleStateElection=0;
var geoXmlElection;
function toggleElection()
{
if (!geoXmlElection)
{
geoXmlElection=new GGeoXml("http://www.energyjustice.net/map/kml/2008election.kmz");
}
if (toggleStateElection == 1) {
map.removeOverlay(geoXmlElection);
toggleStateElection = 0;
} else {
map.addOverlay(geoXmlElection);
toggleStateElection = 1;
}
}
var toggleStateCountyBoundaries=0;
var geoXmlCountyBoundaries;
function toggleCountyBoundaries()
{
if (!geoXmlCountyBoundaries)
{
geoXmlCountyBoundaries=new GGeoXml("http://www.energyjustice.net/map/kml/county_boundaries.kmz");
}
if (toggleStateCountyBoundaries == 1) {
map.removeOverlay(geoXmlCountyBoundaries);
toggleStateCountyBoundaries = 0;
} else {
map.addOverlay(geoXmlCountyBoundaries);
toggleStateCountyBoundaries = 1;
}
}
var toggleStateCD=0;
var geoXmlCD;
function toggleCD()
{
if (!geoXmlCD)
{
geoXmlCD=new GGeoXml("http://www.energyjustice.net/map/kml/cd.kmz");
}
if (toggleStateCD == 1) {
map.removeOverlay(geoXmlCD);
toggleStateCD = 0;
} else {
map.addOverlay(geoXmlCD);
toggleStateCD = 1;
}
}
var toggleStateZCTA=0;
var sStateid=0;
function toggleZCTA(sStateid)
{
var geoXmlZCTA=new GGeoXml("http://www.energyjustice.net/map/kml/"+sStateid+".kmz");
if (toggleStateZCTA == 1) {
map.removeOverlay(geoXmlZCTA);
toggleStateZCTA = 0;
} else {
map.addOverlay(geoXmlZCTA);
toggleStateZCTA = 1;
}
}
var toggleStateEastWindCapacity=0;
var geoXmlEastWindCapacity4;
function toggleEastWindCapacity()
{
if (!geoXmlEastWindCapacity4)
{
geoXmlEastWindCapacity4=new GGeoXml("http://www.energyjustice.net/map/kml/wind-east/blobs_capf15.kmz");
}
if (toggleStateEastWindCapacity == 1) {
map.removeOverlay(geoXmlEastWindCapacity4);
toggleStateEastWindCapacity = 0;
} else {
map.addOverlay(geoXmlEastWindCapacity4);
toggleStateEastWindCapacity = 1;
}
}
var toggleStateEastWindPower=0;
var geoXmlEastWindPower;
function toggleEastWindPower()
{
if (!geoXmlEastWindPower)
{
geoXmlEastWindPower=new GGeoXml("http://www.energyjustice.net/map/kml/wind-east/blobs_pout15.kmz");
}
if (toggleStateEastWindPower == 1) {
map.removeOverlay(geoXmlEastWindPower);
toggleStateEastWindPower = 0;
} else {
map.addOverlay(geoXmlEastWindPower);
toggleStateEastWindPower = 1;
}
}
var toggleStateEastWindOffshore=0;
var geoXmlEastWindOffshore;
function toggleEastWindOffshore()
{
if (!geoXmlEastWindOffshore)
{
geoXmlEastWindOffshore=new GGeoXml("http://www.energyjustice.net/map/kml/wind-east/ewits_offshore_sites.kmz");
}
if (toggleStateEastWindOffshore == 1) {
map.removeOverlay(geoXmlEastWindOffshore);
toggleStateEastWindOffshore = 0;
} else {
map.addOverlay(geoXmlEastWindOffshore);
toggleStateEastWindOffshore = 1;
}
}
var toggleStateWestWind=0;
var geoXmlWestWind;
function toggleWestWind()
{
if (!geoXmlWestWind)
{
geoXmlWestWind=new GGeoXml("http://www.energyjustice.net/map/kml/wind-west/site-meta-out18.kmz");
}
if (toggleStateWestWind == 1) {
map.removeOverlay(geoXmlWestWind);
toggleStateWestWind = 0;
} else {
map.addOverlay(geoXmlWestWind);
toggleStateWestWind = 1;
}
}
var toggleStateIncome=0;
var geoXmlIncome;
function toggleIncome()
{
if (!geoXmlIncome)
{
geoXmlIncome=new GGeoXml("http://www.energyjustice.net/map/kml/ecounties-income.kmz");
}
if (toggleStateIncome == 1) {
map.removeOverlay(geoXmlIncome);
toggleStateIncome = 0;
} else {
map.addOverlay(geoXmlIncome);
toggleStateIncome = 1;
}
}
var toggleStatePoverty=0;
var geoXmlPoverty;
function togglePoverty()
{
if (!geoXmlPoverty)
{
geoXmlPoverty=new GGeoXml("http://www.energyjustice.net/map/kml/ecounties-poverty.kmz");
}
if (toggleStatePoverty == 1) {
map.removeOverlay(geoXmlPoverty);
toggleStatePoverty = 0;
} else {
map.addOverlay(geoXmlPoverty);
toggleStatePoverty = 1;
}
}
var toggleStateBlack=0;
var geoXmlBlack;
function toggleBlack()
{
if (!geoXmlBlack)
{
geoXmlBlack=new GGeoXml("http://www.energyjustice.net/map/kml/ecounties-black.kmz");
}
if (toggleStateBlack == 1) {
map.removeOverlay(geoXmlBlack);
toggleStateBlack = 0;
} else {
map.addOverlay(geoXmlBlack);
toggleStateBlack = 1;
}
}
var toggleStateWhite=0;
var geoXmlWhite;
function toggleWhite()
{
if (!geoXmlWhite)
{
geoXmlWhite=new GGeoXml("http://www.energyjustice.net/map/kml/ecounties-white.kmz");
}
if (toggleStateWhite == 1) {
map.removeOverlay(geoXmlWhite);
toggleStateWhite = 0;
} else {
map.addOverlay(geoXmlWhite);
toggleStateWhite = 1;
}
}
var toggleStateHispanic=0;
var geoXmlHispanic;
function toggleHispanic()
{
if (!geoXmlHispanic)
{
geoXmlHispanic=new GGeoXml("http://www.energyjustice.net/map/kml/ecounties-hispanic.kmz");
}
if (toggleStateHispanic == 1) {
map.removeOverlay(geoXmlHispanic);
toggleStateHispanic = 0;
} else {
map.addOverlay(geoXmlHispanic);
toggleStateHispanic = 1;
}
}
var toggleStateNative=0;
var geoXmlNative;
function toggleNative()
{
if (!geoXmlNative)
{
geoXmlNative=new GGeoXml("http://www.energyjustice.net/map/kml/ecounties-native.kmz");
}
if (toggleStateNative == 1) {
map.removeOverlay(geoXmlNative);
toggleStateNative = 0;
} else {
map.addOverlay(geoXmlNative);
toggleStateNative = 1;
}
}
var toggleStateAsian=0;
var geoXmlAsian;
function toggleAsian()
{
if (!geoXmlAsian)
{
geoXmlAsian=new GGeoXml("http://www.energyjustice.net/map/kml/ecounties-asian.kmz");
}
if (toggleStateAsian == 1) {
map.removeOverlay(geoXmlAsian);
toggleStateAsian = 0;
} else {
map.addOverlay(geoXmlAsian);
toggleStateAsian = 1;
}
}
var toggleStateSolarPotential=0;
var geoXmlSolarPotential_part1;
var geoXmlSolarPotential_part2;
var geoXmlSolarPotential_part3;
var geoXmlSolarPotential_part4;
var geoXmlSolarPotential_part5;
function toggleSolarPotential()
{
if (!geoXmlSolarPotential_part1)
{
geoXmlSolarPotential_part1=new GGeoXml("http://www.energyjustice.net/map/kml/solar/tilt-out-part1b.kmz");
geoXmlSolarPotential_part2=new GGeoXml("http://www.energyjustice.net/map/kml/solar/tilt-out-part2.kmz");
geoXmlSolarPotential_part3=new GGeoXml("http://www.energyjustice.net/map/kml/solar/tilt-out-part3.kmz");
geoXmlSolarPotential_part4=new GGeoXml("http://www.energyjustice.net/map/kml/solar/tilt-out-part4.kmz");
geoXmlSolarPotential_part5=new GGeoXml("http://www.energyjustice.net/map/kml/solar/tilt-out-part5.kmz");
}
if (toggleStateSolarPotential == 1) {
map.removeOverlay(geoXmlSolarPotential_part1);
map.removeOverlay(geoXmlSolarPotential_part2);
map.removeOverlay(geoXmlSolarPotential_part3);
map.removeOverlay(geoXmlSolarPotential_part4);
map.removeOverlay(geoXmlSolarPotential_part5);
toggleStateSolarPotential = 0;
} else {
map.addOverlay(geoXmlSolarPotential_part1);
map.addOverlay(geoXmlSolarPotential_part2);
map.addOverlay(geoXmlSolarPotential_part3);
map.addOverlay(geoXmlSolarPotential_part4);
map.addOverlay(geoXmlSolarPotential_part5);
toggleStateSolarPotential = 1;
}
}
var toggleStatePADrilledWells=0;
var geoXmlPADrilledWells;
function togglePADrilledWells()
{
if (!geoXmlPADrilledWells)
{
geoXmlPADrilledWells=new GGeoXml("http://www.energyjustice.net/map/kml/fracking/pa_drill3.kmz");
}
if (toggleStatePADrilledWells == 1) {
map.removeOverlay(geoXmlPADrilledWells);
toggleStatePADrilledWells = 0;
} else {
map.addOverlay(geoXmlPADrilledWells);
toggleStatePADrilledWells = 1;
}
}
//biomass layers - handles all 18 of them
//define the layers as a [9][2] array - 9 possible types of layers by 2 types (total vs sqmile)
var toggleBiomassArray = new Array(9);
//can I get away just having this be a regular variable? Probably not. Probably needs to be an array so it can be persistent
var geoXmlBiomassArray = new Array(9);
for (i=0; i<9; i++)
{
toggleBiomassArray[i] = new Array(2);
toggleBiomassArray[i][0]=0;
toggleBiomassArray[i][1]=0;
geoXmlBiomassArray[i] = new Array(2);
geoXmlBiomassArray[i][0]=0;
geoXmlBiomassArray[i][1]=0;
}
var sBiomasslayer;
var j;
var k;
//j is the biomass layer - 1..9, and k is 0 for total tons per county or 1 for per square mile
function toggleBiomassLayer(sBiomasslayer, j, k)
{
if (!geoXmlBiomassArray[j][k])
{
if (k==0) geoXmlBiomassArray[j][k]=new GGeoXml("http://www.energyjustice.net/map/kml/biomass-"+sBiomasslayer+".kmz");
else if (k==1) geoXmlBiomassArray[j][k]=new GGeoXml("http://www.energyjustice.net/map/kml/biomass-"+sBiomasslayer+"-persqmile.kmz");
}
if (toggleBiomassArray[j][k] == 1) {
map.removeOverlay(geoXmlBiomassArray[j][k]);
toggleBiomassArray[j][k] = 0;
} else {
map.addOverlay(geoXmlBiomassArray[j][k]);
toggleBiomassArray[j][k] = 1;
}
}
var toggleCarbonArray = new Array(9);
//can I get away just having this be a regular variable? Probably not. Probably needs to be an array so it can be persistent
var geoXmlCarbonArray = new Array(9);
for (i=0; i<9; i++)
{
toggleCarbonArray[i] = new Array(2);
toggleCarbonArray[i][0]=0;
toggleCarbonArray[i][1]=0;
geoXmlCarbonArray[i] = new Array(2);
geoXmlCarbonArray[i][0]=0;
geoXmlCarbonArray[i][1]=0;
}
var sCarbonlayer;
var j;
var k;
//j is the carbon layer - 1..9, and k is 0 for total tons per county or 1 for per square mile
function toggleCarbonLayer(sCarbonlayer, j, k)
{
if (!geoXmlCarbonArray[j][k])
{
if (k==0) geoXmlCarbonArray[j][k]=new GGeoXml("http://www.energyjustice.net/map/kml/carbon-"+sCarbonlayer+".kmz");
else if (k==1) geoXmlCarbonArray[j][k]=new GGeoXml("http://www.energyjustice.net/map/kml/carbon-"+sCarbonlayer+"-percapita.kmz");
}
if (toggleCarbonArray[j][k] == 1) {
map.removeOverlay(geoXmlCarbonArray[j][k]);
toggleCarbonArray[j][k] = 0;
} else {
map.addOverlay(geoXmlCarbonArray[j][k]);
toggleCarbonArray[j][k] = 1;
}
}
//uses jquery to do an embedded video popup
function VideoShow(sYoutubekey)
{
//need to set the html embed tag for the video
$( "#dialog-modal" ).html("");
$( "#dialog:ui-dialog" ).dialog( "destroy" );
$( "#dialog-modal" ).dialog({
height: 600,
width: 800,
modal: true
});
}
//Hides the next and previous page links - for displayview, where there is only one page of info being displayed.
//also hides the number of rows
/*
* jQuery UI Tooltip 1.9m2
*
* Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* http://docs.jquery.com/UI/Tooltip
*
* Depends:
* jquery.ui.core.js
* jquery.ui.widget.js
* jquery.ui.position.js
*/
(function($) {
// role=application on body required for screenreaders to correctly interpret aria attributes
if( !$(document.body).is('[role]') ){
$(document.body).attr('role','application');
}
var increments = 0;
$.widget("ui.tooltip", {
options: {
tooltipClass: "ui-widget-content",
content: function() {
return $(this).attr("title");
},
position: {
my: "left center",
at: "right center",
offset: "15 0"
}
},
_init: function() {
var self = this;
this.tooltip = $("")
.attr("id", "ui-tooltip-" + increments++)
.attr("role", "tooltip")
.attr("aria-hidden", "true")
.addClass("ui-tooltip ui-widget ui-corner-all")
.addClass(this.options.tooltipClass)
.appendTo(document.body)
.hide();
this.tooltipContent = $("")
.addClass("ui-tooltip-content")
.appendTo(this.tooltip);
this.opacity = this.tooltip.css("opacity");
this.element
.bind("focus.tooltip mouseenter.tooltip", function(event) {
self.open( event );
})
.bind("blur.tooltip mouseleave.tooltip", function(event) {
self.close( event );
});
},
enable: function() {
this.options.disabled = false;
},
disable: function() {
this.options.disabled = true;
},
destroy: function() {
this.tooltip.remove();
$.Widget.prototype.destroy.apply(this, arguments);
},
widget: function() {
return this.tooltip;
},
open: function(event) {
var target = this.element;
// already visible? possible when both focus and mouseover events occur
if (this.current && this.current[0] == target[0])
return;
var self = this;
this.current = target;
this.currentTitle = target.attr("title");
var content = this.options.content.call(target[0], function(response) {
// ignore async responses that come in after the tooltip is already hidden
if (self.current == target)
self._show(event, target, response);
});
if (content) {
self._show(event, target, content);
}
},
_show: function(event, target, content) {
if (!content)
return;
target.attr("title", "");
if (this.options.disabled)
return;
this.tooltipContent.html(content);
this.tooltip.css({
top: 0,
left: 0
}).show().position($.extend(this.options.position, {
of: target
})).hide();
this.tooltip.attr("aria-hidden", "false");
target.attr("aria-describedby", this.tooltip.attr("id"));
if (this.tooltip.is(":animated"))
this.tooltip.stop().show().fadeTo("normal", this.opacity);
else
this.tooltip.is(':visible') ? this.tooltip.fadeTo("normal", this.opacity) : this.tooltip.fadeIn();
this._trigger( "open", event );
},
close: function(event) {
if (!this.current)
return;
var current = this.current.attr("title", this.currentTitle);
this.current = null;
if (this.options.disabled)
return;
current.removeAttr("aria-describedby");
this.tooltip.attr("aria-hidden", "true");
if (this.tooltip.is(':animated'))
this.tooltip.stop().fadeTo("normal", 0, function() {
$(this).hide().css("opacity", "");
});
else
this.tooltip.stop().fadeOut();
this._trigger( "close", event );
}
});
})(jQuery);
$("[title]").tooltip();
function ResetSearchForm()
{
$(':input','#searchform')
.not(':button, :submit, :reset, :hidden')
.val('')
.removeAttr('checked')
.removeAttr('selected');
document.forms[0].gfUnitmwmaxrange.disabled=0;
document.forms[0].gfUnitmwminrange.disabled=0;
document.forms[0].gfUnitmwmaxrange.style.backgroundColor="#ffffff";
document.forms[0].gfUnitmwminrange.style.backgroundColor="#ffffff";
}