




// client-side components
function debugObject(obj) {
	var temp = "";
	for(x in obj) {
		temp += x + ": " + obj[x] + "\n";
	}
	alert(temp);
}

function Component() {
}
Component.Debugger=function(obj){
	this.content=obj;
}
function trimString(item){
	return item.substring(0,item.length-2);
}

Component.PlaceScore = function(score,type,operation){

	var body='';
		body += '<div class="level_two_main_columnTwo_right_right">';
		
		
		if(type=='unclaimed'){
			body += '<p class="level_two_main_columnTwo_right_right_para_unclaimed">';
			body += score;
			body += '</p>';	
			body += '<img src="/plc/static/img/unclaimed_placeScore_large.png" border="0" height="65" width="61"/>';
			
		}else if(type=='claimed'){
			body += '<p class="level_two_main_columnTwo_right_right_para_claimed">';
			body += score;
			body += '</p>';
			body += '<img src="/plc/static/img/claimed_placeScore_large.png" border="0" height="65" width="61"/>';
		}
		body += '</div>';
		
		
	if(operation!=null)return Component.encaseLink(body,operation);
	return body;
}
Component.GetLetterEquivalent =function(num,operation){
var body ='';
	switch(num){
		case 0:
			body += 'A';
			break;
		case 1:
			body += 'B';
			break;
		case 2:
			body += 'C';
			break;
		case 3:
			body += 'D';
			break;
		case 4:
			body += 'E';
			break;
		case 5:
			body += 'F';
			break;
		case 6:
			body += 'G';
			break;
		case 7:
			body += 'H';
			break;
		case 8:
			body += 'I';
			break;
		case 9:
			body += 'J';
			break;
		case 10:
			body += 'K';
			break;
		case 11:
			body += 'L';
			break;
			
	}
	if(operation!=null)return Component.encaseLink(body,operation);
	return body;
} 
Component.GetClaimedStatus = function(value,operation){
	var body = '';
		
		if(value){
			body += "Claimed";
		}else{
			body += "Unclaimed";
		}
		
	if(operation!=null)return Component.encaseLink(body,operation);
	return body;
		
		
}
Component.GetCategory = function(categories,operation){
		
	var body = '';
	if (categories && categories.length > 0) {	
		$(categories).each(function(item){
			body += '<p class="level_two_main_columnTwo_left_two_cell_norm_list">' + item.name + '</p>';
		});
	} else {
		body += 'None';
	}
		
	//if(operation!=null)return Component.encaseLink(body,operation);
	return body;
}
Component.GetTags = function(tags,operation){
	var body = '';
		if(tags.length<1){
			body += 'None';
			if(operation!=null)return Component.encaseLink(body,operation);
			return body;
		}	
		for(var i=0;i<tags.length;i++){
			body += tags[i] + ', ';
			
		}
		body = trimString(body);
	if(operation!=null)return Component.encaseLink(body,operation);
	return body;
}
Component.GetAddress = function(address,target,operation){
	var body = '';
			body += '<div class="cell_item">';
			if(address.address1 != null){
				body += address.address1;
				body += '<br/>';
				}
			if(address.region1!= null){
				body += address.region1;
				body += ', ';
				}
			if(address.region2!=null){
				body += address.region2;
				body += ' ';
				}
			if(address.postalCode!=null){
				body += address.postalCode;
			}
			body += '</div>';
		if(target!=null){
			body += '<div class="cell_item" id="';
			body += target;
			body += '_anchor">';
				
			body += '</div>';
		}
	
	return body;
}
Component.GetAddress1 = function(address,operation){
	var body = '';
	if(address.address1 != null){
		body += address.address1;
		body += '<br/>';
	}
	if(operation!=null)return Component.encaseLink(body,operation);
	return body;
}

Component.GetGeoCordnates = function(geocode,operation){
	var body = '';
	if(geocode.latitude!=null){
		body += 'Lat:&nbsp;';
		body += Component.AjaxWrappers.Truncate(geocode.latitude,6);
		body += '&nbsp;|&nbsp;'
		}
	if(geocode.latitude!=null)
		body += 'Long:&nbsp;';
		body += Component.AjaxWrappers.Truncate(geocode.longitude,6);

	
	return body;
}
Component.getLRO = function(location){
	
	if(location.id)
		return location.id;
	return Component.NotFound;
}
Component.Claim = {};

Component.Claim.ShowClaimedStatus=function(claimedStatus){
	var body = '';
		body += '<p> Claimed Status: ';
		body += claimedStatus;
		body += '</p>';
		return body;
}

Component.GetClaimButton = function(value,operation){
	var body ='';
		if(value=='false'){
			body += '<div class="claimButton_container_alt">';
				body += '<p class="claimButton_para_alt">';
					
						
						
							body += 'Claimed';
						
					
				body +=	'</p>';
			body += '</div>';			
		}else{
			body += '<div>';
			
				
				
					body += 'Claim This Place';
				
			
			body += ' &raquo</div>';
			
			
		}
		
	if(operation!=null)return Component.encaseLink(body,operation);
	return body;
}
Component.GetLargeClaimedFlag = function(score){
	var body = '<div class="component_large_claimed_flag">';
		
			body += '<p class="component_large_flag_para">';
				body += score;
			body += '</p>';
		
	body += '</div>';
	
	return body;
}
Component.GetLargeClaimedFlagForActor = function(score){
	var body = '<div class="component_large_claimed_flag_actor">';
			body += '<p class="component_large_flag_para">';
				body += score;
			body += '</p>';
	body += '</div>';
	return body;
}
Component.GetLargeUnClaimedFlag = function(score){
	var body = '<div class="component_large_unclaimed_flag">';
		
			body += '<p class="component_large_flag_para">';
				body += score;
			body += '</p>';
		
	body += '</div>';
	
	return body;
}
Component.GetSmallClaimedFlag = function(letter){
	var body = '<div class="component_small_claimed_flag">';
		body += '<p class="component_small_flag_para">';
			body += Component.GetLetterEquivalent(Number(letter));
		body += '</p>';
	body += '</div>';
	return body;
}
Component.GetSmallClaimedFlagActor = function(letter){
	var body = '<div class="component_small_claimed_flag_actor">';
		body += '<p class="component_small_flag_para">';
			body += Component.GetLetterEquivalent(Number(letter));
		body += '</p>';
	body += '</div>';
	return body;
}
Component.GetSmallUnClaimedFlag = function(letter){

	var body = '<div class="component_small_unclaimed_flag">';
		body += '<p class="component_small_flag_para">';
			body += Component.GetLetterEquivalent(Number(letter));
		body += '</p>';
	body += '</div>';
	return body;
}
Component.GetLocationScoreMarker = function(score){
	var body = '<div class="component_location_score_marker">';
		if(Number(score)<100){
			body += '<p class="component_location_score_marker_para">';
				body += score
			body += '</p>';
		}else{
			body += '<p class="component_location_score_marker_para_max">';
				body += score
			body += '</p>';
		}
	body += '</div>';
	
	return body;
}
Component.View={};
Component.View.CategoryBox = function(header,text,type,operation){
	var body ='';
		if(type==1){
				body += '<div class="view_catBox_container">';
			}else{
				body += '<div class="view_catBox_container_full">';
			}
			body += '<div class="view_catBox_row">';
				body += '<p class="lighter">';
					body += header;
				body += ':</p>';
			body += '</div>';
			body += '<div class="view_catBox_row">';
				body += '<p class="bodyText_tight">';
					body += text;
				body += '</p>';
			body += '</div>';
		body += '</div>';
		
		if(operation!=null)return Component.encaseLink(body,operation);
		return body;
}
Component.View.ButtonWrapper= function(textBody,button){
	var body = ' ';
		
		body += '<div class="view_catBox_textBttn_row">';
		body += textBody;
		body += '</div>';
		body += '<div class="view_catBox_button_row">';
				body += button;
		body += '</div><br/><br/>';
		
	return body;
}

