//alert('starting Loading');//includeJavaScript('admin.js');//includeJavaScript('admin_Build.js');var OPACITY_POPUP_SHOWN			=1.0;var OPACITY_BACKGROUND_SHOWN	=0.65; 		//MUST ALSO BE SET IN popUps.css in backgroundPopupvar starSet=false;	var votesCast={};	var popupStatuses ={		'divPopUpViewComments'	:0,		'divPopUpLoadScreen'	:0,		'divPopUpPage'			:0,		'divPopUpComment'		:0,		'divScrapeURLs'			:0,		'divPopUpWriteAReview'	:0,		'divPopUpEditCell'		:0	};	var templatesWeAllowUsersToEdit=[		'header.html',		'footer.html',		'rightPanel.html',		'itemReview.html',		'reviewComment.html'	];	var	warnedReviewIsZero				=false;	var abortScraping					=false;	var mappedFields					=[];	var numOfRows						=0;	var numOfColumns					=0;	var currentlySelectedTemplateID		=-1;	var currentlySelectedCSSID			=-1;	var currentlySelectedTableID		=null;	var currentlySelectedDatabaseID		=null;	var currentlySelectedReviewID		=null;	var masterTables					=[];	var allReviewsShown					=[];	var allRowShown						=[];//PUBLIC	function dropQuotesAndNewLine(toClean){		//alert('dropQuotesAndNewLine\n'+toClean);		toClean=toClean.replace(/###SINGLEQUOTE###/g,"",toClean);		toClean=toClean.replace(/###DOUBLEQUOTE###/g,"",toClean);		toClean=toClean.replace(/###NEWLINE###/g,"",toClean);		//alert('dropQuotesAndNewLine CLEANED\n'+toClean);		return	toClean	}	function returnQuotesAndNewLine(toClean){		//alert('returnQuotesAndNewLine\n'+toClean);		toClean=toClean.replace(/###SINGLEQUOTE###/g,"'",toClean);		toClean=toClean.replace(/###SINGLEQUOTE###/g,'"',toClean);		toClean=toClean.replace(/###NEWLINE###/g,"\n",toClean);		//alert('returnQuotesAndNewLine RETURNED\n'+toClean);		return	toClean;	}	function searchSubmit(){		var link=ABSOLUTE_PATH;		if(getFormElementValue('formSearchField')!=''){			link+='&search='+getFormElementValue('formSearchField');		}		if(getFormElementValue('formSearchCloseTo')!=''){			link+='&location='+getFormElementValue('formSearchCloseTo');		}		location.href=link;	}	function allowTabCharacter(documentID) {		//alert('allowTabCharacter');		if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);		}else if( (event != null)&&				(event.srcElement)&&				(event.srcElement.value) ){			if (event.keyCode == 9) {  // tab character				if (document.selection != null) {					document.selection.createRange().text = '\t';					event.returnValue = false;				}else {					event.srcElement.value += '\t';					return false;				}			}		}	}	function keyHandler(e) {		if(e.keyCode == 9) {//TABKEY			var tab = "\t";			var myTarget = e.target;			var ss = myTarget.selectionStart;			var se = myTarget.selectionEnd;            myTarget.value = myTarget.value.slice(0,ss).concat(tab).concat(myTarget.value.slice(ss,myTarget.value.length));			if (ss == se) {				myTarget.selectionStart = myTarget.selectionEnd = ss + tab.length;			}			if(e.preventDefault) {				e.preventDefault();			}			return false;		}else{			ev = e || window.event;			kCode = ev.keyCode || ev.which;   // gets the keycode in ie or ns			//alert('kCode='+kCode);			if (ev.ctrlKey && ev.shiftKey && kCode == 19 || ev.ctrlKey && ev.shiftKey && kCode == 83) {    // ctrl+alt+s				//alert('Was never able to get this to work');			}		}	}	function get_html_translation_table (table, quote_style) {		var entities = {}, hash_map = {}, decimal = 0, symbol = '';    var constMappingTable = {}, constMappingQuoteStyle = {};		var useTable = {}, useQuoteStyle = {};				// Translate arguments		constMappingTable[0]      = 'HTML_SPECIALCHARS';    constMappingTable[1]      = 'HTML_ENTITIES';		constMappingQuoteStyle[0] = 'ENT_NOQUOTES';		constMappingQuoteStyle[2] = 'ENT_COMPAT';		constMappingQuoteStyle[3] = 'ENT_QUOTES';		useTable       = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';		useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';	 		if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {			throw new Error("Table: "+useTable+' not supported');        // return false;		}		entities['38'] = '&amp;';		if (useTable === 'HTML_ENTITIES') {			entities['160'] = '&nbsp;';			entities['161'] = '&iexcl;';			entities['162'] = '&cent;';			entities['163'] = '&pound;';			entities['164'] = '&curren;';			entities['165'] = '&yen;';			entities['166'] = '&brvbar;';			entities['167'] = '&sect;';			entities['168'] = '&uml;';			entities['169'] = '&copy;';			entities['170'] = '&ordf;';			entities['171'] = '&laquo;';			entities['172'] = '&not;';			entities['173'] = '&shy;';			entities['174'] = '&reg;';			entities['175'] = '&macr;';			entities['176'] = '&deg;';			entities['177'] = '&plusmn;';			entities['178'] = '&sup2;';			entities['179'] = '&sup3;';			entities['180'] = '&acute;';			entities['181'] = '&micro;';			entities['182'] = '&para;';			entities['183'] = '&middot;';			entities['184'] = '&cedil;';			entities['185'] = '&sup1;';			entities['186'] = '&ordm;';			entities['187'] = '&raquo;';			entities['188'] = '&frac14;';			entities['189'] = '&frac12;';			entities['190'] = '&frac34;';			entities['191'] = '&iquest;';			entities['192'] = '&Agrave;';			entities['193'] = '&Aacute;';			entities['194'] = '&Acirc;';			entities['195'] = '&Atilde;';			entities['196'] = '&Auml;';			entities['197'] = '&Aring;';			entities['198'] = '&AElig;';			entities['199'] = '&Ccedil;';			entities['200'] = '&Egrave;';			entities['201'] = '&Eacute;';			entities['202'] = '&Ecirc;';			entities['203'] = '&Euml;';			entities['204'] = '&Igrave;';			entities['205'] = '&Iacute;';			entities['206'] = '&Icirc;';			entities['207'] = '&Iuml;';			entities['208'] = '&ETH;';			entities['209'] = '&Ntilde;';			entities['210'] = '&Ograve;';			entities['211'] = '&Oacute;';			entities['212'] = '&Ocirc;';			entities['213'] = '&Otilde;';			entities['214'] = '&Ouml;';			entities['215'] = '&times;';			entities['216'] = '&Oslash;';			entities['217'] = '&Ugrave;';			entities['218'] = '&Uacute;';			entities['219'] = '&Ucirc;';			entities['220'] = '&Uuml;';			entities['221'] = '&Yacute;';			entities['222'] = '&THORN;';			entities['223'] = '&szlig;';			entities['224'] = '&agrave;';			entities['225'] = '&aacute;';			entities['226'] = '&acirc;';			entities['227'] = '&atilde;';			entities['228'] = '&auml;';			entities['229'] = '&aring;';			entities['230'] = '&aelig;';			entities['231'] = '&ccedil;';			entities['232'] = '&egrave;';			entities['233'] = '&eacute;';			entities['234'] = '&ecirc;';			entities['235'] = '&euml;';			entities['236'] = '&igrave;';			entities['237'] = '&iacute;';			entities['238'] = '&icirc;';			entities['239'] = '&iuml;';			entities['240'] = '&eth;';			entities['241'] = '&ntilde;';			entities['242'] = '&ograve;';			entities['243'] = '&oacute;';			entities['244'] = '&ocirc;';			entities['245'] = '&otilde;';			entities['246'] = '&ouml;';			entities['247'] = '&divide;';			entities['248'] = '&oslash;';			entities['249'] = '&ugrave;';			entities['250'] = '&uacute;';			entities['251'] = '&ucirc;';			entities['252'] = '&uuml;';			entities['253'] = '&yacute;';			entities['254'] = '&thorn;';			entities['255'] = '&yuml;';		}		if (useQuoteStyle !== 'ENT_NOQUOTES') {			entities['34'] = '&quot;';    }		if (useQuoteStyle === 'ENT_QUOTES') {			entities['39'] = '&#39;';		}		entities['60'] = '&lt;';    entities['62'] = '&gt;';		// ascii decimals to real symbols		for (decimal in entities) {        symbol = String.fromCharCode(decimal);			hash_map[symbol] = entities[decimal];		}		return hash_map;	}	function html_entity_decode (string, quote_style) {		var hash_map = {}, symbol = '', tmp_str = '', entity = '';		tmp_str = string.toString();		if (false === (hash_map = this.get_html_translation_table(			'HTML_ENTITIES', quote_style))) {        return false;		}		// fix &amp; problem		// http://phpjs.org/functions/get_html_translation_table:416#comment_97660    delete(hash_map['&']);		hash_map['&'] = '&amp;';		for (symbol in hash_map) {			entity = hash_map[symbol];        tmp_str = tmp_str.split(entity).join(symbol);		}		tmp_str = tmp_str.split('&#039;').join("'");		return tmp_str;	}	function drawMap(businessName,address,latLong) {//alert('businessName= '+businessName+'\n address= '+address+'\nlatLong= '+latLong);		geocoder = new google.maps.Geocoder();		if(address.indexOf('-')>-1){			address=address.substring(address.indexOf('-')+1);		}		//document.getElementById("googleMapContainer").innerHTML='<BR><BR>Address MalFormatted:<BR>'+address+'<BR>';		if (geocoder) {			geocoder.geocode( { 'address': address}, function(results, status) {				if (status == google.maps.GeocoderStatus.OK) {					map.setCenter(results[0].geometry.location);					var marker = new google.maps.Marker({						title:businessName,						map: map,						position: results[0].geometry.location					});				} else {					//alert("Geocode was not successful for the following reason: " + status);				}			});		}		var myOptions = {			zoom:				14,			keyboardShortcuts:true,			//center:			new google.maps.LatLng(latLong),			mapTypeId:		google.maps.MapTypeId.HYBRID,			mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}		};		var map = new google.maps.Map(getFormElement("googleMapContainer"), myOptions);	}	function vote(reviewID,yourVote){		if(votesCast[reviewID]!=1){			setFormElementValue("formReviewID"	,reviewID);			setFormElementValue("formVote"		,yourVote);			ajaxFunction('vote');			votesCast[reviewID]=1;		}else{			setFormElementInnerHTML('divAdminMessage','Sorry, You have already Voted on this Item');			getFormElement('divAdminMessage').className='warningMessage';						getFormElement('divAdminMessage').style.display='block';			scroll(0,0);//top of page		}	}	function setReviewHelpfullness(ratingID,helpfullnessYes,helpfullnessNo){		if( (helpfullnessYes>=0)&&	(helpfullnessNo>=0)&&		((helpfullnessYes+helpfullnessNo)>0) ){			var helpfullnessPercent=Math.round(helpfullnessYes/(helpfullnessYes+helpfullnessNo)*1000)/10;		}else{			var helpfullnessPercent='N/A';		}		//alert('rating:'+ratingID+'\nYes: '+helpfullnessYes+'\nNo: '+helpfullnessNo+'\n='+helpfullnessPercent+'%');		var toSet=	'<img src="'+ABSOLUTE_PATH+'images/thumb-up.png" />'+helpfullnessYes+' |'+					'<img src="'+ABSOLUTE_PATH+'images/thumb-down.png" />'+helpfullnessNo+'&nbsp;&nbsp;&nbsp;';		if(helpfullnessPercent!='N/A'){			toSet+=helpfullnessPercent+'% <span class="lightBlue">of viewers found this helpful</span>';		}			setFormElementInnerHTML("reviewHelpfullness"+ratingID,toSet);	}	function starChange(formItemName,enteredValue,starMode){		if (starMode=='click'){			setFormElementValue(formItemName,enteredValue);			starSet=true;		}		if( (starSet===false)||(starMode=='click') ){			for(var i=1;i<=5;i++){				if(i<=enteredValue){					getFormElement('starSlot'+i).src=ABSOLUTE_PATH+'images/star-pos.png';//slash added adam				}else{					getFormElement('starSlot'+i).src=ABSOLUTE_PATH+'images/star-neg.png';				}			}		}	}	function popUpComment(reviewID){		//alert('popUpComment:'+reviewID);		allowUserPopUp=false;		if(popupStatuses['divPopUpComment']==0){			$("#backgroundPopup")	.fadeTo("slow",OPACITY_BACKGROUND_SHOWN);			$("#divPopUpComment")	.fadeTo("slow",OPACITY_POPUP_SHOWN);			if(reviewID){				setFormElementValue('formReviewID',reviewID);			}			popupStatuses['divPopUpComment'] = 1;		}	}	function popUpWriteAReview(reviewID){		setFormElementInnerHTML('pWriteAReviewMessage','<span class="adminHeading">Edit review</span>');		if(popupStatuses['divPopUpWriteAReview']==0){			$("#backgroundPopup")		.css({"opacity": "0.7"});			$("#backgroundPopup")		.fadeIn("slow");			$("#divPopUpWriteAReview")	.fadeIn("slow");			if(reviewID){				setFormElementValue('formReviewID',reviewID);			}else{				//alert('ReviewID not provided.  THis will create a NEW REVIEW');				setFormElementValue('formReviewID','');			}			popupStatuses['divPopUpWriteAReview'] = 1;		}	}	function popUpLoadScreen(){		if(popupStatuses['divPopUpLoadScreen']==0){			$("#backgroundPopup").css({"opacity": "0.7"});			$("#backgroundPopup").fadeIn("slow");			$("#divPopUpLoadScreen").fadeIn("slow");			popupStatuses['divPopUpLoadScreen'] = 1;		}	}	function disablePopup(idPassed){		//alert('disablePopup:'+idPassed);		if(popupStatuses[idPassed]==1){//disable popup only if it is enabled			$("#backgroundPopup")	.fadeOut("slow");			$("#"+idPassed)			.fadeOut("slow");			popupStatuses[idPassed] = 0;			if(idPassed=='divScrapeURLs'){				//alert('Aborting Scrape URL Process');				abortScraping=true;			}else if(idPassed=='divPopUpEditCell'){				//alert('There are no outstanding Changes');				editCellInfo['columnID']=-1;				editCellInfo['rowID']	=-1;				editCellInfo['oldValue']=-1;			}		}else{			//alert('Cannot disablePopup: '+idPassed);		}	}	function submitComment(){		ajaxFunction('comment');	}	function showLoadWindow(){		getFormElement('divEditTemplate').style.display='block';	}	function showHideAjaxResultWindow(param){		if(param=='block' || param=='hide'){			//alert(param+getFormElement('ajaxIFrame').style.display);			getFormElement('ajaxIFrame').style.display=param;		}else{			getFormElement('ajaxIFrame').style.display=(getFormElement('ajaxIFrame').style.display=='block'?'none':'block');		}	}	function restrictTo(id,mininum,maximum,revertBackTo){		//alert('restrictTo');		if( ! isInt(getFormElementValue(id)) ){			alert('Field Must be a Integer');			setFormElementValue(id,revertBackTo);		}else if( (parseInt(getFormElementValue(id))>maximum )||(parseInt(getFormElementValue(id))<mininum ) ){			alert('Field Restricted from '+mininum+' to '+maximum);			setFormElementValue(id,revertBackTo);		}else{			//alert('Valid');		}	}	function showReviewPopUp(reviewIDToShow){		if (allReviews[reviewIDToShow]){			popUpComment();			setFormElementValue("formCommentContent",allReviews[reviewIDToShow]['content'] );		}else{			alert('Unable to Load Review:'+reviewIDToShow);		}	}	function showEditReviewPopUp(tableName,reviewIDToShow){		if (allReviews[reviewIDToShow]){			popUpWriteAReview();			//alert(printArray(allReviews[reviewIDToShow]));			setFormElementValue("formReviewID",			reviewIDToShow);			setFormElementValue("formTableName",		tableName);			starChange('formRating'						,allReviews[reviewIDToShow]['rating'],'click');			setFormElementValue("formEntryID"			,allReviews[reviewIDToShow]['entryID']);			setTinyMCEContent("formReviewContent"		,returnQuotesAndNewLine(allReviews[reviewIDToShow]['content']) );			setFormElementValue("formReviewerName"		,allReviews[reviewIDToShow]['reviewerName']);			setFormElementValue("formReviewerLocation"	,allReviews[reviewIDToShow]['reviewerLocation']);			setFormElementValue("formSpamCount"			,allReviews[reviewIDToShow]['spamCount']);		}else{			alert('Unable to Load Review:'+reviewIDToShow);		}	}	//DEBUGGING	function showTemplateStatus(){		alert(	'showTemplateStatus'+"\n"+			'allTemplates='						+"\n"+printArray(allTemplates,false)+"\n"		);	}		function alertLargePieces(hugeString){		var hugeStringLength	=hugeString.length;		var currentlyRead		=0;		var increment			=2100;		while(currentlyRead<hugeStringLength){			alert(  hugeString.substring(currentlyRead,(currentlyRead+increment) )  );			currentlyRead+=increment;		}	}	function printArray(arrayToPrint,assoc){		var arrayTableData='';		if( ! arrayToPrint){			arrayTableData='*NOT SET*';		}else{			if(arrayToPrint.length<=0){				arrayTableData='*EMPTY*';			}				for(eachTableId in arrayToPrint){				if(assoc==true){					for(eachTableAssocIndex in arrayToPrint[eachTableId]){						arrayTableData+=' ['+eachTableId+']['+eachTableAssocIndex+']='+arrayToPrint[eachTableId][eachTableAssocIndex]+"\n";					}				}else{					arrayTableData+=' ['+eachTableId+']='+arrayToPrint[eachTableId]+"\n";				}			}		}		return arrayTableData;	}	function showStatus(){		//alert('showStatus');		alert(	'showStatus'+"\n"+			/*			'numOfColumns='						+numOfColumns+"\n"+			'numOfRows='						+numOfRows+"\n"+			'currentlySelectedTableID='			+currentlySelectedTableID+"\n"+			'currentlySelectedDatabaseID='		+currentlySelectedDatabaseID+"\n"+			'formSelectedDatabaseName='			+getFormElementValue('formSelectedDatabaseName')+"\n"+			'formSelectedTableName='			+getFormElementValue("formSelectedTableName")+"\n"+			*/			//REMEMBER ASSOC=TRUE OR FALSE			//'mappedFields='							+"\n"+printArray(mappedFields,false)+"\n"+			'allRowShown='							+"\n"+printArray(allRowShown,false)+"\n"			//'allDatabases='						+"\n"+printArray(allDatabases,false)+"\n"		);	}		function alertLargePieces(hugeString){		var hugeStringLength=hugeString.length;		var currentlyRead=0;		var increment=2400;		while(currentlyRead<hugeStringLength){			alert(  hugeString.substring(currentlyRead,(currentlyRead+increment) )  );			currentlyRead+=increment;		}	}	//CORE + SIMPLE	function in_array (needle, haystack, argStrict) {		var key = '', strict = !!argStrict; 		for (key in haystack) {			if (haystack[key] === needle) {				return true;			}		}		return false;	}	function removeFileExtension(strName){		var extPosition = strName.indexOf('.'); 		if(extPosition >-1) { 			return strName.substr(0, extPosition );		}		return strName;  	}	function isArray(obj) {		if (obj.constructor.toString().indexOf("Array") == -1){			return false;		}else{			return true;		}	}	function returnQuotesRemoveNewLine(toClean){		toClean=toClean.replace(/###SINGLEQUOTE###/g,"'",toClean);		toClean=toClean.replace(/###DOUBLEQUOTE###/g,"'",toClean);		return	toClean.replace(/\n/g,'',toClean);	}	function escapeQuotesRemoveNewLine(toClean){		toClean=toClean.replace(/'/g,'###SINGLEQUOTE###',toClean);		toClean=toClean.replace(/'/g,'###DOUBLEQUOTE###',toClean);		return	toClean.replace(/\n/g,'',toClean);	}	function isInt(x) {		var y=parseInt(x);		if (isNaN(y)) return false;		return x==y && x.toString()==y.toString();	} 	function ucfirst (str) {		var f = str.charAt(0).toUpperCase();		return f + str.substr(1);	}	function alternateBoolean(bool){		if (bool===true){			return false;		}		return true;	}	function includeJavaScript(jsFile){	  document.write('<scr'+'ipt type="text/javascript" src="'+ jsFile + '"></scr' + 'ipt>'); 	}	//SELECTS	function selectTable(tableId){		//alert('selectTable='+tableId);		if (tableId==null){			tableId=currentlySelectedTableID;		}		for(var eachTableId in masterTables){			if(tableId==eachTableId){				getFormElement('trTable'+eachTableId).setAttribute("class", "databaseSelected");			}else{				getFormElement('trTable'+eachTableId).setAttribute("class", "databaseUnSelected");			}		}		currentlySelectedTableID=tableId;		currentlySelectedDatabaseID=null;		for(var eachDatabaseID in allDatabases){			if(allDatabases[eachDatabaseID]==masterTables[tableId]['fileName']){				currentlySelectedDatabaseID=eachDatabaseID;			}		}		//alert('setting currentlySelectedDatabaseID:'+eachDatabaseID+'\ncurrentlySelectedTableID='+currentlySelectedTableID);		if(masterTables[tableId]==undefined){			alert('Error: Unknown Table ID: '+tableId);		}		setFormElementValue("formSelectedTableName"		,masterTables[tableId]['tableName']	);		setFormElementValue("formSelectedDatabaseName"	,masterTables[tableId]['fileName']	);		//alert('Calling control steps from select Table');		controlSteps(	masterTables[tableId]["currentStep"] );	}	function selectDatabase(){		for(var eachDatabaseID in allDatabases){			//alert(allDatabases[currentlySelectedDatabaseID]+'=='+allDatabases[eachDatabaseID]);			if(allDatabases[currentlySelectedDatabaseID]==allDatabases[eachDatabaseID]){				getFormElement('trDatabase'+eachDatabaseID).setAttribute("class", "databaseSelected");			}else{				getFormElement('trDatabase'+eachDatabaseID).setAttribute("class", "databaseUnSelected");			}		}	}	function selectDatabaseFromName(databaseName){		for(var eachDatabaseID in allDatabases){			if(databaseName==allDatabases[eachDatabaseID]){				currentlySelectedDatabaseID=eachDatabaseID;				return true;			}		}		alert('Error: Could Not Find Database Named "'+databaseName+'"');		return false;	}	function selectTemplate(templateId){		if (templateId==null){			templateId=currentlySelectedTemplateID;		}		//alert(templateId+'\nLength:'+parseInt(allTemplates.length));		for(var eachTemplateId in allTemplates){			if( (templateId==eachTemplateId)&&(templateId<allTemplates.length) ){				getFormElement('trTemplate'+eachTemplateId).setAttribute("class", "databaseSelected");			}else{				getFormElement('trTemplate'+eachTemplateId).setAttribute("class", "databaseUnSelected");			}		}		switch(allTemplates[templateId]['mode']){			case 'root':	setFormElementValue('formSelectedTemplateName',allTemplates[templateId]['value']); break;			case 'entry':	setFormElementValue('formSelectedTemplateName','editable_pageContent/'+allTemplates[templateId]['value']); break;			case 'list':	setFormElementValue('formSelectedTemplateName','editable_listContent/'+allTemplates[templateId]['value']); break;			case 'promo':	setFormElementValue('formSelectedTemplateName','table_specific_promos/'+allTemplates[templateId]['value']); break;			default: alert('Error: Invalid Template Mode: '+allTemplates[templateId]['mode']);		}		currentlySelectedTemplateID=templateId;		//alert('loadingTemplate:\n'+getFormElementValue('formSelectedTemplateName') );		ajaxFunction('loadTemplate',loadScreen=false);		showLoadWindow();	}	function selectCSS(cssId){		if (cssId==null){			templateId=currentlySelectedCSSID;		}		for(var eachCSSId in allCSSs){			if( (cssId==eachCSSId)&&(cssId<allCSSs.length) ){				getFormElement('trCSS'+eachCSSId).setAttribute("class", "databaseSelected");			}else{				getFormElement('trCSS'+eachCSSId).setAttribute("class", "databaseUnSelected");			}		}		if(cssId<allCSSs.length){			setFormElementValue('formSelectedCSSName',allCSSs[cssId] );		}else{			alert('Error: Invalid CSSID');		}		currentlySelectedCSSID=cssId;		//alert('loadingTemplate:\n'+getFormElementValue('formSelectedCSSName'));		ajaxFunction('loadCSS',loadScreen=false);	}	//AJAX	function ajaxFileSubmit(){		document.getElementById("ajaxFileForm").submit();	}	function doneAjaxFileMethod() { //Function will be called when iframe is loaded		var ret = frames['ajaxFileIFrame'].document.getElementsByTagName("body")[0].innerHTML;		if(ret==''){//ignore		}else{			disablePopup('divPopUpLoadScreen');					var data = JSON.parse(ret, function (key, value) { return value;});			if((data.message)&&(data.message.indexOf('Error')<=-1) ){				var mode=(data.messageMode?data.messageMode:'info');				setAdminMessage(mode,data.message);			}else{				setAdminMessage(null);			}		}	}	function ajaxFunction(ajaxMethod,loadScreen){		//alert('ajaxFunction\n'+ajaxMethod);		var postString='';		switch(ajaxMethod){			case 'finalStuff':postString=				'formSelectedDatabaseName='	+getFormElementValue("formSelectedDatabaseName")			+'&'+				'formSelectedTableName='	+getFormElementValue("formSelectedTableName")				;break;			case 'retrievePassword':postString=				'formLoginUsername='		+getFormElementValue("formLoginUsername")					;break;			case 'login':postString=				'formLoginUsername='		+getFormElementValue("formLoginUsername")					+'&'+				'formLoginPassword='		+getFormElementValue("formLoginPassword")					;break;			case 'createTable':postString=				'formNewTableName='			+getFormElementValue("formNewTableName")					;break;			case 'deleteTable':postString=				'formSelectedTableName='	+getFormElementValue("formSelectedTableName")				;break;			case 'deleteDatabase':postString=				'formSelectedDatabaseName='	+getFormElementValue("formSelectedDatabaseName")			;break;			case 'deleteRow':postString=				'formSelectedDatabaseName='	+getFormElementValue("formSelectedDatabaseName")			+'&'+				'formRowIdToDelete='		+getFormElementValue("formRowIdToDelete")					+'&'+				'formSelectedTableName='	+getFormElementValue("formSelectedTableName")				;break;			case 'deleteComments':postString=				'formCommentIdToDelete='	+getFormElementValue("formCommentIdToDelete")				;break;			case 'deleteReviews':postString=				'formReviewIdToDelete='		+getFormElementValue("formRowIdToDelete")					;break;			case 'saveCell':postString=				'formSelectedTableName='	+getFormElementValue("formSelectedTableName")				+'&'+				'formSelectedColumnName='	+databaseColumns[ editCellInfo['columnID'] ]				+'&'+				'formSelectedRowId='		+editCellInfo['rowID']										+'&'+				'formCellNewValue='			+editCellInfo['newValue']									;break;			case 'deleteRows':postString=				'formCurrentPage='			+CURRENT_PAGE												+'&'+				'formRowIdToDelete='		+getFormElementValue("formRowIdToDelete")					+'&'+				'formSelectedTableName='	+getFormElementValue("formSelectedTableName")				;break;			case 'deleteAllUsedFunctions':	postString=''												;break;			case 'logIP':					postString=''												;break;			case 'refresh':					postString=''												;break;			case 'processCommentModeration':				for(var eachCommentIndex in allComments[currentlySelectedReview]){					var commentID=allComments[currentlySelectedReview][eachCommentIndex]['commentID'];					if (MODERATE_COMMENTS_AND_REVIEWS==true){						postString+='approveComment'	+commentID+'='+(getFormElementCheckbox("approveCommentYES"	+commentID)===true?'true':'false')+'&';					}					postString+='deleteComment'	+commentID+'='+(getFormElementCheckbox("deleteComment"		+commentID)===true?'true':'false')+'&';				}				postString+='reviewID='	+currentlySelectedReview+'&';				//alert(postString);				break;			case 'savePromoSettings':				var promoToSet=0;				if(	getFormElementCheckbox('NumPromo1') ){promoToSet+=1;		}				if(	getFormElementCheckbox('NumPromo2') ){promoToSet+=2;		}				var selectedTable=getFormElement('formSelectPromoTable').options[getFormElement('formSelectPromoTable').selectedIndex].value;				postString=				'formNumPromos='			+promoToSet													+'&'+				'formSelectPromoTable='		+selectedTable												;break;			case 'savePostSettings':postString=				'formNumPromos='			+promoToSet													+'&'+				'formDripStartDate='		+getFormElementValue("formDripStartDate")					+'&'+				'formRowsPerDay='			+getFormElementValue("formRowsPerDay")						+'&'+				'formSelectedTableName='	+getFormElementValue("formSelectedTableName")				;break;			case 'associate':postString=				'formSelectedDatabaseName='	+getFormElementValue("formSelectedDatabaseName")			+'&'+				'formSelectedTableName='	+getFormElementValue("formSelectedTableName")				;break;			case 'getFirstRow':postString=				'formSelectedDatabaseName='	+getFormElementValue("formSelectedDatabaseName")			+'&'+				'formSelectedTableName='	+getFormElementValue("formSelectedTableName")				;break;			case 'processModeration':				for  (eachReviewID in allReviews){					if (MODERATE_COMMENTS_AND_REVIEWS==true){						postString+='approveReview'				+eachReviewID+'='+(getFormElementCheckbox("approveReviewYES"+eachReviewID)===true?'true':'false')+'&';					}					postString+='deleteReview'				+eachReviewID+'='+(getFormElementCheckbox("deleteReview"	+eachReviewID)===true?'true':'false')+'&';				}				//alert(postString);				break;			case 'mapDatabase':				for(var i=0;i<numOfColumns;i++){					postString+=						'formSelectColumnType'		+i+'='+getFormElementValue("formSelectColumnType"		+i)+'&'+						'formColumnName'			+i+'='+getFormElementValue("formColumnName"				+i)+'&'+						'formColumnCustomName'		+i+'='+getFormElementValue("formColumnCustomName"		+i)+'&'+						'formColumnCategoryCheckBox'+i+'='+(getFormElementCheckbox("formColumnCategoryCheckBox"	+i)?'YES':'NO')+'&'+						'formColumnListCheckBox'	+i+'='+(getFormElementCheckbox("formColumnListCheckBox"		+i)?'YES':'NO')+'&';				}				postString+=				'formSelectedDatabaseName='	+getFormElementValue("formSelectedDatabaseName")			+'&'+				'formSelectedTableName='	+getFormElementValue("formSelectedTableName")				+'&'+				'formDripStartDate='		+getFormElementValue("formDripStartDate")					+'&'+				'formRowsPerDay='			+getFormElementValue("formRowsPerDay")						+'&';				break;			case 'importDatabase':postString=				'formSelectedDatabaseName='	+getFormElementValue("formSelectedDatabaseName")			+'&'+				'formSelectedTableName='	+getFormElementValue("formSelectedTableName")				+'&';				if(getFormElementValue('formStartAt') ){					postString+='formStartAt='+getFormElementValue("formStartAt");				}				break;			case 'deleteAdminUser':postString=				'formAdminUserToDelete='	+getFormElementValue("formAdminUserToDelete")				;break;			case 'viewDatabase':postString=				'formSelectedTableName='	+getFormElementValue("formSelectedTableName")				;break;			case 'vote':postString=				'formReviewID='				+getFormElementValue("formReviewID")						+'&'+				'formVote='					+getFormElementValue("formVote")							;break;			case 'comment':postString=				'formReviewID='				+getFormElementValue("formReviewID")						+'&'+				'formTableName='			+getFormElementValue("formTableName")						+'&'+				'formSecurityID='			+getFormElementValue("formSecurityID")						+'&'+				'formSecurityAnswer='		+getFormElementValue("formCommentSecurityAnswer")			+'&'+				'formCommentContent='		+getFormElementValue("formCommentContent")					;				//alert(postString);				break;			case 'submitReview':				if(getFormElement("formReviewID")&&getFormElementValue("formReviewID")!='' ){					postString+='formReviewID='			+getFormElementValue("formReviewID")							+'&'+								'formSpamCount='		+getFormElementValue("formSpamCount")							+'&';				}				//alert('submitReview'+postString)				if(getFormElement("formSecurityID"			,NOERROR=true)&&getFormElementValue("formSecurityID")!='' ){					postString+='formSecurityID='			+getFormElementValue("formSecurityID")				+'&';				}				if(getFormElement("formReviewSecurityAnswer",NOERROR=true)&&getFormElementValue("formReviewSecurityAnswer")!='' ){					postString+='formSecurityAnswer='	+getFormElementValue("formReviewSecurityAnswer")			+'&';				}				//alert(getFormElementValue("formRating"));				if( (getFormElementValue("formRating")=='')||(getFormElementValue("formRating")==0) ){					//alert('aa'+warnedReviewIsZero);					if(warnedReviewIsZero!==true){					//alert('warning!');						setFormElementInnerHTML('pWriteAReviewMessage','Are you Sure you wish you Submit a Rating Score of Zero?');						getFormElement('pWriteAReviewMessage').className='warningMessage';						getFormElement('pWriteAReviewMessage').style.display='block';							warnedReviewIsZero=true;			//	alert('warning!');							return false;//break it all					}				}				var cleanedContent=getTinyMCEContent("formReviewContent");				cleanedContent=cleanedContent.replace(/&/g,'###AMP###');				postString+=					'formRating='				+getFormElementValue("formRating")						+'&'+					'formTableName='			+getFormElementValue("formTableName")					+'&'+					'formEntryID='				+getFormElementValue("formEntryID")						+'&'+					'formReviewContent='		+cleanedContent											+'&'+										'formReviewerName='			+getFormElementValue("formReviewerName")				+'&'+					'formReviewerLocation='		+getFormElementValue("formReviewerLocation")			+'&';				//alert('Trying TINYMCE in IE:'+cleanedContent );				//alert('DONE');				//alert(postString);				break;			case 'renameTable':postString=				'formOldTableName='			+getFormElementValue("formOldTableName")					+'&'+				'formNewTableName='			+getFormElementValue("formNewTableName")					;break;			case 'selectDatabase':postString=				'formSelectedTableName='	+getFormElementValue("formSelectedTableName")				;break;			case 'saveCSS':var cssContents=editAreaLoader.getValue("formCSSContents");				postString=				'formCSSContents='		+cssContents.replace(/&/g,'###AMP###')							+'&'+				'formSelectedCSSName='	+getFormElementValue("formSelectedCSSName")						;				//alert(postString);				break;			case 'doesDatabaseHaveDuplicates':postString=				'formSelectedTableName='	+getFormElementValue("formSelectedTableName")				;break;			case 'saveTemplate':var templateContents=editAreaLoader.getValue("formTemplateContents");				postString=				//'formTemplateContents='		+getFormElementValue("formTemplateContents")	+'&'+				'formTemplateContents='		+templateContents.replace(/&/g,'###AMP###')			+'&'+				'formSelectedTemplateName='	+getFormElementValue("formSelectedTemplateName")			;				//alert(postString);				break;			case 'loadCSS':postString='formSelectedCSSName='	+allCSSs[currentlySelectedCSSID]		;break;			case 'loadTemplate':postString+=				'initLoad='	+initLoad																+'&'+				'formSelectedTemplateName='	+getFormElementValue('formSelectedTemplateName');				//alert(postString);				break;			case 'savePopUpPreferences':				for(var iConfig in allPopUpSettingsToSet){					//alert(allPopUpSettingsToSet[iConfig]['type']);					if(allPopUpSettingsToSet[iConfig]==null){//ignore					}else if(allPopUpSettingsToSet[iConfig]['type'] =='checkbox'){						postString+=iConfig+'='+getFormElementCheckbox(iConfig)+'&';					}else{						postString+=iConfig+'='+getFormElementValue(iConfig)+'&';					}				}				//alert(postString);				break;						case 'saveConfigPreferences':				//alert('saveConfigPreferences');				//alertLargePieces(printArray(allPreferencesToSet));				for(var iConfig in allPreferencesToSet){					//alert(allPreferencesToSet[iConfig]['type']);					if(allPreferencesToSet[iConfig]['type'] =='checkbox'){						postString+=iConfig+'='+getFormElementCheckbox(iConfig)+'&';					}else{						postString+=iConfig+'='+getFormElementValue(iConfig)+'&';					}				}				if(getFormElement("formNewAdminUsername",noError=true)&&getFormElement("formNewAdminPassword",noError=true)){					postString+=						'formNewAdminUsername='	+getFormElementValue("formNewAdminUsername")			+'&'+						'formNewAdminPassword='	+getFormElementValue("formNewAdminPassword")			;				}				//alert(postString);				break;			case 'scrapeURL':postString=				'formSelectedTableName='					+getFormElementValue("formSelectedTableName")						+'&'+				'formRowIdToStartScrapeAt='					+getFormElementValue("formRowIdToStartScrapeAt")					;				//alert(postString);				break;				case 'deletePage':postString=				'formDeletePageId='+getFormElementValue("formDeletePageId")	;break;				case 'savePage':postString=				'formCheckShowInHeader='+(getFormElementCheckbox("formCheckShowInHeader")?'on':'')		+'&'+				'formCheckShowInFooter='+(getFormElementCheckbox("formCheckShowInFooter")?'on':'')		+'&'+				'formCheckShowInMenu='	+(getFormElementCheckbox("formCheckShowInMenu")?'on':'')		+'&'+				'formPageDescription='	+getTinyMCEContent('formPageDescription')						+'&'+				'formPageTitle='		+getFormElementValue("formPageTitle")							+'&'+				'formPageId='			+getFormElementValue("formPageId")								;				//alert(postString);				break;			default: alert('Error: Unknown Ajax Method: '+ajaxMethod); break;		}		postString+='&ajaxMethod='+ajaxMethod//alert('ajaxFunction\n'+ajaxMethod+'\n'+postString);		var xmlhttp;		if (window.XMLHttpRequest) {			xmlhttp=new XMLHttpRequest();// code IE7+, Firefox, Chrome, Opera, Safari		}else if (window.ActiveXObject){		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); // IE6, IE5		}else{alert("Your browser does not support XMLHTTP!");}		xmlhttp.onreadystatechange=function(){			if( (xmlhttp.readyState>=1)&&(xmlhttp.readyState<=3) ){				if(loadScreen===true){					popUpLoadScreen();				}			}			if(xmlhttp.readyState==4){				//disablePopup('divPopUpLoadScreen');				var responseText=xmlhttp.responseText;				if( responseText.indexOf('parse error')!==-1 ){					alert('Parse Error: '+responseText);				}else{									frames['ajaxIFrame'].document.getElementsByTagName("body")[0].innerHTML=responseText;					doneAjaxMethod();				}			}		}			//alert('xmlhttp opening: '+ABSOLUTE_PATH+"includes/ajaxProcess.php");		xmlhttp.open("POST",ABSOLUTE_PATH+"includes/ajaxProcess.php",true);		//alert('Hooray');		xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");		xmlhttp.send(postString);	}	function doneAjaxMethod() { //Function will be called when iframe is loaded		var ret = frames['ajaxIFrame'].document.getElementsByTagName("body")[0].innerHTML;//alert('doneAjaxMethod:\n');		if(ret==''){//upload done probably, refresh			ajaxFunction('refresh',loadScreen=false);		}else if(  (ret.indexOf('SQL Error:')!==-1)||(ret.indexOf('Fatal error:')!==-1)  ){			alert('SQL Error: There is a Problem with your Imported Data:\n\n'+ret);			disablePopup('divPopUpLoadScreen');		}else{			disablePopup('divPopUpLoadScreen');//alert('Trying to Evaluate Javascript:\n'+ret);			var data = JSON.parse(ret, function (key, value) { return value;});			//OLD WAY			//var data = eval("("+ret+")"); //Parse JSON // Read the below explanations before passing judgment on me//alert('DONE Evaluating Javascript:\n'+data);			if(ret.indexOf('<div class="errorMessage">')!==-1){				getFormElement("ajaxIFrame").style.display='block';			}else if(data.success) { //This part happens when the image gets uploaded.				//alert('SUCCESS');				if(data.clearReviewId===true){				setFormElementValue('formReviewID',''); }				if(data.topOfPage===true){					scroll(0,0); }				if(data.currentlySelectedTableID){					currentlySelectedTableID=data.currentlySelectedTableID;					//alert('set currentlySelectedTableID:'+currentlySelectedTableID);				}				if((data.message)&&(data.message.indexOf('Error')<=-1) ){					//alert('Good Message'+data.message);					//showHideAjaxResultWindow('block');					var mode=(data.messageMode?data.messageMode:'info');					setAdminMessage(mode,data.message);				}else{					setAdminMessage(null);				}				if(data.rowIdToStartScrapeAt){					setFormElementValue("formRowIdToStartScrapeAt",	data.rowIdToStartScrapeAt);					setFormElementValue("formRowURLLastSearched",	data.urlLastSearched);					if(data.rowIdToStartScrapeAt===-1){//DONE						//alert('DONE!');						setAdminMessage('info',data.message);						alert('Scrape URL Process Concluded Succesfully');						disablePopup('divScrapeURLs');					}else{//keep going						//alert('keep going:'+data.rowIdToStartScrapeAt);						ajaxFunction('scrapeURL',loadScreen=false);					}				}				if(data.refresh){					//alert('refreshing');					getFormElement('ajaxForm').reset();					location.href=removeAnchorTag(location.href);				}				if(data.redirectTo){					location.href=data.redirectTo;				}				if(data.allTemplates){					allTemplates= new Array();//to reset it ;)					for(var eachTemplateId in data.allTemplates){						if(allTemplates[eachTableId]==null){							allTemplates[eachTableId]=[];						}						//alert('data.allTemplates['+eachTableId+']');						//alert(data.allTemplates[eachTableId]['numOfRows']);						allTemplates[eachTemplateId]		= data.allTemplates[eachTemplateId];					}					setFormElementInnerHTML("divSelectTemplate",getSelectTemplatesContents() );				}				if(data.templateContents&&data.templateName){					if(data.templateContents==null){						alert('There have been illegal Characters in this Template "'+data.templateName+'".  Please Attempt To Fix it by Hand');					}					var tempp=html_entity_decode(data.templateContents);					tempp=tempp.replace(/###DOUBLEQUOTE###/g,'"');					tempp=tempp.replace(/###TAB###/g,'\t');					tempp=tempp.replace(/###AMP###/g,'&');					//setFormElementValue("formTemplateContents",tempp);					//var new_file= {id: data.templateName, text: tempp, syntax: 'html'};					//if(data.initLoad=="true"){alert('Loading your Template:'+data.templateName);}					//setTimeout("alert('a');",1490);					//editAreaLoader.openFile('formTemplateContents', new_file);					editAreaLoader.setValue("formTemplateContents", tempp);					editAreaLoader.setSelectionRange("formTemplateContents", 0, 0);					if(data.allTableTemplatesVariables){						//alert('a');						if(data.allTableTemplatesVariables.length!=0){							var variablesContents='<div class="TemplateVariablesContent"><h1>Insert the Following Variables into your Template:</h1>';							for(var eachVariableID in data.allTableTemplatesVariables){								variablesContents+='<a onClick="insertVariableIntoTemplate(\''+eachVariableID+'\')">['+eachVariableID+']</a> &nbsp; ';							}							variablesContents+='<a onClick="insertVariableIntoTemplate(\'StateName\')">[StateName]</a> &nbsp; ';							variablesContents+='</div>';						}else{							variablesContents='<div class="errorMessage">Table not Successfully Imported Yet</div>';						}						setFormElementInnerHTML("divTemplateVariables",variablesContents+'');											}else{						setFormElementInnerHTML("divTemplateVariables",'');					}				}				if(data.cssContents&&data.CSSName){//CSS					if(data.cssContents==null){						alert('There have been illegal Characters in this CSS "'+data.CSSName+'".  Please Attempt To Fix it by Hand');					}					var tempp=html_entity_decode(data.cssContents);					tempp=tempp.replace(/###DOUBLEQUOTE###/g,'"');					tempp=tempp.replace(/###TAB###/g,'\t');					tempp=tempp.replace(/###AMP###/g,'&');					editAreaLoader.setValue("formCSSContents", tempp);					editAreaLoader.setSelectionRange("formCSSContents", 0, 0);				}							if(data.commentSuccess==true){//--commenting & Review					disablePopup('divPopUpComment');					setFormElementValue("formCommentContent",'');				}				if(data.reviewSuccess==true){					disablePopup('divPopUpWriteAReview');					setFormElementValue("formRating",'');					setFormElementValue("formReviewContent",'');					setFormElementValue("formReviewerName",'');					setFormElementValue("formReviewerLocation",'');						}				if(data.reviewID&&data.reviewScore){					setReviewHelpfullness(data.reviewID,parseInt(data.reviewScore['helpfullnessYes']),parseInt(data.reviewScore['helpfullnessNo']))				}				if(data.promoTable){					if(data.promoNum){						masterTablesPromoNum[data.promoTable]=data.promoNum;					}					//alert('promoTable');					var selectTableCount=getFormElement("formSelectPromoTable").options.length;					//alert(selectTableCount);					for( var i=1;i<selectTableCount;i++){// 1 because we forget the select one						//alert(i);						//alert( getFormElement("formSelectPromoTable").options[i].value);						if(getFormElement("formSelectPromoTable").options[i].value==data.promoTable){							//setAdminMessage('info',data.message);							//alert('found');							getFormElement("formSelectPromoTable").options[i].selected=true;						}					}				}				if(data.allTables){					disablePopup('divPopUpLoadScreen');					//alert('allTables found');					masterTables= new Array();//to reset it ;)					for(var eachTableId in data.allTables){						if(masterTables[eachTableId]==null){							masterTables[eachTableId]=[];						}						//alert('data.allTables['+eachTableId+']');						//alert(data.allTables[eachTableId]['numOfRows']);						masterTables[eachTableId]['fileName']		= data.allTables[eachTableId]['fileName'];						masterTables[eachTableId]['tableName']		= data.allTables[eachTableId]['tableName'];						masterTables[eachTableId]['readyToImport']	= data.allTables[eachTableId]['readyToImport'];						masterTables[eachTableId]['hasDuplicates']	= data.allTables[eachTableId]['hasDuplicates'];						masterTables[eachTableId]['importComplete']	= data.allTables[eachTableId]['importComplete'];						masterTables[eachTableId]['currentStep']	= data.allTables[eachTableId]['currentStep'];						masterTables[eachTableId]['numOfRows']		= data.allTables[eachTableId]['numOfRows'];					}					//alert('Calling control steps from Ajasx done'+currentlySelectedTableID);					if(getFormElement("divSelectTable",noError=true) ){//only for build page, not data Page						setFormElementInnerHTML("divSelectTable",getSelectTableContents() );					}					if(data.newTable){						currentlySelectedTableID=null;						for(eachTableID in masterTables){							if( masterTables[eachTableID]['tableName']==data.newTable ){								currentlySelectedTableID=eachTableID;							}						}						if(currentlySelectedTableID==null){							alert('Unable to Locate Recently Created Table: '+data.newTable);						}						//alert('currentlySelectedTableID:'+currentlySelectedTableID );						//alert('Your Table "'+data.newTable+'"has been Created');						setFormElementValue('formSelectedTableName',data.newTable)						controlSteps(0);					}else if(  (currentlySelectedTableID)&&(data.page!='edit_data')  ){						//alert('Controling Steps');						setFormElementValue('formSelectedTableName',masterTables[currentlySelectedTableID]['tableName'])						controlSteps(masterTables[currentlySelectedTableID]['currentStep']);					}				}				if(data.newStartAt){					setAdminMessage('info',data.message);					//alert('Conituning'+data.newStartAt);					if(data.newStartAt=='finalStuff'){						setFormElementValue('formStartAt',data.newStartAt);						setFormElementInnerHTML('divLoadingMessage','Finishing Up');						ajaxFunction('finalStuff',loadScreen=true);					}else{						setFormElementValue('formStartAt',data.newStartAt);						setFormElementInnerHTML('divLoadingMessage','Row:'+data.newStartAt);						ajaxFunction('importDatabase',loadScreen=true);					}				}				if(data.allDatabases){					if(isArray(data.allDatabases) ){						allDatabases= new Array();//to reset it ;)						for(var eachDatabaseId in data.allDatabases){							allDatabases[eachDatabaseId]= data.allDatabases[eachDatabaseId];						}						setFormElementInnerHTML("divSelectDatabase", getSelectDatabaseContents() );					}else{						alert(data.allDatabases);					}				}				if(data.firstRow){					disablePopup('divPopUpLoadScreen');		//alert(data.firstRow);					numOfColumns	=data.firstRowColumnCount;					setMapDatabaseContents(data.firstRow);					//alert('setting numOfColumns to:'+data.firstRowColumnCount);					//alert('setting numOfRows to:'	+data.rowCount);					setFormElementValue("formDripStartDate",data.startDate);					setFormElementValue("formRowsPerDay",	data.rowsPerDay);					//alert(data.numPromos);					numOfRows		=data.rowCount;					calcDripMath();		//alert('set');									}				if(data.databaseColumns&&data.databaseRows){					disablePopup('divPopUpLoadScreen');					//alert('setting databaseRows FOUND!!!!');					//alert('set databaseRows FOUND!!!!'+hasDuplicates);					data.message=data.message.replace(/\n/g,'<BR>');					if(data.duplicateCount){						setAdminMessage('info',data.message+'Rows: '+data.duplicateCount);					}					var hasDuplicates=false;					if(data.hasDuplicates===true){						hasDuplicates=true;					}					setDatabaseRows(data.databaseColumns,data.databaseRows,hasDuplicates);				}				if(data.databaseName)	{					selectDatabaseFromName(data.databaseName)	;				}				if(data.checkIfHasDuplicates===false){					setFormElementInnerHTML("divDatabaseRows",'No Duplicates in this Table');				}				if(data.checkIfHasDuplicates===true){					setFormElementInnerHTML("divDatabaseRows",'Loading your Duplicates');					ajaxFunction('viewDatabase');					//setDatabaseRows(data.databaseColumns,data.databaseRows,hasDuplicates);				}			}else{ //Upload failed - show user the reason.				//alert('Upload failed'+data);				if(data.securityImage){						var newImage=ABSOLUTE_PATH+'images/bg_icon_warning.gif';					var newImage=ABSOLUTE_PATH+'includes/securityCheck.php?refid='+data.securityImage;					//alert('NEW SECUIRTY IMAGE'+data.securityImage+'\n'+newImage);										getFormElement('formReviewSecurityImage').src= newImage;					getFormElement('formCommentSecurityImage').src= newImage;					setFormElementValue('formSecurityID',data.securityImage)					//alert('DONE SECUIRTY IMAGE'+data.securityImage);				}				if(data.reviewError){					//alert('REVIEW Error\nType:'+data.reviewError+'\nMessage:'+"\n"+data.message);					setFormElementInnerHTML('pWriteAReviewMessage',data.message);					getFormElement('pWriteAReviewMessage').className=data.reviewError+'Message';								getFormElement('pWriteAReviewMessage').style.display='block';						}else if(data.commentError){					//alert('COMMENT Error\nType:'+data.commentError+'\nMessage:'+"\n"+data.message);					setFormElementInnerHTML('pCommentOnReviewMessage',data.message);					getFormElement('pCommentOnReviewMessage').className=data.commentError+'Message';								getFormElement('pCommentOnReviewMessage').style.display='block';						}else{					showHideAjaxResultWindow('block');					data.message=data.message.replace(/\\n/g,'\n');					//alert('REGULAR Error Message:'+"\n"+data.message);					data.message=data.message.replace(/\n/g,'<BR>');					setAdminMessage('error',data.message);				}			}		}	}	function removeAnchorTag(toReturn){		//alert('removeAnchorTag\n'+toReturn);		if(toReturn.indexOf('#')>-1){			var toReturn=toReturn.substring(0,toReturn.indexOf('#'));		}		//alert('removeAnchorTag IS NOW\n'+toReturn);		return toReturn;	}	function setAdminMessage(type,message){		//alert('Setting Admin '+type+' Message\n\n'+message);		var validTypes=new Array('confirm', 'error','warning', 'info');		if( ! in_array(type,validTypes) ){type='info';}		getFormElement("divAdminMessage").className=type+'Message';		setFormElementInnerHTML("divAdminMessage",message);		showItem("divAdminMessage");	}	//SAFE SETTTERS, SHOWERS, ETC	function getFormElement(id,noError){		if( (! document.getElementById(id))&&(noError!==true) ){			alert('getFormElement\nForm Element: "'+id+ '" not Found');		}else{			return document.getElementById(id);		}		return false;	}	function getTinyMCEContent(id,noError){		if( (! document.getElementById(id))&&(noError!==true) ){			alert('getTinyMCEContent\nForm Element: "'+id+ '" not Found');			return false;		}else if( (! tinyMCE)||(tinyMCE==undefined) ){			alert('getTinyMCEContent\ntinyMCE Not Found');			return false;		}else if( ! tinyMCE.get(id)){			alert('getTinyMCEContent\ntinyMCE Could not find your Element "'+id+'" Found');			return false;		}else{			return tinyMCE.get(id).getContent();		}	}	function getFormElementValue(id){		if(! document.getElementById(id)){			alert('getFormElementValue\nForm Element: "'+id+ '" Not Found');		}else{			return document.getElementById(id).value		}	}	function getFormElementInnerHTML(id){		if(! document.getElementById(id)){			alert('getFormElementInnerHTML\nForm Element: "'+id+ '" Not Found');		}else{			return document.getElementById(id).innerHTML		}	}	function getFormElementCheckbox(id){		if(! document.getElementById(id)){			alert('getFormElementCheckbox\nForm Element: "'+id+ '" Not Found');		}else{			//alert('setting:\n'+id+':'+typeof(checkTrueOrFalse)+':'+checkTrueOrFalse)			return document.getElementById(id).checked;		}	}	//SET	function setFormElementCheckbox(id,checkTrueOrFalse){		if(! document.getElementById(id)){			alert('setFormElementCheckbox\nForm Element: "'+id+ '" Not Found');		}else if(typeof(checkTrueOrFalse)!=='boolean'){			alert('Cannot Set Form Element: "'+id+ '".  Invalid Boolean Value:'+checkTrueOrFalse);		}else{			document.getElementById(id).checked=checkTrueOrFalse;		}	}	function setFormElementInnerHTML(id,valueToSet){		if(! document.getElementById(id)){			alert('setFormElementInnerHTML\nForm Element: "'+id+ '" Not Found');		}else{			document.getElementById(id).innerHTML=valueToSet;		}	}	function setTinyMCEContent(id,valueToSet,noError){		if( (! document.getElementById(id))&&(noError!==true) ){			alert('setTinyMCEContent\nForm Element: "'+id+ '" not Found');			return false;		}else if( (! tinyMCE)||(tinyMCE==undefined)||( ! tinyMCE.get(id)) ){			alert('setTinyMCEContent\nForm Element: "'+id+ '" Not Found');			return false;		}else{			tinyMCE.get(id).setContent(valueToSet);		}	}	function setFormElementValue(id,valueToSet){		if(! document.getElementById(id)){			alert('setFormElementValue\nForm Element: "'+id+ '" Not Found');		}else{			document.getElementById(id).value=valueToSet;		}	}	function toggleShowHideComments(reviewID){		allowUserPopUp=false;		if( getFormElement('divCommentsForReview'+reviewID).style.display=='none' ){			getFormElement('divCommentsForReview'+reviewID).style.display='block';			getFormElement('divMinMaxForReview'+reviewID).className ='max';			}else{			getFormElement('divCommentsForReview'+reviewID).style.display='none';			getFormElement('divMinMaxForReview'+reviewID).className ='min';		}	}	function toggleShowHideItem(id){		if(! document.getElementById(id) ){			alert('toggleShowHideItem\nForm Element: "'+id+ '" Not Found');		}else if( document.getElementById(id).style.display=='none' ){			document.getElementById(id)		.style.display='block';		}else{			document.getElementById(id)		.style.display='none';		}	}	function hideItem(id){		if(! document.getElementById(id) ){			alert('hideItem\nForm Element: "'+id+ '" Not Found');		}else{			document.getElementById(id)		.style.display='none';		}	}	function showItem(id){		if(! document.getElementById(id) ){			alert('showItem\nForm Element: "'+id+ '" Not Found');		}else{			document.getElementById(id)		.style.display='block';		}	}	//FOR HOVERBARS	var offsetxpoint=-60; //Customize x offset of tooltip	var offsetypoint= 20; //Customize y offset of tooltip	var ie=document.all;	var ns6=document.getElementById && !document.all;	var enabletip=false;	function ietruebody(){		return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;	}	function hoverToolTip(thetext, thewidth){		if (ns6||ie){			if (typeof thewidth!="undefined"){				//alert(tipobj);				if( ! tipobj){					alert('tipobj is working');				}else{					tipobj.style.width=thewidth+"px";				}			}			tipobj.innerHTML=thetext;			enabletip=true;			return false;		}	}	function positiontip(e){		if (enabletip){			var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;			var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;			//Find out how close the mouse is to the corner of the window			var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20;			var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20;			var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000;			//if the horizontal distance isn't enough to accomodate the width of the context menu			if (rightedge<tipobj.offsetWidth){			//move the horizontal position of the menu to the left by it's width				tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px";			}else if (curX<leftedge){				tipobj.style.left="5px";			}else{			//position the horizontal position of the menu where the mouse is positioned				tipobj.style.left=curX+offsetxpoint+"px";			}//same concept with the vertical position			if (bottomedge<tipobj.offsetHeight){				tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px";			}else{				tipobj.style.top=curY+offsetypoint+"px";			}			tipobj.style.visibility="visible";		}	}	function hideToolTip(){		if (ns6||ie){			enabletip=false;			tipobj.style.visibility="hidden";			tipobj.style.left="-1000px";			tipobj.style.backgroundColor='';			tipobj.style.width='';		}	}	document.onmousemove=positiontip;	//NOT USED	function uploadDatabaseFile(){		alert('You have called a function previously thought to be Unused, please alert the site administrators to this problem');}	function prepareDatabase(){			alert('You have called a function previously thought to be Unused, please alert the site administrators to this problem');}	function importClick(){				alert('You have called a function previously thought to be Unused, please alert the site administrators to this problem');}	function followShortURL(shortURL){	alert('You have called a function previously thought to be Unused, please alert the site administrators to this problem');}/*	function uploadDatabaseFile(){		var xmlhttp;		if (window.XMLHttpRequest) {			xmlhttp=new XMLHttpRequest();// code IE7+, Firefox, Chrome, Opera, Safari		}else if (window.ActiveXObject){		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); // IE6, IE5		}else{alert("Your browser does not support XMLHTTP!");}				xmlhttp.open("POST",ABSOLUTE_PATH+"includes/ajaxProcess.php",true);		var boundary = "--------XX" + Math.random();		xmlhttp.setRequestHeader("Content-type", "multipart/form-data; boundary=" + boundary);		alert(getFormElement("uploadedFile").value);		xmlhttp.setRequestHeader("Content-length", 222);		xmlhttp.onload = function(event) { alert(event.target.responseText); }		var prefix = "--" + boundary + "\n" +			"Content-Disposition: form-data; name=\"aaaa\"; filename=\"eeeeee\"\n" +			"Content-type: text/plain\n\n";		alert('444');		alert(prefix);		var stream = IO.newInputStream(prefix, "multi");		alert('777');		stream.appendStream(IO.newInputStream(document.getElement('uploadedFile'), ""));		alert('6666');		stream.appendStream(IO.newInputStream("\n--" + boundary + "\n", ""));		alert('5555555555');		xmlhttp.send(stream);	}	function prepareDatabase(){		//alert('prepareDatabase\n'+			'currentlySelectedDatabaseID='+currentlySelectedDatabaseID+'\n'+			'allDatabases['+currentlySelectedDatabaseID+']='+allDatabases[currentlySelectedDatabaseID]+'\n\n'+			'currentlySelectedTableID='+currentlySelectedTableID+'\n'+			'masterTables['+currentlySelectedTableID+']='+masterTables[currentlySelectedTableID]["tableName"]		//);		if(currentlySelectedDatabaseID==null){			alert('The Database File you Selected: "'+masterTables[currentlySelectedTableID]["fileName"]+'"\nNo Longer Exists!');			setFormElementValue('formSelectedDatabaseName','');		}else{			setFormElementValue("formSelectedDatabaseName",allDatabases[currentlySelectedDatabaseID] );			setFormElementValue("formSelectedTableName",masterTables[currentlySelectedTableID]['tableName'] );			ajaxFunction('getFirstRow',loadScreen=true)		}	}	function importClick(){		//NOT USED ADAM JUNE 11		if(confirm('Are you Sure you wish to Import this Database Again?'+"\n"+'This will re-insert any duplicate rows you have previously removed') ){			//selectTable(tableId);			ajaxFunction('importDatabase',loadScreen=true);		}	}	function followShortURL(shortURL){		ajaxFunction('selectDatabase',loadScreen=false);		//might have a problem here ADAM		location.href=shortURL;	}*/	//alert('script loaded');