

//Video Box
$(document).ready(function() {
  $(".iframe").fancybox({
  'overlayShow'    : true,
  'zoomSpeedIn'    : 600,
  'frameWidth' : 600,
  'frameHeight': 300,
  'callbackOnShow' : function(){$('object').css('display','block')},
  'callbackOnClose' : function(){$('object').css('display','none')},
  'zoomSpeedOut'    : 500,
  'easingIn'    : 'easeOutBack',
  'easingOut'    : 'easeInBack',
  'padding':0
  });
  $("#videobox").fancybox({
   'overlayShow'    : true,
  'zoomSpeedIn'    : 600,
  'callbackOnShow' : function(){$('object').css('display','block')},
  'callbackOnClose' : function(){$('object').css('display','none')},
  'zoomSpeedOut'    : 500,
  'easingIn'    : 'easeOutBack',
  'easingOut'    : 'easeInBack',
  'frameWidth' : 853,
  'frameHeight': 505,
  'scrolling':'no'
  });
  
  
  initialize();
  
  //weatherinit();

   $('#replyBtn').click(function(){
        $('#replyTitle').ScrollTo(800)
        return false;
        });
      $('#replyBtn2').click(function(){
        $('#replyTitle').ScrollTo(800)
        return false;
        });
      $('#reviewBtn').click(function(){
        $('#reviewTitle').ScrollTo(800)
        return false;
        });
      $('#topBtn').click(function(){
        $('#container').ScrollTo(800)
        return false;
        });
});
//////
  
function check_login(who)
{
    if(!temp) 
    {
		alert("Please login to review!");
    	who.blur();
	}
}
  
 
function get(id,pg,changepage) {
/*
$('#sr').hide();
$('#wait').show();
*/
  if(changepage=="review")  ///// send comment!!
  {
		  var comment=$('#review').val();
		  comment=comment.replace(/\n/g,"[br]");
		  if(!comment) 
		  {
			  alert("Please input your review!");
			  return;
		   }
		  var rating=$('#rating').val();
		  if(!temp) 
			{
				alert("Please Login!");
				return;
			}
			$('#sr').css('opacity',0.2);
			$('#review').val('');
			$('#reviewTitle').ScrollTo(200); 
			$.post("/business/func/getreview.php?"+Math.random(), {
			id:id,
			page:'1',
			order:'time',
			comment:comment,
			rating:rating
			},function(data){
					tips('Review submitted.');
					nav(data);
					 });
 }
  else //not review
  {
	  $('#sr').css('opacity',0.2);
	  var order=$('#sortby').val();
	  var searchtext = $('#searchtext').val();
	  if(!searchtext||searchtext=="Search Reviews") searchtext='';
			$.post("/business/func/getreview.php?"+Math.random(), {
			id:id,
			page:pg,
			order:order,
			searchtext:searchtext
			},function(data){
				nav(data);
				});
  }
}

function nav(data)
{
	$('#sr').html(data);
	$('#sr').css('opacity',1);
	/*
	$('#sr').show();
	*/
	$('#wait').hide();
}



function sele_item(a,orderby){
for(var i=0;i<document.getElementsByTagName("span").length;i++){
if(document.getElementsByTagName("span")[i].id=="itemid"){
document.getElementsByTagName("span")[i].className='Sitem';
document.getElementById("sortby").value=orderby;
}
}
a.className='SitemS';
get(biz_id,1);
}

function showflag(topicid,replyid,zone){
var d=document.flag;
d.topicid.value=topicid;
d.replyid.value=replyid;
d.zone.value=zone;
document.getElementById('flagform').style.display='';
}


function code2img(code){
     return "http://l.yimg.com/us.yimg.com/i/us/we/52/"+code+".gif";  
  }

function weather2html(weather,cat,alt){  //cat =1 now   2 tomorrow ... 
var imgurl = code2img(weather.code);
var text = weather.text;
var _temp = weather.temp;
var temp = "";
var date= weather.date;
  //"date":"21 May 2009",
  //"text":"Mostly Clear",
  //"day":"Thu",
if (_temp==undefined) {
   var high = weather.high;
   var low = weather.low;
   temp = low+" F ~ "+high+" F";
}
else {
   temp = _temp+" F";
}
  switch(cat)
  {
  case '1':
  $('#current_title').text("Current Weather");
       $('#current_img').attr("src",imgurl);
       $('#current_img').attr("title",alt);
       $('#current_stat').text(text);
       $('#current_text').text(temp+"");
       break;
  case '2':
  var day=weather.day;
  $('#tomorrow_title').text(day);
       $('#tomorrow_img').attr("src",imgurl);
       $('#tomorrow_img').attr("title",text);
       $('#tomorrow_stat').text(text);
       $('#tomorrow_text').text(temp+"");
  break;
  case '3':
  var day=weather.day;
  $('#after_title').text(day);
       $('#after_img').attr("src",imgurl);
       $('#after_img').attr("title",text);
       $('#after_stat').text(text);
       $('#after_text').text(temp+"");
  break;
  }
}

function weatherinit()
{
	
// Weather Forecast Init.
var zipcode=biz_zip;
var url ="http://pipes.yahoo.com/pipes/pipe.run?_id=2eb187fcae6192aee203f670109a40f7&_render=json&u=f&p="+zipcode+"&_callback=?";

    $.getJSON(url, function(data){
    var _item = data.value.items[0];
    var alt=_item['y:title'];
  var y_id=_item['y:id']['value'];
  if(y_id!=null){    
       weather2html(_item["yweather:condition"],'1',alt);
       weather2html(_item["yweather:forecast"][0],'2','');
       weather2html(_item["yweather:forecast"][1],'3','');
       $('.weather').slideDown('slow');
  }
    })
	
}

function initialize() {
//Google Map init.
if(zoom==0)
{
  document.getElementById("map_canvas").innerHTML="<center><img src=../../../theme/default/images/nomap.png></center>";
}
else
{      
var map = new GMap2(document.getElementById("map_canvas"));
var center = new GLatLng(mapy, mapx);
map.setCenter(center, zoom);
var mxy= new GLatLng(y, x);
var marker = new GMarker(mxy, {draggable: false});
map.addOverlay(marker);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setMapType(G_HYBRID_MAP); 
 }}
 
 
 function tips(content)
{
	$('#tips').html(content);
	$('#tips').show();
	setTimeout("$('#tips').hide()",2200);
}