Component.Buttons={};
Component.Buttons.BlueWithArrow=function(text,operation){
	var body= '';
		body += '<div class="button_blue_container">';
			body += '<div class="button_blue_left"></div>';
			body += '<div class="button_blue_middle"><p>';
				body += text;
			body += '</p></div>';
			body += '<div class="button_blue_right_arrow"></div>';
		body += '</div>';
		
		if(operation!=null)return Component.encaseLink(body,operation);
		return body;
}

Component.Buttons.BlueNoArrow=function(text,operation){
	var body= '';
		body += '<div class="button_blue_container">';
			body += '<div class="button_blue_left"></div>';
			body += '<div class="button_blue_middle"><p>';
				body += text;
			body += '</p></div>';
			body += '<div class="button_blue_right"></div>';
		body += '</div>';
		
		if(operation!=null)return Component.encaseLink(body,operation);
		return body;
}
Component.Buttons.GreyNoArrow=function(text,operation){
	var body= '';
		body += '<div class="button_grey_container">';
			body += '<div class="button_grey_left"></div>';
			body += '<div class="button_grey_middle"><p>';
				body += text;
			body += '</p></div>';
			body += '<div class="button_grey_right"></div>';
		body += '</div>';
		
		if(operation!=null)return Component.encaseLink(body,operation);
		return body;
}
Component.LightView={};
Component.LightView.ShowPlaceLocationScore = function(){
	var ctx = 'dialog/location/score';
		Lightview.show({
			href: '/plc?command=dialog&context='+ctx,
			options:{width:820,height:540}
		});
}


Component.NoneFound = '<em>None Provided</em>';

Component.AssistHourFinder = function(data,day){
		if(data==null)
			return '';
		var body = '';
			body += '<em>';
				body += day;
			body += '</em>';
			body += '&nbsp;-&nbsp;';
		switch(data['hoursOfOperationType']['code']){
			case 'OPEN_24_HOURS':
				body += data['hoursOfOperationType']['name'];
				return body;
				break;
			case 'CLOSED':
				body += 'Closed';
				body += '<br />';
				return body;
		}
		body += data['openingTime'];
			body += '&nbsp;-&nbsp;';
		body += data['closingTime'];
		body += '<br />';
		
		return body; 
}
Component.FindHours = function(info,anchor){
	if(info.customHoursOfOperation.length>0)
		return Component.SpecialFindHours(info);
		
	var body =''; 
	body =  Component.AssistHourFinder(info['sundayHoursOfOperation'],'Sunday');
	body += Component.AssistHourFinder(info['mondayHoursOfOperation'],'Monday');
	body += Component.AssistHourFinder(info['tuesdayHoursOfOperation'],'Tuesday');
	body += Component.AssistHourFinder(info['wednesdayHoursOfOperation'],'Wednesday');
	body += Component.AssistHourFinder(info['thursdayHoursOfOperation'],'Thursday');
	body += Component.AssistHourFinder(info['fridayHoursOfOperation'],'Friday');
	body += Component.AssistHourFinder(info['saturdayHoursOfOperation'],'Saturday');
	if(body.length<1) {
		body += Component.NoneFound;
	} else {
		body = '<div id="'+anchor+'">' + body;
		body += '</div>';
	}
	return body;
}
Component.SpecialFindHours = function(info){ 
 	var body = ''; 
      try{ 
           if(info){ 
                if(info.customHoursOfOperation){ 
                     for(var i=o;i<info.customHoursOfOperation;i++){ 
                          body += info['customHoursOfOperation'][i]['hoursOfOperation']['openingTime']; 
                          body += ' - '; 
                          body += info['customHoursOfOperation'][i]['hoursOfOperation']['closingTime']; 
                          body += ' '; 
                          body += info['customHoursOfOperation'][i]['startDate']; 
                          body += ' - '; 
                          body += info['customHoursOfOperation'][i]['endDate']; 
                     } 
                }else{ 
                     body += Component.NoneFound; 
                } 
           }else{ 
                body += Component.NoneFound; 
           } 
      }catch(e){ 
            
      } 
      if(body.length<1)
      	body += Component.NoneFound;

      return body; 
 }

Component.FindNeighborhood = function(info){
	var body = '';
		if(info['customProperty4']){
			body += info['customProperty4'];
		}else{
			body += Component.NoneFound;
		}
	return body;
}
Component.FindPrimaryUrl = function(info){
	var body = '';
		if(info['primaryUrl']){
			body += info['primaryUrl'];
		}else{
			body += Component.NoneFound;
		}
	return body;
}
Component.FindPaymentOps = function(info){
	var body = '';
		if(info['paymentTypeAccepted'].length>0){
			$(info['paymentTypeAccepted']).each(function(item){
				body += item.name;
				body += ', ';
			});
			body = body.substring(0,body.length-2);
		}else{
			body += Component.NoneFound;
		}
	return body;		
}
Component.CSVtoArray = function(info,key){
	var tmp = new Array();
	if(info){
		if(info[key]){
			if(info[key].length>0){
				$(info[key]).each(function(item){
					tmp.push(item); 
				});
			}
		}
	}
	return tmp;
}
Component.FindCSV = function(info,key){
	var body = '';
		if(info){
			if(info[key]){
				if(info[key].length>0){
					$(info[key]).each(function(item){
						body += item + ', ';
					});
					body = trimString(body);
				}
			}
		}
	if(body.length<1)
		body += Component.NoneFound;
	return body;
}
Component.FindTags = function(info){
	return Component.FindCSV(info,'tag');
}
Component.FindObj = function(info,key){
	var body = '';
		if(info){
			if(info[key]){
				if(info[key].length>0){
					$(info[key]).each(function(item){
						body += item['name'] + ', ';
					});
					body = trimString(body);
				}
			}
		}
	if(body.length<1)
		body += Component.NoneFound;
	return body;
}

