﻿/// <reference path="jquery-1.3.2.min.js" />
////---------------------------------------------------------------
//// Shared Code Begins
////---------------------------------------------------------------
var _sFINAL_CASE_PAGE = "";
var _bAddressNeeded = false;
var _bSecondPageNeeded = false;
var _bSpecificLocationNeeded = true;
var _sSECOND_PAGE = "";
var _bArticlesReviewed = false;
var _bRedirectToMyRequestPage = false;
var _bCallDialog = false;
//Function encodes s into HTML
function HtmlEncode(s)
{
	if (typeof(s) != "string")
	{
		return s;
	}
	s = s.replace(/&/g, "&amp;");
	s = s.replace(/</g, "&lt;");
	s = s.replace(/>/g, "&gt;");
	return s.replace(/\"/g, "&quot;");
}

////---------------------------------------------------------------
//// Removes trailing and spaces before the string
////---------------------------------------------------------------
String.prototype.trim = function() {
	return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

////---------------------------------------------------------------
//// SHARED CODE ENDS
////---------------------------------------------------------------

//XML compatibility code for Mozilla
if (document.implementation && document.implementation.hasFeature("XPath", "3.0"))
{ 
	XMLDocument.prototype.selectNodes = function(sExpr, contextNode)
	{
		var oResult = this.evaluate(sExpr, (contextNode?contextNode:this), 
							this.createNSResolver(this.documentElement),
							XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
		var nodeList = new Array(oResult.snapshotLength);
		nodeList.expr = sExpr;
		
		for(i=0;i<nodeList.length;i++)
		{
			nodeList[i] = oResult.snapshotItem(i);
		}
		
		return nodeList;
	};
	
	Element.prototype.selectNodes = function(sExpr)
	{
		var doc = this.ownerDocument;
		if(doc.selectNodes)
		{
			return doc.selectNodes(sExpr, this);
		}
		else
		{
			//not supported
		}
	};
	
	XMLDocument.prototype.selectSingleNode = function(sExpr, contextNode)
	{
		var ctx = contextNode?contextNode:null;
		sExpr += "[1]";
		var nodeList = this.selectNodes(sExpr, ctx);
		if(nodeList.length > 0)
		{
			return nodeList[0];
		}
		else 
		{
			return null;
		}
	};
	Element.prototype.selectSingleNode = function(sExpr)
	{
		var doc = this.ownerDocument;
		if(doc.selectSingleNode)
		{
			return doc.selectSingleNode(sExpr, this);
		}
		else
		{
			//not supported
		}
			
	};
	Event.prototype.__defineGetter__("srcElement", function () 
	{
		var node = this.target;
		while (node.nodeType != 1) 
		{
			node = node.parentNode;
		}
		return node;
	});
	
	Event.prototype.__defineSetter__('cancelBubble',function (v)
	{
		if (v)
		{
			this.stopPropagation();
		}
	});
	
	XMLDocument.prototype.__defineGetter__("xml", function ()
	{
		return (new XMLSerializer()).serializeToString(this);
	});
	
	// Emulates IE's xml property. Gives an XML serialization of the DOM Object
	Node.prototype.__defineGetter__("xml", function ()
	{
		return (new XMLSerializer()).serializeToString(this);
	});

	/* set the SelectionNamespaces property the same for NN or IE: */
	XMLDocument.prototype.setProperty = function(p,v)
	{
		if(p == "SelectionNamespaces" && v.indexOf("xmlns:dflt") == 0)
		{
			this.defaultNS = v.replace(/^.*=\'(.+)\'/,"$1");
		}
	}

	XMLDocument.prototype.defaultNS;
	XMLDocument.prototype.setProperty = function(p,v)
	{
		if( p == "SelectionNamespaces" && v.indexOf("xmlns:dflt")==0)
		{
			this.defaultNS = v.replace(/^.*=\'(.+)\'/,"$1");
		}
	}
	Node.prototype.__defineGetter__("text", function () 
	{
		return(this.textContent);
	});
	
	Node.prototype.__defineSetter__("text", function (txt) 
	{
		this.textContent = txt;
	});
	
	HTMLElement.prototype.__defineGetter__("innerText", function() 
	{
		return this.textContent;
	});
	
	HTMLElement.prototype.__defineSetter__("innerText", function(val) 
	{
		this.textContent = val;
	});
	
	var _emptyTags = {
		"IMG":   true,
		"BR":    true,
		"INPUT": true,
		"META":  true,
		"LINK":  true,
		"PARAM": true,
		"HR":    true
	};

	HTMLElement.prototype.__defineGetter__("outerHTML", function () 
	{
		var attrs = this.attributes;
		var str = "<" + this.tagName;
		for (var i = 0; i < attrs.length; i++)
		{
			str += " " + attrs[i].name + "=\"" + attrs[i].value + "\"";
		}

		if (_emptyTags[this.tagName])
		{
			return str + ">";
		}

		return str + ">" + this.innerHTML + "</" + this.tagName + ">";
	});
}

//************************************************************************************
//NEWREQUEST PAGE BEGINS
//************************************************************************************

//creates httpobject 
 function CreateHttpObject()
 {
	//to return null for unsupported browsers
	oHttpObject = null;
	//mozilla object
	if (window.XMLHttpRequest)
	{
		oHttpObject = new XMLHttpRequest();
	}
	//IE 6/7 object
	else if (window.ActiveXObject)
	{
		oHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return oHttpObject;
 }

// Hack around IE6 bug that always shows picklists on top
function TogglePicklistsForIE6(bShow)
{
	// Hide subjects and topics
	if (document.getElementById("subjectRow") != null)
	{
		if (bShow)
		{
			document.getElementById("subjectRow").style.display = "inline";
		}
		else
		{
			document.getElementById("subjectRow").style.display = "none";
		}
	}
	
	// Hide Landmarks
	if (document.getElementById("landMarkRow") != null)
	{
		if (bShow)
		{
			document.getElementById("landMarkRow").style.display = "inline";
		}
		else
		{
			document.getElementById("landMarkRow").style.display = "none";
		}
	}	
}

/*function validate that we have enough infomation on the page 
 *to create a request.  Returns true if all items are filled
 *out, false if not
 */
function ValidateUserInputNewRequestPage()
{
	//make sure one subject is selected
	if( document.getElementById("hidSubject").value != "" &&
	    document.getElementById("inputUserComment").value !="")
	{
		return true;
	}
	return false;
}
function ValidateInputComment()
{
		//make sure one subject is selected
	if(document.getElementById("inputUserComment").value !="")
	{
		return true;
	}
	return false;
}

/*function builds the subject title of the case
 *from a hyphonated concatenation of the picklists that
 *have been selected by the user
 *WARNING: No validation. Call ValidateUserInputNewRequestPage() before using
 *to ensure 1 picklist is selected
 */
function BuildSubjectTitle(optTitle)
{
	var sForTitle = optTitle; //GetSelectedOptionFromPicklist("levelOneRequestSelect");

//	if(document.getElementById("levelTwoRequestSelect").selectedIndex > 0)
//	{
//		sForTitle = sForTitle + "-" + GetSelectedOptionFromPicklist("levelTwoRequestSelect")
//	}
	return HtmlEncode(sForTitle);
}

/*function gets the id of the lowest seleted picklist 
 *from the subject tree on the page
 *
 *WARNING: No validation. Call ValidateUserInputNewRequestPage() before using
 *to ensure 1 picklist is selected
 */
function GetProperPicklistForSubject()
{
	if( document.getElementById("levelTwoRequestSelect").selectedIndex > 0)
	{
		return "levelTwoRequestSelect";
	}

	return "levelOneRequestSelect";
}

/*Function returns the innerText of the selected
 *option of the picklist with id == sPicklistId
 */
function GetSelectedOptionFromPicklist(sPicklistId)
{
	return document.getElementById(sPicklistId).options[document.getElementById(sPicklistId).selectedIndex].innerText;
}


/*Wrapper is simply a way to maniputlate the data for populating the
 *SELECT options for the tags using LoadSubjectPicklist(sSelectId, sParentSubjectId)
 *sSelectToFillId == the id of the control to fill the options of
 *sParentSelectId == the id of the parent SELECT control that has
 *               created the call and has the data for populating sSelectToFillId
 *iSelectedIndex == the index of the item selected in sParentSelectId
 */
function LoadPicklistByIndex(sSelectToFillId,sParentSelectId,iSelectedIndex)
{
	
	//TODO: CLean up UI on this
	//this vs selected  notparent 
	if(iSelectedIndex < 1)
	{		
		//switch
		//switch
		if(sParentSelectId =="levelOneRequestSelect")
		{
			CleanPickList("levelTwoRequestSelect");
			ResetLevelTwoRequestSelect();
		}
		return;
	}
	
	if(sParentSelectId == "levelTwoRequestSelect")
	{
		ChckeSubjectTopicOptions();
	}
	
	if(sParentSelectId =="levelOneRequestSelect")
	{		
		var sOptionValue = document.getElementById(sParentSelectId).options[iSelectedIndex].value;

		LoadSubjectPicklist(sSelectToFillId,sOptionValue);
	}
}

/*utility to clean out a picklist
 *picklistId == the picklist to delete options from
 */
function CleanPickList(picklistId)
{
	var oSelect = document.getElementById(picklistId);

	//remove all old info, add please select to first slot
	while(oSelect.length > 0)
	{
		oSelect.remove(oSelect.length - 1);
	}
	
}

//clears out all the inputs and the map

function ClearAllInputsAndMap()
{

		DeleteAllMapEntries();
		document.getElementById("inputStreetAddress").value="";
		document.getElementById("inputApptNumber").value="";
		document.getElementById("inputCity").value="";
		document.getElementById("inputZipCode").value="";	
}

function ClearShortAddressForm()
{

    ClearPinsLatLong();
    ClearAspAddressForm();
    ClearAspComment();
    
}

function ClearAspAddressForm() {
    DeleteAllMapEntries();
    document.getElementById("ctl00_Main_LocationInfo_inputStreetAddress").value = "";
    //document.getElementById("ctl00_Main_LocationInfo_inputCity").value = "";
}

function ClearAspComment() {
    document.getElementById("ctl00_Main_UserComment_inputUserComment").value = "";
}

function ClearAddressAndMap()
{

		DeleteAllMapEntries();
		document.getElementById("inputStreetAddress").value="";
	
}
function ClearAddress()
{
		document.getElementById("inputStreetAddress").value="";	
}
function ClearAspAddress() {
    document.getElementById("ctl00_Main_LocationInfo_inputStreetAddress").value = "";
}



/*also resets the original subject picklist
 *This means the data in _subjectTreelXmlDoc
 *better not have been corrupted or bad 
 *things may happen
 */
function ClearPickListandInput()
{
        location.href = window.location;
		//CleanAndClearPicklistsByID("LevelOneRequestSelect");
		//CleanAndClearPicklistsByID("levelTwoRequestSelect");
//		document.getElementById(_sPrePendForMasterPage +"submitCaseButton").style.display = "inline";
//		//document.getElementById(_sPrePendForMasterPage +"continueCaseButton").style.display = "none";
//		document.getElementById("inputUserComment").value="";
//		document.getElementById("caseCommentTr").style.display = "none";
//		document.getElementById("caseCommentTd").style.display = "none";
//		document.getElementById("cbInformByEmail").checked=true;
}


/*removes all the options from a picklist
 *with the ID == picklistId
 *Then either hides it or restores it 
 *(Subject picklist is the one restored)
 *_subjectTreelXmlDoc must not be corrupted or
 *pick lists will to load correctly
 */
function CleanAndClearPicklistsByID(picklistId)
{
	
		var oSelect = document.getElementById(picklistId);
		if (oSelect)
		{
			//remove all old info, add please select to first slot
			while(oSelect.length > 0)
			{
				oSelect.remove(oSelect.length - 1);
			}
		}
		
		switch(picklistId)
		{
			case "LevelOneRequestSelect":
			LoadSubjectPicklist("levelOneRequestSelect",GUID_EMPTY);
			//document.getElementById("LevelTwoRequestSelect").disabled = true;
			break;
			
			case "levelTwoRequestSelect":
			ResetLevelTwoRequestSelect();
			break;
			
			
			default:
			//something weird happened if we hit this
		}
}

function ResetLevelTwoRequestSelect()
{   
	if(document.getElementById("levelOneRequestSelect").selectedIndex < 1)
	{
			var oOption = window.document.createElement("OPTION");
			document.getElementById("levelTwoRequestSelect").options.add(oOption);
			document.getElementById("levelTwoRequestSelect").options[0].value = "NOT USED";
			document.getElementById("levelTwoRequestSelect").options[0].innerText = _sDEFAULT_PICKLIST_VALUE + " Subject First";
	}
}


/*Function is used by call back on the map
 *to add a push pin to the location the map 
 *has been recentered to through
 *an address lookup
 * a,b,c,d,e are variables generated durring the call back
 * and are defined by the api
 */
function UpdateMapInformation(oVEShapeLayer, arVEFindResults, arVEPlaces, bMoreResults, sError)
{
	AddIconToMap(arVEPlaces[0].LatLong.Latitude, arVEPlaces[0].LatLong.Longitude,_sMAP_HOVER_TIP_LOCATION_TITLE,ConcatenateAddress(),false);
	document.getElementById(_sPrePendForMasterPage + "inputLatitude").value = arVEPlaces[0].LatLong.Latitude;
	document.getElementById(_sPrePendForMasterPage + "inputLongitude").value = arVEPlaces[0].LatLong.Longitude;	
}

/*Function used to place an incident on the map 
 *through a lookup of the address entered by a user
 */
function PinpointIncidentLocationOnMap()
{ 
	DeleteAllMapEntries();
	
	var sAddress = ConcatenateAddress();	
	
	if (sAddress == _sNO_LOCATION_PROVIDED)
	{		
		return;		
	}
		
	
	var VEFindResult = _map.Find(null,sAddress,null,null, 0,1,
	true,true,true,true,UpdateMapInformation);
}

/*Concatenates all the address fields
 *on the form into 1 big string for shooting
 *to Virtual Earth
 *It will only add appt if app # filled out
 *Performs no validation
 *NOTE: string "apartment" is due to Microsoft VE Dependancy 
 */
function ConcatenateAddress()
{
	var sIncidentAddress = document.getElementById("inputStreetAddress").value + " ";

	if(document.getElementById("inputApptNumber").value != "")
	{
		sIncidentAddress = sIncidentAddress 
		+ "apartment " 
		+ document.getElementById("inputApptNumber").value 
		+ " "  
	}
	
	sIncidentAddress = sIncidentAddress
					+ document.getElementById("inputCity").value 
					+ " " 					
					+ document.getElementById("inputZipCode").value; 
					
	sIncidentAddress = sIncidentAddress.trim();
	
	if(sIncidentAddress == "")
	{
		return _sNO_LOCATION_PROVIDED;
	}
	
	return sIncidentAddress;
}

//check if registration is needed
function IsRegistrationRequired(sTopicField, sSubjectField)
{
	return IsSubjectTopicInvalid(sTopicField, sSubjectField, arSubjectTopicRegistration);
}
//check if address is needed
function IsAddressRequired(sTopicField, sSubjectField)
{
	return IsSubjectTopicInvalid(sTopicField, sSubjectField, arSubjectTopicAddress);
}
//check if specific location is needed
function IsSpecificLocationNotRequired(sTopicField, sSubjectField)
{
	return IsSubjectTopicInvalid(sTopicField, sSubjectField, arSubjectTopicCorridor);
}
//check if second page is needed
function IsSecondPageRequired(sTopicField, sSubjectField)
{
	return IsSubjectTopicInvalid(sTopicField, sSubjectField, arSubjectTopicSecondPage);
}
//check if call to OM is needed
function IsCallOMRequired(sTopicField, sSubjectField)
{
	return IsSubjectTopicInvalid(sTopicField, sSubjectField, arSubjectTopicCallOM);
}
//check if call to RM needed
function IsCallRMRequired(sTopicField, sSubjectField)
{
	return IsSubjectTopicInvalid(sTopicField, sSubjectField, arSubjectTopicCallRM);
}

//checks if the Subject and Topic is valid for guest users
function IsSubjectTopicInvalid(sTopicField, sSubjectField, arSubjectTopic)
{
	var oSubject = document.getElementById(sSubjectField);
	var sSubject = oSubject.options[oSubject.selectedIndex].text.toLowerCase();
	var oTopic = document.getElementById(sTopicField);
	var sTopic = oTopic.options[oTopic.selectedIndex].text.toLowerCase();
	var iLength = arSubjectTopic.length;
	for(var i = 0; i < iLength; i++)
	{		
		if((arSubjectTopic[i].indexOf(sSubject) != -1) && (arSubjectTopic[i].indexOf(sTopic) != -1))
		{
			return true;
		} 
	}
	return false;
}

//redirects to the New Request Page
function RedirectToMyRequestPage()
{
	if(_bCallDialog)
	{
		return;
	}
	if (sOrigRequestPage != undefined && sOrigRequestPage != "" && sOrigRequestPage.indexOf(window.location.hostname) > -1) {
	    window.location = sOrigRequestPage;
	} else {
	    if(_bRedirectToMyRequestPage)
	    {
		    window.location = sMyRequestPage;
	    }
	    else
	    {
		    window.location = sNewRequestPage;
	    }
	}
}

//validates the email provided by user
function ValidateEmail(email)
{

	emailRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/
	if(emailRe.test(email))
	{
	    return true
	}
	else
	{
	    return false;
	}                  
}

//display the case in a new window
function ShowCaseDetail(sIncidentId, iDescLengeth)
{

		if(IsUserSessionExpired().indexOf("false") != -1)
		{
			var sFeatures = "width=450,height=500,resizable=no,scrollbars=yes";
			window.open("GetRequestDetail.aspx?incidentid=" + sIncidentId, "mywindow", sFeatures);
		}
		else
		{
			var sFeatures = "width=450,height=300,resizable=no,scrollbars=no";
			my_window= window.open ("", "caseWindow", sFeatures); 
			my_window.document.body.innerHTML = "";
			var sDialogBody =  '<html><head><title>Reqiest Details</title>';
			sDialogBody += '</head><body>';
			sDialogBody += '<div>Your Session Has Expired. Please Log in to See the Details.';
			sDialogBody +=  '</div><br/><div></div><input type="button" value="Close Window" onclick="window.close()"/>'
			sDialogBody +=  '</body></html>';
			my_window.document.write(sDialogBody);								
		}

}

//checks if the user session is expired before making an ajax call is made
function IsUserSessionExpired()
{
		var sXmlToSend =  "<user><element name='isguestuser'>" + bIsGuest + "</element></user>" ;
		var sResponseText = "true"; //SendXmlToServer(sXmlToSend, "../Registration/HandleSessionEnd.aspx")
		if(sResponseText.indexOf("true") != -1)
		{
			return "false";
		}
		else
		{
			return "Session Expired. Please Login again to continue";;
		}
}

//function sends and XML document to a specified page on the server
//sXmlToSend == the XML string to send to server
//sRequestHandlerUrl == the URL of the page to recieve the 
function SendXmlToServer(sXmlToSend,sRequestHandlerUrl)
{
	//TODO: naive method, may have an advantage by doing onchange
	//hideous block loads XML for shipping back to server
	//with info from UI elements on the page

	//set to null for unsupported browser check
	_oXmlSendCase=null;

	//mozilla object
	if (window.XMLHttpRequest)
	{
		_oXmlSendCase=new XMLHttpRequest();
	}
	//IE 6/7 object
	else if (window.ActiveXObject)
	{
		_oXmlSendCase=new ActiveXObject("Microsoft.XMLHTTP");
	}

	//if not null must be supported, send request
	//else prompt user
	if (_oXmlSendCase!=null)
	{
		//_oXmlSendCase.onreadystatechange=StateChange;

		//send the data back to the server and wait for response false == wait
		_oXmlSendCase.open("POST", sRequestHandlerUrl, false);
		_oXmlSendCase.send(sXmlToSend);
		return _oXmlSendCase.responseText;		
	}
}

//retrieves the querystring values
function GetQueryStringValue(sKey)
{
	// Create a new QueryString object
	var myQuery = new QueryString();
	// Read query string from browser into the new QueryString object, name myQuery
	myQuery.read();
	// Check the status, to make sure it read the query string
	// Then write out the query string arguments
	if(myQuery.getStatus())
	{		
		var aQueryData = myQuery.getAll();
		return aQueryData[sKey];
	}
	else
	{	
		return "";
	}
}

function QueryString() 
{
	
	// PROPERTIES	
	this.arg = new Array;
	this.status = false;
	
	// METHODS	
	this.clear = Clear;
	this.get = Get;
	this.getAll = GetAll;
	this.getStatus = GetStatus;
	this.read = Read;
	this.set = Set;
	this.write = Write;
	
	// FUNCTIONS
	// Clears the array, this.arg, of all query string data
	function Clear()
	{	
		this.arg = new Array;
	}
	
	// Returns a named value from the query string
	function Get(sName)
	{	
		return this.arg[sName];
	}
		
	// Return all data as an associative array
	function GetAll()
	{
		return this.arg;
	}
	
	function GetStatus()
	{
		return this.status;
	}
	
	// Reads the query string into an array named this.arg
	function Read(sUrl) 
	{
		var aArgsTemp, aTemp, sQuery;
		// You can pass in a URL query string
		if(sUrl)		
		{	
			sQuery = sUrl.substr(sUrl.lastIndexOf("?")+1, sUrl.length);
		}
		// Or read it from the browser location
		else
		{
			sQuery = window.location.search.substr(1, window.location.search.length);
		}
		// Check that query string exists and contains data
		// If not (length < 1) then return
		
		if(sQuery.length < 1) 
		{
			return;
		}			
		// Else set this.status to true and proceed		
		else 
		{
			this.status = true;
		}			
		aArgsTemp = sQuery.split("&");	
		for (var i=0 ; i<aArgsTemp.length; i++)
		{	
			aTemp = aArgsTemp[i].split("=");		
			this.arg[aTemp[0]] = aTemp[1];			
		}
	}		
		
	// Overwrites an existing named value in the array, this.arg		
	// You can also pass null to delete from array
	function Set(sName,sValue)
	{	
		if (sValue == null) 
		{
			delete this.arg[sName];
		}			
		else 
		{
			this.arg[sName] = sValue;
		}
	}		
		
	// Writes out a string from the data in this.arg array
	// This string can be used to pass a new query string to the browser
	// when navigating to the next page. This allows a page
	// to create and pass data to another page via JavaScript.
	function Write()
	{	
		var sQuery = new String(""); 
		for (var sName in this.arg)			
		{
			if (sQuery != "") 
			{
				sQuery += "&";
			}			
			if (this.arg[sName]) 
			{
				sQuery += sName + "=" + this.arg[sName];
			}
		}		
		if (sQuery.length > 0) 
		{
			return "?" + sQuery;
		}			
		else 
		{
			return sQuery;
		}
		
	}

}
function SaveMyCustomerInfo(myCheckbox) {
    if (myCheckbox.checked) {
        $("#pwdArea").show();
    }
    else {
        $("#pwdArea").hide();
    }
}
//************************************************************************************
//NEWREQUEST PAGE ENDS
//************************************************************************************/

$(document).ready(function() {
    var LocInputSwitchTo = "Map"

    $(".AddressToggle").click(function(event) {
        switch (LocInputSwitchTo) {
            case "Address":
                $("#DKAddress").html("Don't know the address? ");
                $(".AddressToggle").html("Use a map.");
                $("#locMap").hide();
                $("#MapInstructions").hide();
                $("#locAddress").fadeIn();
                ClearPinsLatLong();
                LocInputSwitchTo = "Map"
                break;
            case "Map":
                $("#DKAddress").html("Don't want to use the map? ");
                $(".AddressToggle").html("Tell us the address.");
                $("#locAddress").hide();
                $("#MapInstructions").show();
                $("#locMap").fadeIn();
                ClearAspAddress();
                LocInputSwitchTo = "Address"
                break;
            default:
                $("#DKAddress").html("Don't know the address? ");
                $(".AddressToggle").html("Use a map.");
                $("#locMap").hide();
                $("#MapInstructions").hide();
                $("#locAddress").fadeIn();
                ClearPinsLatLong();
                LocInputSwitchTo = "Map"
                break;
        }
        return false;
    });

    $("#HelpLinkImage").click(function() {
        $(".HelpMap").toggle();
        return false;
    });
    $(".CloseHelp").click(function() {
        $(".HelpMap").toggle();
        return false;
    });
    function ToggleMap(MapOrAddress) {
        switch (MapOrAddress) {
            case "Address":
                $("#locMap").hide();
                $("#locAddress").fadeIn();
                ClearPinsLatLong();
                break;
            case "Map":
                $("#locAddress").hide();
                $("#locMap").fadeIn();
                ClearAspAddress();
                break;
            default:
                $("#locMap").hide();
                $("#locAddress").fadeIn();
                ClearPinsLatLong();
                break;
        }
    }

    swapValues = [];
    $(".swap_value").each(function(i) {
        swapValues[i] = $(this).val();
        $(this).focus(function() {
            if ($(this).val() == swapValues[i]) {
                $(this).val("");
                $(this).css("color", "#000");
            }
        }).blur(function() {
            if ($.trim($(this).val()) == "") {
                $(this).val(swapValues[i]);
                $(this).css("color", "Gray");
            }
        });
    });

    $('.tabs a').click(function() {
        $('.tabs a').removeClass('active');
        $(this).addClass('active');
        $('div.tabContent').removeClass('activeTC');
        $("#" + this.id + "TC").addClass('activeTC');
    });

});

