function format_email(e,obj)
{var key=false;if(e.keyCode)key=e.keyCode;if(e.which)key=e.which;if(key)
{key=parseInt(key,10);if(key==32)
{obj.value=obj.value.replace(/^\s*(\S*(\s+\S+)*)\s*$/,"$1");if(obj.value.indexOf('@')<=0)
obj.value+='@';else
obj.value+='.';return false;}}
return true;}
var currentWidth=0;function updateLayout()
{if(window.innerWidth!=currentWidth)
{currentWidth=window.innerWidth;var orient;if(currentWidth==320)
{orient="profile";width=320;}
else
{orient="landscape";width=480;}
document.body.setAttribute("orient",orient);setTimeout(function()
{window.scrollTo(0,1);},100);}}
if((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPod/i))){addEventListener("load",function()
{setTimeout(updateLayout,0);},false);setInterval(updateLayout,400);}
function onchange_submit(control,form){if(document.getElementById(control)&&document.getElementById(form)){document.getElementById(control).addEventListener('change',function(){document.getElementById(form).submit();},false);}}
function kill_event(e){e=e||event;e.preventDefault?e.preventDefault():e.returnValue=false;return false;};function activate_gps_button()
{if(navigator.geolocation){if(document.getElementById("gpsButtonContainer")&&document.getElementById("gpsButton")){document.getElementById("gpsButtonContainer").style.display="block";document.getElementById("gpsButton").addEventListener('click',function(){navigator.geolocation.getCurrentPosition(set_location_from_gps);return false;},false);if(document.getElementById("locationInput")){document.getElementById("locationInput").addEventListener('focus',function(){document.getElementById("locationInput").value="";},false);}}
if(document.getElementById("headerGPSButton")){document.getElementById("headerGPSButton").addEventListener('click',function(e){navigator.geolocation.getCurrentPosition(set_location_from_gps_header,failure_go_to_where_page);return kill_event(e);},false);}}}
failure_go_to_where_page=function(){window.location.href=document.getElementById('headerGPSButton').href;}
set_location_from_gps=function(location){if(document.getElementById("jsLocationInput")&&document.getElementById("locationForm")){document.getElementById("jsLocationInput").value=location.coords.latitude+", "+location.coords.longitude;document.getElementById("locationForm").submit();}}
set_location_from_gps_header=function(location){if(document.getElementById("headerJSLocationInput")&&document.getElementById("headerLocationForm")){document.getElementById("headerJSLocationInput").value=location.coords.latitude+", "+location.coords.longitude;document.getElementById("headerLocationForm").submit();}}
ajax_where=function(e){return true;}
where_callback=function(data,textStatus){};$(document).ready(function(){$("form.dealForm input.ajax-flag").attr("value","1");$("form.dealForm input.deal-button").bind('click',function(e){return ajax_vote(e);});});ajax_vote=function(e){var buttonIDArray=e.target.id.split('-');votetype=buttonIDArray[0];dealid=buttonIDArray[2];var buttonInfoList={'deal-id':dealid,'vote-type':votetype,'ajax-flag':1}
$.post("/vote-quiet.php",buttonInfoList,vote_callback,"text");var votecountspan=$("#"+$(this).children().filter("input.vote-type-input").attr("value")+"-count-"+$(this).children().filter("input.deal-id-input").attr("value"));if(votecountspan){var votecount=parseInt(votecountspan.html())+1;votecountspan.html(votecount).addClass("vote-count-pending").removeClass("vote-count");}
return false;}
vote_callback=function(data,textStatus){if(textStatus=="success"&&data!="false"){var dataArray=data.split("|");if(dataArray.length>0){var dealID=dataArray[0];var voteType=dataArray[1];var voteCount=dataArray[2];if(voteType!="save"){$("#"+voteType+"-count-"+dealID).html(voteCount);}
else{$("#"+voteType+"-indicator-"+dealID).addClass("deal-button-indicator-active").html("saved").focus().blur();}}}}