Component.FindObjNewRow = function(info,key){
	var body = '';
		if(info){
			if(info[key]){
				if(info[key].length>0){
					$(info[key]).each(function(item){
						body += item['name'] + '<br/>';
					});
				} else {
					body += Component.NoneFound;				
				}
			}
		}
	return body;
}
Component.FindCategories = function(info,anchor){
	var body ='<div id="'+anchor+'">'; 
	body += Component.FindObj(info,'category');
	body += '</div>';
	//alert(body);
	if(body.length<1)
		body += Component.NoneFound;
	return body;
}
Component.FindLangSpoken = function(info){
	var arr = Component.CSVtoArray(info,'languageSpoken');
	var body = '';
	
	$(arr).each(function(item){
		switch(item){
			case 'zh':
				body += 'Chinese, ';
				break;
			case 'en':
				body += 'English, ';
				break;
			case 'fr':
				body += 'French, ';
				break;
			case 'de':
				body += 'German, ';
				break;
			case 'es':
				body += 'Spanish, ';
				break;				
		}	
	});
	body = trimString(body);
	if(body.length<1)
		body += Component.NoneFound;
	return body;
}
Component.FindFax = function(info,anchor){
	var body ='';
	if (info.primaryFaxNumber) {
		body += info.primaryFaxNumber;
	}
	if(body.length<1) {
		body += Component.NoneFound;
	} else {
		body = '<div id="'+anchor+'">' + body + '</div>';
	}
	return body;
}
Component.FindTollFree = function(info,anchor){
	var body ='';
	if (info.tollFreePhoneNumber) {
		body += info.tollFreePhoneNumber;
	}
	if(body.length<1) {
		body += Component.NoneFound;
	} else {
		body = '<div id="'+anchor+'">' + body + '</div>';
	}
	return body;
}
Component.FindMobile = function(info,anchor){
	var body ='';
	if (info.alternatePhoneNumber) {
		body += info.alternatePhoneNumber;
	}
	if(body.length<1) {
		body += Component.NoneFound;
	} else {
		body = '<div id="'+anchor+'">' + body + '</div>';
	}
	return body;
}
Component.FindAffiliation = function(info,anchor){
	var body ='';
	if (info.customProperty6) {
		body += info.customProperty6;
	}
	if(body.length<1) {
		body += Component.NoneFound;
	} else {
		body = '<div id="'+anchor+'">' + body + '</div>';
	}
	return body;
}
Component.FindAmenities = function(info){
	
}

Component.GetAlertItem = function(info,label){
	var body = '';
		if(info){
			body += '<div>';
				if(label){
					body += '<div>';
						body += label;
					body += '</div>';
				}
				body += '<div>';
					body += info;
				body += '</div>';
			body += '</div>';
		}else{
			body += Component.NoneFound;
		}
	return body;
}
Component.AbstractGetExpertOrgBox = function(header,textBody,linkText,operation){
	var body = '';
	body += '<div class="component_expertOrg_container">';
			body += '<div class="component_expertOrg_header_container">';
				body += '<div class="component_exportOrg_header">';
					body += '<div class="component_exportOrg_header_cell_left">';
						body += '<p>';
							body += header;
						body += '</p>';
					body += '</div>';
					body += '<div class="component_exportOrg_header_cell_right">';
						body += '<p>';
							body += '<a href="#" onclick="';
								body += operation;
							body += '">';	
								body += linkText;
							body += '</a>';
						body += '</p>';
					body += '</div>';
				body += '</div>';
			body += '</div>';
		body += '</div>';
		body += '<div class="component_exportOrg_body_container">';
			body += '<div class="component_exportOrg_body">';
				body += textBody;
			body += '</div>';
		body += '</div>';
	body += '</div>'; 
	return body;
}
Component.GetExpertOrgImageBox = function(header,images,linkText,operation){
	var body = '';
		body += '<div class="item_cell">';
			$(images).each(function(item){
				body += '<img height="60px" border="0" src="'
					body += item;
				body += '"/>';
			});
		body += '</div>';
	return Component.AbstractGetExpertOrgBox(header,body,linkText,operation);
}
Component.GetExpertOrgBox = function(header,textBody,linkText,operation){
	var body ='';
		body += '<p>';
			body += textBody;
		body+= '</p>';
		return Component.AbstractGetExpertOrgBox(header,textBody,linkText,operation);
}
Component.Places={};
Component.Places.DisplayRecordConflicts=function(operation){
	var body ='';
		body += '<a href="#" onclick="';
			body += operation;
		body += '">';
			body += '<img src="/plc/static/img/conflict_icon.png" align="left" border="0"  />';
			body += 'Record conflicts';
		body += '</a>';
		
	return body;
}
Component.Places.DisplayAlerts=function(operation){
	var body ='';
		body += '<a href="#" onclick="';
			body += operation;
		body += '">';
			body += '<img src="/plc/static/img/conflict_icon.png" align="left" border="0"  />';
			body += 'Alerts';
		body += '</a>';
		
	return body;
}
Component.Places.RecordDisplay = function(type){
	var body = '';
		body += '<div class="level_two_main_columnTwo_left_two_places_alerts">';
 			body += '<div>';
	switch(type){
		case 0:
			body += '<p style="display:inline">';
	 			body += Component.Places.DisplayAlerts("Control.navigate('/dashboard.html')");
	 			//body += Component.Places.DisplayAlerts('asdf');
	 		body += '</p>';
			break;
		case 1:
			body += '<p style="display:inline">';
 				//body += Component.Places.DisplayRecordConflicts("Control.navigate('/dashboard.html')");
 				body += Component.Places.DisplayRecordConflicts('fdsa');
 			body += '</p>';
			break;
		case 2:
			body += '<p style="display:inline">';
	 			body += Component.Places.DisplayAlerts("Control.navigate('/dashboard.html')");
	 		body += '</p>';
 			body += '<p style="display:inline">';
 				body += Component.Places.DisplayRecordConflicts("Control.navigate('/dashboard.html')");
 			body += '</p>';
			break;
	
	}
		body += '</div>';
	body += '</div>';
}
Component.Discrepancy = {};
Component.Discrepancy.Display = function(target,operation){
	
	if (Page.location.claimedByActor) {
		var body ='';
			body += '<a href="#" onclick="';
			body += operation;
			body += '">';
			body += '<img src="/plc/static/img/conflict_icon.png" border="0" />';
			body += '</a>';
			if($(target)!=null)
				$(target).update(body);
	}
}
Component.AjaxWrappers={};
Component.AjaxWrappers.RenderTitle = function( textBody, sn, target, isClaimed ){
	// Flag icon defaults to red, which means it's claimedByActor.
	var body ='';
		body += '<div class="cell_item">';
		body += '<p class="bizHeader">';
			var clr = 'red';
			if( isClaimed == null ){
				clr = 'red';
			} else if( isClaimed == true ){
				clr = 'blue';
			} else if( isClaimed == false ){
				clr = 'gray';			
			}
			var imgTemplate = new Template( '<img src="/plc/static/img/#{flagColor}_flag.jpg" align="absmiddle" />&nbsp;' );
			body += imgTemplate.evaluate({
				flagColor: clr
			});	
				
			body += textBody;
		body += '</p>';
		body += '<p class="bizCaption">PlaceID:&nbsp;';
			body += sn;
		body += '</p>';
		body += '</div>';
		body += '<div class="cell_item" id="';
			body += target;
			body += '_anchor';
			body += '">';
			
		body += '</div>';
		$(target).update(body);
}

