function ziplook() {
    /* Get a list of theaters from a zip code */
    var zipcode = $('#zipcode').val();
    if (zipcode=='') {
        return;
    }
    $.ajax({
      type: "GET",
      url: "/cinemas_by_zip",
      data: "zipcode="+encodeURI(zipcode),
      complete: function(t){
        $("#neartheaters").html(t.responseText);
		Cufon.replace('.box2 h3', { fontFamily: 'Museo 500'});
		Cufon.replace('.box2 h6', { fontFamily: 'Museo 500'});
		Cufon.replace('#content .box2 .left h5', { fontFamily: 'Museo 700'});
		Cufon.replace('#content .box2 p.det ', { fontFamily: 'Museo 500'});
      }
    });		
}

function zipfocus() {
    if ($('#zipcode').val()=="enter zip code") {
        $('#zipcode').val("");
        $('#zipcode').css('color','#000');
    }
}
function zipblur() {
    if ($('#zipcode').val()=="") {
        $('#zipcode').val("enter zip code");
        $('#zipcode').css('color','#999');
    } else {
        ziplook();
    }
}

function zipkeypress(e,form){
    var key=e.keyCode || e.which;
    if (key==13){
        ziplook();
    }
}


function openmap(lat,lng) {
    window.open('/map?latitude='+lat+'&longitude='+lng,'map','width=400,height=400,menubar=no,status=no,location=no,toolbar=no,scrollbars=no');
}

function showmap(lat,lng) {
    // Show the map
    var center_latlng = new google.maps.LatLng(lat, lng); 
    var myOptions = {
        zoom: 14,
        center: center_latlng,
        mapTypeId: google.maps.MapTypeId.HYBRID
    };
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    google.maps.event.addListener(map,'idle',function (event) {
        mapmoved();
    });

    // The current location
    var curimg = '/static/images/mapicons/red-stars_maps.png';

    new google.maps.Marker({
      position: (new google.maps.LatLng(lat, lng)), 
      map: map, 
      title: "Theater",
      icon: '/static/images/mapicons/red-stars_maps.png'
    })

}

function launch(page,width,height) {
  open(page, '', 'toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes,width='+width+',height='+height);
}
function launchwin(page) {
  open(page, '', 'toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes,width=725,height=635');
}
function launchwinmini(page) {
  open(page, '', 'toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes,width=720,height=520');
}
function launchscroll(page,width,height) {
  open(page, '', 'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width='+width+',height='+height);
}


function purchaserest() {
    $('#spinner').show();
    var quantity = $('#resto_quantity').val();
    var pars = "ctype=resto&quantity="+quantity+"&chktime=" + chktime;
	$.ajax({
	  type: "GET",
	  url: '/member/ajaxpurchase',
	  data: pars,
	  complete: function(t){	
			$('#restup').html(t.responseText);
	  }
	});	 	
}

function submit_contest() {
    if ($('#cfirst_name').val() == '' || $('#clast_name').val() == '') {
        alert("Please enter your name");
        return;
    }
    if ($('#cemail').val() == '') {
        alert("Please enter your e-mail address");
        return;
    }
    if ($('#cmobile1').val() != '' || $('#cmobile2').val() != '' || $('#cmobile3').val() != '') {
        if ($('#cmobile1').val() == '' || $('#cmobile2').val() == '' || $('#cmobile3').val() == '') {
            alert("Please enter all parts of your phone number");
            return;
        }
    }
	var pars = $("#signupform").serialize();
	$.ajax({
	  type: "POST",
	  url: '/contest/signup',
	  data: pars,
	  complete: function(t){	
			$('#contest2div').html(t.responseText);
	  }
	});	 	
}

    
