
function send_form() {
	var data=$('#pickup').serialize();
	var url=prefix+"form.php";


	$.post(url,data,function(answer) {
		modal_dialog_show('Your request was sent successfully');
							 });
		$('#reset').click();
	
}

function send_message() {
	var data=$('#contact').serialize();
	var url=prefix+"sendmessage.php";
	$.post(url,data,function(answer) {
							 if (answer=="Captcha code wrong.") {
								 $('#captcha').attr('src','securimage/securimage_show.php?' + Math.random());
								 modal_dialog_show('You entered an incorrect validation code. Please try again.');
							 }
							 else if (answer=="Message sent.") {
								 modal_dialog_show('Message sent.');
								 $('#modal_db').jqmHide();
							 }
							 else {
								 modal_dialog_show('An emailing error occured.');
								 $('#modal_db').jqmHide();
								 
							 }
							 });
}

function toggle_streetview(id){
	$('#'+id).html('<iframe width="220" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com.au/maps/sv?cbp=12,179.1,,0,1&amp;cbll=-27.456132,153.079023&amp;panoid=&amp;v=1&amp;hl=en&amp;gl=au"></iframe><br /><small><a href="http://maps.google.com.au/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=363+Lytton+Rd+Colmslie,+QLD+4170&amp;sll=-25.335448,135.745076&amp;sspn=36.001906,79.101563&amp;ie=UTF8&amp;ll=-27.444687,153.082895&amp;spn=0.00874,0.019312&amp;z=14&amp;iwloc=A&amp;layer=c&amp;cbll=-27.456132,153.079023&amp;panoid=bKimoHyMVD-eiy0noulRDQ&amp;cbp=12,179.1,,0,1" style="color:#0000FF;text-align:left">View Larger Map</a>| <a href="#" onclick="toggle_map(\''+ id +'\'); return false;">View map</a></small>');				  
}

function toggle_map(id){
$('#'+id).html('<iframe width="220" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com.au/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=363 Lytton Rd Colmslie, QLD 4170&amp;sll=-25.335448,135.745076&amp;sspn=36.001906,79.101563&amp;ie=UTF8&amp;ll=-27.444687,153.082895&amp;spn=0.00874,0.019312&amp;z=12&amp;iwloc=near&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com.au/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=363+Lytton+Rd+Colmslie,+QLD+4170&amp;sll=-25.335448,135.745076&amp;sspn=36.001906,79.101563&amp;ie=UTF8&amp;ll=-27.444687,153.082895&amp;spn=0.00874,0.019312&amp;z=14&amp;iwloc=A" style="color:#0000FF;text-align:left">View Larger Map</a>| <a href="#" onclick="toggle_streetview(\''+ id +'\'); return false;">View Streetview</a></small>');			  
}

function show_slide_text() {
	$(this).find('.slidetext').animate({
									   height:"20px",
									   marginTop:"-20px"
									   },500);
}

function modal_dialog_show(text) {
	$('#modal_dialog').html(text+'<br /><a href="javascript:void(0)" onclick="$(\'#modal_dialog\').jqmHide();">Close</a>');							
	$('#modal_dialog').jqmShow();
	

}


function modal_db_show(id) {
	
	var data='&id='+id;
	var url=prefix+"dialogs";
	$('#modal_db').html('');
	$.post(url,data,function(answer) {
							 $('#modal_db').html('<div class="modal-border"><a onclick="$(\'#modal_db\').jqmHide(); $(\'#flashmovie\').css(\'visibility\',\'visible\');  $(\'#flashmovie\').show();" href="javascript:void(0)">Close</a></div><div class="modal_content">'+answer+'</div>');

	$('.flash_offers').flash(
        { src: prefix+'logo.swf',
          width: 204,
		  loop:false,
		  id:'flashmovie-offers',
          height: 168 },
        { version: 8 }
    );
							 
							 });
	$('#flashmovie').css('visibility','hidden');
	$('#flashmovie').hide();
	$('#modal_db').jqmShow();


}

function captcha_refresh() {
		$('#captcha').attr('src','securimage/securimage_show.php?' + Math.random());
}

$(function() {
	//start the slideshow
	$('.slideshow').cycle({
	fx: 'fade',
	speed:  slideshow_fading_speed,
	timeout: slideshow_delay,
	after: show_slide_text,
	before: function(){
			$(this).find('.slidetext').css({"height":"0px","margin-top":"0px"}).hide();}
	});
	
	// initialize modal dialogs
	 $('.dialog').jqm({modal:true})

	 // initialize flash logo
	 
	$('.flash').flash(
        { src: prefix+'logo.swf',
          width: 204,
		  loop:false,
		  id:'flashmovie',
          height: 168},
        { version: 8 },
		function(htmlOptions){
		  htmlOptions.wmode='transparent';
		 $(this).addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions));
		}
    );
	
	$.fn.fancyzoom.defaultsOptions.imgDir=prefix+'images/fancyzoom/'; 
	$(".product a").fancyzoom();
	 // initialize streetview button
	 /*$('#map-change-view').click(function() {
										  toggle_streetview();
										  });*/
	//$.fn.fancyzoom.defaultsOptions.imgDir=prefix+'images/fancyzoom/'; 
	//$('#featured').jcarousel({wrap:"both"});
	
	// show Offers Popup
	if (typeof popup != 'undefined'){
	modal_db_show('Current_Offers');
	}
});