Component.AjaxWrappers.RenderBrand = function(brand, target){
	var body ='<div class="ajaxWrapper_container">';
		body += '<div class="row_item">';
			body += '<div >';
				body += '<p class="lighter">';
					body += 'Brand Name';
				body += ':</p>';
			body += '</div>';
			body += '<div class="cell_item" id="';
				body += target;
				body += '_anchor';
				body += '">';
			body += '</div>';
		
		body +='<div>';
			if(brand.name){
				body += '<p class="bigger_val">';
				body += brand.name;
				body += '</p>';
			}
		body += '</div>';
		body += '</div>';
		$(target).update(body);
}

Component.AjaxWrappers.RenderClientId = function(location, target){
	var body ='<div class="ajaxWrapper_container">';
		body += '<div class="row_item">';
			body += '<div >';
				body += '<p class="lighter">';
					body += 'Client ID';
				body += ':</p>';
			body += '</div>';
			body += '<div class="cell_item" id="';
				body += target;
				body += '_anchor';
				body += '">';
			body += '</div>';
		
		body +='<div>';
			if(location.code){
				body += '<p class="bigger_val">';
				body += location.code;
				body += '</p>';
			}
		body += '</div>';
		body += '</div>';
		$(target).update(body);
}

Component.AjaxWrappers.RenderBusinessId = function(locationAlias, target){
	var body ='<div class="ajaxWrapper_container">';
		body += '<div class="row_item">';
			body += '<div >';
				body += '<p class="lighter">';
					body += 'Business ID';
				body += ':</p>';
			body += '</div>';
			body += '<div class="cell_item" id="';
				body += target;
				body += '_anchor';
				body += '">';
			body += '</div>';
		
		body +='<div>';
			if(locationAlias.code){
				body += '<p class="bigger_val">';
				body += locationAlias.code;
				body += '</p>';
			}
		body += '</div>';
		body += '</div>';
		$(target).update(body);
}

Component.AjaxWrappers.RenderVerification = function(verified, target){
	var body ='<div class="ajaxWrapper_container">';
		body += '<div class="row_item"><div>';		
		if(verified=='not_verified'){
			body += '<div style="float: left; padding-right: 4px;"><img src="/plc/static/img/verification_img3.png"/></div>';
			body +='<div class="verification_fail">';
			body +='You have not been verified for this Place<br/><br/>';
			body += '</div>';
			body += '<a class="button blueButton" onclick="Control.submit(\'\', \'verifyLocation\');" href="#"><div id="plc_location_verification_submit">GET VERIFIED »</div></a>';
			body += '<div class="verification_fail_1">Get verified to include your Location on the NAVTEQ Map.</div>';
		} else if(verified=='verified'){
			body += '<div style="float: left; padding-right: 4px;"><img src="/plc/static/img/verification_img2.png"/></div>';
			body +='<div class="verification">';
			body +='You have been verified for this Place<br/><br/>';
			body += '</div>';
		} else if(verified=='pending'){
			body += '<div style="float: left; padding-right: 4px"><img src="/plc/static/img/verification_img1.png"/></div>';
			body +='<div class="verification">';
			body +='Verification is pending.<br/><br/>';
			body += '</div>';
			body += '<div class="verification">You can check the status of your verification via your dashboard.  We will also send an e-mail once your location has been verified.</div>';
		}
		body += '</div>';
		body += '</div>';
		$(target).update(body);
}

Component.AjaxWrappers.RenderSingleLineWithAlertAnchor = function(text,def,target){
	if(text==null || text=='undefined'){
		$(target).update(Component.AjaxWrappers.AddInfo());
	} else {
		var body = '';
		body += '<div class="row_item">';
		body += '<div class="cell_item">';
			body += text;
		body += '</div>';
		body += '<div class="cell_item" id="';
		body += target;
		body += '_anchor';
		body += '">';
		body += '</div>'
		body += '</div>';
		
		$(target).update(body);
	}
}
Component.AjaxWrappers.RenderDescription = function(text,target){
	var body ='<div class="ajaxWrapper_container">';
		body += '<div class="row_item">';
			body += '<div >';
				body += '<p class="lighter">';
					body += 'Description';
				body += ':</p>';
			body += '</div>';
			body += '<div class="cell_item" id="';
				body += target;
				body += '_anchor';
				body += '">';
			body += '</div>';
		
		body +='<div>';
			if(text){
				body += '<pre class="bodyText_tight">';
					body += text;
				body += '</pre>';
			}else{
				body += Component.AjaxWrappers.AddInfo();
			}
		body += '</div>';
		body += '</div>';
		$(target).update(body);
}
Component.AjaxWrappers.RenderPrimaryPhone = function(text,target){
	var body ='<div class="ajaxWrapper_container">';
		body += '<div class="row_item">';
			body += '<div >';
				body += '<p class="lighter">';
					body += 'Phone';
				body += ':</p>';
			body += '</div>';
			body += '<div class="cell_item" id="';
				body += target;
				body += '_anchor';
				body += '">';
			body += '</div>';
		
		body +='<div>';
			if(text){
			body += '<p class="bigger_val">';
				body += text;
			body += '</p>';
				}else{
					body += Component.AjaxWrappers.AddInfo();
				}
		body += '</div>';
		body += '</div>';
		$(target).update(body);
}
Component.AjaxWrappers.RenderPrimaryUrl = function(text,target){
	var body ='<div class="ajaxWrapper_container">';
		body += '<div class="row_item">';
			body += '<div >';
				body += '<p class="lighter">';
					body += 'Website Address';
				body += ':</p>';
			body += '</div>';
			body += '<div class="cell_item" id="';
				body += target;
				body += '_anchor';
				body += '">';
			body += '</div>';
		
		body +='<div>';
			if(text){
			body += '<p class="bigger_val">';
				body += text;
			body += '</p>';
				}else{
					body += Component.AjaxWrappers.AddInfo();
				}
		body += '</div>';
		body += '</div>';
		$(target).update(body);
}

Component.AjaxWrappers.RenderCategory = function( location, target ){
	var body ='<div class="ajaxWrapper_container">';
		body += '<div class="row_item">';
			body += '<div >';
				body += '<p class="lighter">';
					body += 'Category';
				body += ':</p>';
			body += '</div>';
			body += '<div class="cell_item" id="';
				body += target;
				body += '_anchor';
				body += '">';
			body += '</div>';
		
		body +='<div>';
			if( location ){
			body += '<p class="bigger_val">';
				body += Component.FindObjNewRow( location, 'category' );
			body += '</p>';
				}else{
					body += Component.AjaxWrappers.AddInfo();
				}
		body += '</div>';
		body += '</div>';
		$(target).update(body);
}

Component.AjaxWrappers.RenderSingleText = function(text,target){
	var body = '<div>';
		body += '<p class="bigger_val">';
			body += text;
		body += '</p>';
		body += '</div>';
		$(target).update(body);
}

Component.AjaxWrappers.AddInfo = function(){
	var body='<div class="view_cell_item">';
		body += Component.NoneFound;
	body += '</div>';
	
	/*
	body += '<div class="view_cell_item go_right">';
		if (Page.location.claimedByActor) {
			body += Component.Buttons.GreyNoArrow('+ ADD INFO',"Control.submit('','update')");
		} else {
			// body += Component.Buttons.GreyNoArrow('+ ADD INFO',"Control.submit('','claimLocation')");
		}
	*/
		
	body += '</div>';
	return body;
}	
Component.AjaxWrappers.Truncate = function(number,places)
{
	var body = '';
		var dependent = number.toString();
		var result = dependent.split(".");
		try{
			return String(result[0])+"."+String(result[1]).substring(0,places);
		}catch(p){
		}
		return dependent;
}
Component.Alias = {};
Component.Alias.RenderTitleText = function(text,def,sn,target){
	if(text==null || text=='undefined'){
		$(target).update(Component.AjaxWrappers.AddInfo());
	} else {
		Component.AjaxWrappers.RenderTitle(text,sn,target);
	}
}
Component.Alias.RenderDescText = function(text,def,target){
	Component.AjaxWrappers.RenderDescription(text,target);
}
Component.Alias.RenderSingleText = function(text,def,target){
	if(text==null || text=='undefined'){
		$(target).update(Component.AjaxWrappers.AddInfo());
	} else {			
		Component.AjaxWrappers.RenderSingleText(text,target);
	}
}
Component.Alias.RenderAddress = function(text,def,target){
	if(text==null || text=='undefined'){
		$(target).update(Component.AjaxWrappers.AddInfo());
	} else {
		$(target).update(Component.GetAddress(text));
	}
}
Component.Alias.RenderGeo = function(text,def,target){
	if(text==null || text=='undefined'){
		$(target).update(Component.AjaxWrappers.AddInfo());
	} else {
		$(target).update(Component.GetGeoCordnates(text));
	}
}
Component.Alias.RenderNewMapIcon = function(location,alias,map){
	map.addLocationAliasMarker(location.serialNumber,alias);
}
Component.Alias.RenderCategory = function(text,def,target){
	if (text && text[0]) {
		Component.Alias.RenderSingleText(text[0]['name'],def,target);
	}
}

Component.Map = {};
Component.Map.ToggleMenu = function(id,results){
	
}
Component.Popovers={};
Component.Popovers.ClaimTosClose = function(target,operation){
	$(target).update('');
	eval(operation);
	
}
Component.Popovers.ClaimTosBodyText = function(header,textBodies){
	var body ='';
		body += '<div class="row_item_full">';
			body += '<div>';
				body += header;
			body += '</div>';
			body += '<ul>';
	for(var i=0;i<textBodies.length;i++){
		body += '<li>';
			body += textBodies[i];
		body += '</li>'; 
	}
	//>		body += '</ul>';
		body += '</div>';
	return body;
}
Component.Popovers.BizId = function(target,operation)
{
	//allocated
}
Component.Popovers.ClaimTos = function(target,operation){
	var body ='<div class="popover_claimTos_container">';
			body += '<div class="popover_claimTos_container_header">';
				body += '<div class="row_item_full">';
					body += '<div class="popover_claimTos_header_x">';
						body += '<a href="#" onclick="';
							body += "Component.Popovers.ClaimTosClose('"+target+"','"+operation+"')";
							body += '">';
								body += '<div class="closeTosBox">';
									body += 'X';
								body += '</div>';
						body += '</a>';
					body += '</div>';	
					body +='<div class="popover_claimTos_header_text">'; 
						body += '<div class="row_item_full_flat">';
							body += '<p>';
								body += 'NAVTEQ Locations Registered User Agreement (13-Feb-09)';
							body += '</p>';
						body += '</div>';
						body += '<div class="row_item_full_flat">';
							body += '<p>';
								body += '*	The NAVTEQ Locations Website is under development.  Your use of this Website should take this into account.  This Agreement is also under development and will likely be modified.  ';
							body += '</p>';
						body += '</div>';
					body += '</div>';
				body += '</div>';
			body += '</div>';
			body += '<div class="popover_claimTos_container_body">';
				var tmp=['This Agreement is between you (&quot;Registered User&quot;) and NAVTEQ North America, LLC (&quot;NAVTEQ).  This Agreement applies to your use of the NAVTEQ Locations Website and your participation in NAVTEQ Locations, including but not limited to all products, software and services offered via the website such as the NAVTEQ geo-spatial referencing platform, the NAVTEQ Locations Content Management System (&quot;LCMS&quot;) and its derivative parts, and other applications.'];
				body += Component.Popovers.ClaimTosBodyText('1. Parties ',tmp);
				
				tmp = ['The NAVTEQ Locations website includes Terms of Use (add LINK) that apply to all users of the site.  As a Registered User, you agree to comply with this Agreement as well as the Terms of Use of the NAVTEQ Locations Website.  In any way that this Agreement and the Terms of Use of the NAVTEQ Locations Website differ, this Agreement shall supersede the Terms of Use.'];
				body += Component.Popovers.ClaimTosBodyText('2. NAVTEQ Locations Website Terms of Use',tmp);
				
				tmp = ['In order to become a Registered User and access some features of the NAVTEQ Locations Website, you will have to create a NAVTEQ Locations account. When creating your account, you must provide accurate and complete information. You are solely responsible for the activity that occurs on your account.  You agree to keep your password secure and you agree to notify NAVTEQ of any breach of security or unauthorized use of your account.  NAVTEQ is not liable for your losses caused by any unauthorized use of your account; however you may be liable for the losses of NAVTEQ or others occasioned by unauthorized use.'];
				body += Component.Popovers.ClaimTosBodyText('3. NAVTEQ Locations Accounts',tmp);
				
				tmp = ['A. As a Registered User you may submit any content you legally own or are otherwise entitled to, collectively referred to as &quot;User Submitted Content.&quot; ','B. You shall be solely responsible for your own User Submitted Content and the consequences of posting it. You affirm, represent, and/or warrant that: you own or have the necessary permission to use and authorize NAVTEQ to use any and all intellectual property rights in said User Submitted Content to enable inclusion and use of the User Submitted Content.','C. You retain ownership rights in your User Submitted Content. However, by submitting User Submitted Content to NAVTEQ, you hereby grant NAVTEQ a worldwide, non-exclusive, royalty-free, and transferable license, with a right to sub-license, to use, reproduce, distribute, prepare derivative works of, display, and perform the User Submitted Content in connection with the NAVTEQ Locations Website and NAVTEQ&quot;s businesses, including without limitation for promoting and redistributing part or all of the NAVTEQ Locations Website (and derivative works thereof) in any media formats and through any media channels and for inclusion in NAVTEQ&quot;s map database products and other services. You also hereby grant each User of the NAVTEQ Locations Website a non-exclusive license to access your User Submitted Content through the Website, and to use, reproduce, distribute, display and perform such User Submitted Content as permitted through the Website under the Terms of Use. The above licenses granted by you are perpetual and irrevocable.','D. In connection with User Submitted Content, you further agree that you will not submit material that is copyrighted, protected by trade secret or otherwise subject to third party proprietary rights, including privacy and publicity rights, unless you are the owner of such rights or have permission from their rightful owner to post the material and to grant NAVTEQ all of the license rights granted herein.','E. NAVTEQ does not endorse any User Submitted Content or any opinion, recommendation, or advice expressed therein, and NAVTEQ expressly disclaims any and all liability in connection with User Submitted Content. NAVTEQ will remove any User Submitted Content upon notification in accordance with its take-down policy, as set forth in the Terms of Use.  NAVTEQ reserves the right to remove User Submitted Content without prior notice.'];
				body += Component.Popovers.ClaimTosBodyText('4. User Submitted Content',tmp);
				
				tmp = ['A. You agree not to access your own or anybody else&quot;s User Submitted Content through any means other than the NAVTEQ Locations Website itself, except as authorized by NAVTEQ.','B. You agree not to use, resell or redistribute other&quot;s User Submitted Content for commercial purposes, without permission from NAVTEQ or the owner of the other&quot;s User Submitted Content, or someone with authority to act on behalf thereof.','C. You agree not to use the Website or its related services in any way that NAVTEQ determines competes with NAVTEQ Locations.'];
				body += Component.Popovers.ClaimTosBodyText('5. Prohibited Activities',tmp);
				
				tmp = ['A. NAVTEQ reserves the right to terminate a Registered User&quot;s account and access.','B. NAVTEQ reserves the right to decide whether User Submitted Content complies with this Agreement. NAVTEQ may remove any User Submitted Content, or portion thereof, and/or terminate a Registered User&quot;s access for uploading material in violation of this Agreement or the Terms of Use at any time, without prior notice and at its sole discretion.'];
				body += Component.Popovers.ClaimTosBodyText('6. Account Termination Policy',tmp);
			body += '</div>';
			/*
			body += '<div class="row_item_full">';
				body += '<div>';
					body += '1. Parties ';
				body += '</div>';
				body += '<ul>';
					body += '<li>';
						body += 'This Agreement is between you (&quot;Registered User&quot;) and NAVTEQ North America, LLC (&quot;NAVTEQ).  This Agreement applies to your use of the NAVTEQ Locations Website and your participation in NAVTEQ Locations, including but not limited to all products, software and services offered via the website such as the NAVTEQ geo-spatial referencing platform, the NAVTEQ Locations Content Management System (&quot;LCMS&quot;) and its derivative parts, and other applications.';
					body += '</li>';
				body += '</ul>';
			body += '</div>';
			
			body += '<div class="row_item_full">';
				body += '<div>';
					body += '2. NAVTEQ Locations Website Terms of Use';
				body += '</div>';
				body += '<ul>';
					body += '<li>';
						body += 'The NAVTEQ Locations website includes Terms of Use (add LINK) that apply to all users of the site.  As a Registered User, you agree to comply with this Agreement as well as the Terms of Use of the NAVTEQ Locations Website.  In any way that this Agreement and the Terms of Use of the NAVTEQ Locations Website differ, this Agreement shall supersede the Terms of Use.';
					body += '</li>';
				body += '</ul>';
			body += '</div>';
			
			body += '<div class="row_item_full">';
				body += 'body';
			body += '</div>';
			*/
		body += '</div>';
		
		$(target).update(body);
}

Component.ApplePie = function(name,showPie){
	this.getPie=function(pieName)
	{
	if (document.cookie.length>0)
	  {
	  this.pieStart=document.cookie.indexOf(pieName + "=");
	  if (this.pieStart!=-1)
		{ 
		this.pieStart=this.pieStart + pieName.length+1; 
		this.pieEnd=document.cookie.indexOf(";",this.pieStart);
		if (this.pieEnd==-1) this.pieEnd=document.cookie.length;
		return unescape(document.cookie.substring(this.pieStart,this.pieEnd));
		} 
	  }
	return "";
	}
	this.setPie = function(pieName,pieValue,pieExpiration)
	{
		this.pieExpiration=new Date();
		this.pieExpiration.setDate(this.pieExpiration.getDate()+pieExpiration);
		document.cookie=pieName+ "=" +escape(pieValue)+
		((pieExpiration==null) ? "" : ";expires="+this.pieExpiration.toGMTString());
	}
	this.pieKey = name;
	this.pieCount;
	this.pieCount = this.getPie(this.pieKey);
	if((this.pieCount != null) && (this.pieCount !=""))
	{
		this.pieCount++;
		this.setPie(this.pieKey,this.pieCount,365);
	}
	else
	{
		this.pieCount=1;
		this.setPie(this.pieKey,this.pieCount,365);
	}
	return this.pieCount;
}

Component.LocationInjection  ={};
Component.LocationInjection.Check = function(){
	if(Page.location == null)
		return true;
	return false;
}
Component.LocationInjection.geocode = function(geocode){
	if(Component.LocationInjection.Check())
		return false;
	
	Page.location.geoLocation.geocode = geocode; 
}
Component.LocationInjection.address = function(address)
{
	if(Component.LocationInjection.Check())
		return false;
	Page.location.geoLocation.address = address;
}
Component.LocationInjection.name = function(name)
{
	if(Component.LocationInjection.Check())
		return false;
	Page.location.name = name;
}

Component.Validate ={};
/*
Component.Validate.AutoRegister = function()
{
	//var nodes = $A( $$("input
	this.reqString="_req";
	this.emailValString="_emv";
	
	this.lookForEmail=function()
	{
		var tmp = $$('div[class="_emv"]');
		console.log($A(tmp));
	}
	this.lookForReq=function()
	{
	
	}
	this.lookForEmail();
}
*/
Component.Validate.Clear = function()
{
	Component.Validate.Failed.Data = new Array();
	Component.Validate.Email.Data=new Array();
}

Component.Validate.Register = function(target,type,outputTarget,text)
{
	switch(type)
	{
		case "email":
			Component.Validate.Email.Register(target,text,outputTarget);
	}
}
Component.Validate.Interface = function(target,text,outputTarget,rules)
{
	this.target=target;
	this.text=text;
	this.outputTarget=outputTarget;
	this.rules=rules;
	return this;
}
Component.Validate.Email = {};
Component.Validate.Email.Data = new Array();
Component.Validate.Email.Register = function(targetItem,text,outputTarget)
{
	Component.Validate.Email.Data.push(Component.Validate.Interface(targetItem,text,outputTarget));
}
Component.Validate.Email.Rule = function(textItem)
{
	dot = textItem.indexOf('@');
	if(dot == -1)
		return false;
	var arr = textItem.split("@");
	if(arr[1] == "undefined" || arr[1] == null)
		return false;
	var arrTwo = String(arr[1]).split(".");
	if(arrTwo[1] == "undefined" || arrTwo[1] == null)
		return false;
	return true;
}
Component.Validate.Email.Check = function()
{
	var data = $A(Component.Validate.Email.Data);
		data.each(function(item,index){
			if(!Component.Validate.Email.Rule(item.text))
			Component.Validate.Failed.Register(Component.Validate.Failed.ValidationInterface(item.target,item.outputTarget));
	});
}
Component.Validate.Failed = {};
Component.Validate.Failed.Data= new Array();
Component.Validate.Failed.ValidationInterface = function(divValidationTarget,validationOutputText)
{
	this.targetDiv = divValidationTarget;
	this.valText = validationOutputText;
	return this;
}
Component.Validate.Failed.Register = function(validationObject)
{
	Component.Validate.Failed.Data.push(validationObject);
}
Component.Validate.Form = function(arr)
{
	Component.Validate.Email.Check();
	if(Component.Validate.Failed.Data.length!=0)
	{
		Component.Validate.Failed.Render();
		return true;
	}
	return false;		
}
Component.Validate.Failed.Render = function()
{
	var data = $A(Component.Validate.Failed.Data);
	data.each(function(item,index){
		var div = $(item.targetDiv);
		div.update(new Element('p',{'class':'componentValidater'}).update(item.valText));
	});
}



Component.encaseLink =function(element,operation){
	var body ='';
	body += '<a href="#" onclick="';
	body += operation;
	body += '" class="encaseLink button grayButton" >';
	body += element;
	//body += 'ASDF';
	body += '</a>';
	return body;
}
Component.claimButton = function(operation){
	
	
	var body='';
	body += '<div class="button_15_container">';
	body += '<div class="button_15_left"></div><div class="button_15_middle"><p>';
	body += "Claim This Place";
	body += '</p></div><div class="button_15_right_arrow"></div>';
	if(operation!=null)return Component.encaseLink(body,operation);
	return body;
}
Component.locationScore = function(score,operation){
		
			var body ='';
			body += '<div class="locationScore_container">';
			body += '<div class="locationScore_left">';
			body += '<p class="locationScore_para">';
			body += "LocationScore";
			body += '</p>';
			body += '</div>';
			body += '<div class="locationScore_right">';
			
			body += '<img src="/plc/static/img/locationScoreNumber_background.jpg" width="35px" height="35px" alt="Location Score percentage"/>';
			body += '<div class="score">';
			body += '<span>';
			body += score;
			body += '%</span>';
			body += '</div>';
			body += '</div>';
			body += '</div>';
	if(operation!=null)return Component.encaseLink(body,operation);
	return body;
}
Component.placeScore = function(score,alt,operation){

	var body = '';
	body += '<div class="locationScore_container">';
	body += '<div class="locationScore_left">';
	body += '<p class="locationScore_para">';
	body += "PlaceScore";
	body += '</p>';
	body += '</div>';
	body += '<div class="locationScore_right">';
	body += '<img src="/plc/static/img/placeScoreNumber_background.jpg" width="35px" height="35px"';
	if(alt!=null) body += ' alt="'+ alt + '"';
	body += ' />';
	body += '<div class="score">';
	body += '<span>';
	body += score;
	body += '%</span>';
	body += '</div>';
	body += '</div>';
	body += '</div>';
	if(operation!=null)return Component.encaseLink(body,operation);
	return body;
}
Component.placeTag = function(id,alt,operation){
	
	var body = '';
	
	body += '<div class="placeTag_container">';
	body += '<img src="/plc/static/img/placeIcon_background.jpg" border="0" width="21px" height="28px" ';
	
	if(alt!=null) body += 'alt="' +alt.toString()+'"';
	
	body += ' />';
	body += '<div class="placeTag_span">';
	body += '<span>';
	body += id.toString();
	body += '</span>';
	body += '</div>';
	body += '</div>';
	
	if(operation!=null)return Component.encaseLink(body,operation);
	return body;
}


Component.profilePhoto = function(src,alt,operation){


	var body = '';
	body += '<img src="';
	body += src.toString();
	body += '" height="75px" width="100px"';
	if(alt!=null) body += ' alt="'+ alt +'"';
	body += '/>';
	
	if(operation!=null)return Component.encaseLink(body,operation);
	return body
}
Component.claimAllCheckedPlaces = function(operation){
	var body = '';
	body += '<p class="claimAllCheckPlaces_para">';
	
		
		
			body += "Claim all Checked Places";
		
	
	body += '</p>';
	
	if(operation!=null)return Component.encaseLink(body,operation);
	return body;
}
Component.sortBox = function(id,listItems,caption,activeItem,operation){
	var body = '';
	body += '<div class="sortBox_container">';
		body += '<div class="sortBox_boxContainer">';
			if(caption!=null){
				body += '<div class="component_spanBox">';
					body += '<span>'+ caption +'</span>';
				body += '</div>';
				body += '<div class="component_sortBox">';
			}else{
				body += '<div class="component_sortBox_full">';
			}
				body += '<select class="component_sortBox" id="'+ id +'" onchange="';
				body += operation;
				body += '">';
					body += '<option value=""></option>';
					for(var item=0;item<listItems.length;item++){
						body += '<option value="'+ listItems[item] +'" ';
						if(activeItem==item) body += 'selected="selected" ';
						body +=  '>';
						body += listItems[item] +'</option>';
					}
				body += '</select>';
			body += '</div>';
		body += '</div>';
	body += '</div>';
	return body;
}

Component.addYourPlaceStaticImage = function(operation){
	body += '<img src="/plc/static/img/addYourPlace_imageAsset.jpg" border="0" height="27px" width="135px" />';
	
	if(operation!=null)return Component.encaseLink(body,operation);
	return body;
}


Component.panelTypeSix = function(id,content,operation){
	var body = '';
	body += '<div id="';
	body += id;
	body += '" class="component_panel_6">';
		body += '<div class="component_panel_6_top"></div>';
		body += '<div class="component_panel_6_body">';
			body += '<div class="component_panel_6_body_inner">';
				body += content;
			body += '</div>';
		body += '</div>';
		body += '<div class="component_panel_6_bottom"></div>';
	body += '</div>';
	
	if(operation!=null)return Component.encaseLink(body,operation);
	return body;
}
Component.getCategories = function(category){
	body = '';
	
	for(var i=0;i<category.length;i++){
		body += category[i].name;
		if(i+1!=category.length) body += ', ';
		}
	//>
	return body;
}
Component.getTags = function(tags){
	body = '';
	
	for(var i=0;i<tags.length;i++){
		body += tags[i].firstChild;
		if(i+1!=tags.length) body += ', ';
	}
	return body;
}

Component.visualClaimedStatusIndicator = function(claimed,operation){
	body = '';
	if(operation!=null)return Component.encaseLink(body,operation);
	return body;
}

// expected format: '2009-06-17T09:33:30.198-07:00'
// result formaT: 'Oct 20, 2009'
// of today than: '11:44pm (just time)'

Component.formatDateTimeShort = function(str) {
	var body = '';
	if (str) {
		var d1 = str.split('T');
		var d2 = d1[0].split('-');
		var y = d2[0];
		var m = '';
		switch (d2[1]) {
			case '01':
				m = 'Jan';
				break;
			case '02':
				m = 'Feb';
				break;
			case '03':
				m = 'Mar';
				break;
			case '04':
				m = 'Apr';
				break;
			case '05':
				m = 'May';
				break;
			case '06':
				m = 'Jun';
				break;
			case '07':
				m = 'Jul';
				break;
			case '08':
				m = 'Aug';
				break;
			case '09':
				m = 'Sep';
				break;
			case '10':
				m = 'Oct';
				break;
			case '11':
				m = 'Nov';
				break;
			case '12':
				m = 'Dec';
				break;
		}
		var d = d2[2];
		var d3 = d1[1].split('.');
		var d4 = d3[0].split(':');
		var hh = d4[0];
		var hm = 'am';
		if (hh == 0) {
			hh = 12;
		} else if (hh > 12) {
			hh -= 12;
			hm = 'pm';
		} else {
			hh++;
			hh--;
		}
		var mi = d4[1];
		
		var today = new Date();
		if (d2[1] == today.getMonth()+1 && d2[2] == today.getDate() && y == today.getFullYear())
			return hh + ':' + mi + hm;

		return m + ' ' + d + ', ' + y;
	}
}


// expected format: '2009-06-17T09:33:30.198-07:00'
// result formaT: 'Oct 20 2009 4:11am'
Component.formatDateTime = function(str) {
	var body = '';
	if (str) {
		var d1 = str.split('T');
		var d2 = d1[0].split('-');
		var y = d2[0];
		var m = '';
		switch (d2[1]) {
			case '01':
				m = 'Jan';
				break;
			case '02':
				m = 'Feb';
				break;
			case '03':
				m = 'Mar';
				break;
			case '04':
				m = 'Apr';
				break;
			case '05':
				m = 'May';
				break;
			case '06':
				m = 'Jun';
				break;
			case '07':
				m = 'Jul';
				break;
			case '08':
				m = 'Aug';
				break;
			case '09':
				m = 'Sep';
				break;
			case '10':
				m = 'Oct';
				break;
			case '11':
				m = 'Nov';
				break;
			case '12':
				m = 'Dec';
				break;
		}
		var d = d2[2];
		var d3 = d1[1].split('.');
		var d4 = d3[0].split(':');
		var hh = d4[0];
		var hm = 'am';
		if (hh == 0) {
			hh = 12;
		} else if (hh > 12) {
			hh -= 12;
			hm = 'pm';
		} else {
			hh++;
			hh--;
		}
		var mi = d4[1];

		return m + ' ' + d + ' ' + y + ' ' + hh + ':' + mi + hm;
	}
}