function ShowChat(){
	$("body.home #zazacontainer a").click();	
}
function animateheader(){
	$("span.anim").animate({"width":390},1000,
		function(){
			$("h1.anim").animate({"width":750},1000);
		}
	);	
}
function showGallery(){
	var url = document.location.hash;
	if(url != ""){
		var indx = parseInt(url.replace("#img" , ""));
		var imgs = $(".itemContainer .items a");
		$(imgs[indx - 1]).click();
	}	
}

$(document).ready(function() {
	$("#slink0").colorbox({inline:true, width:800});
	$("#slink1").colorbox({inline:true, width:550});
	$("#slink2").colorbox({inline:true, width:800});
	$(".testi_more").click(
		function(){
			$(".testiAcc").slideToggle("slow");	
			return false;
		}
	);
	//$("#zazacontainer a").attr("onclick","");	
	//$("#zazacontainer a").colorbox({iframe:true, innerWidth:585, innerHeight:513, href:"http://zazachat.zazasoftware.com/livechatclient/prechat.aspx?d=0&ms=&zzwindow=0&zazac=17536&custom1=&custom2=&custom3="});
	//setTimeout("ShowChat()", 45000);
	setTimeout("animateheader()", 2000);
	
	$(".phonenum").colorbox({width:550, inline:true, href:"#click_to_call"});
	$(".txt").click(
		function(){
			if($(this).val() == $(this).attr("title")){
				$(this).val("");	
			}
		}
	
	);
	
	if($("#vidHolder").length > 0){
		var flashvars = {
			file: "/wp-content/uploads/videos/mok grocery 4by3-revised(1).flv", 
			image: "/images/video.jpg", 
			autostart:"false"
		}
	
		var params = {
			allowfullscreen:"true", 
			allowscriptaccess:"always",
			wmode:"transparent"
		}
	
		var attributes = {
			id:"player1",  
			name:"player1"
		}
	
		swfobject.embedSWF(templateURL + "/player.swf", "vidHolder", "604", "360", "9.0.115", false, flashvars, params, attributes);
	}
	
	$("body.page-id-91 .contentfr a").click(
		function(){
			var vid = $(this).attr("href");
			var player = window.document["player1"];
			player.sendEvent('STOP');
			player.sendEvent('LOAD', vid);
			player.sendEvent('PLAY');
			return false;
		}
	);
	
	$(".needhelp a, a.needhelp").click(
		function(){
			$("#zazacontainer a").click();	
			return false;
		}
	);
	
	$("form").submit(
		function(){
			if($(this).attr("role") == "search"){
				if($("input[name=s]").val() == ""){
					alert("Please enter keyword");
				}else{
					return true;
				}
			}
			var fID = $(this).attr("id");
			var _data = $(this).serialize() + "&ajax=yes";
			var _url = $(this).attr("action");
			var pform = $(this);
			$(".c_msg", pform)
			.css("display","none")
			.html("<p class='info'>Sending data. Please wait...</p>")
			.fadeIn("slow");
			
			jQuery.ajax({
			   type: "POST",
			   url: _url,
			   data: _data,
			   success: function(msg){
				    $(".c_msg", pform).html(msg)
					.delay(3000)
					.fadeOut("slow");
					
				  if(msg.indexOf("<!--RESET-->") > -1){
					   $("input[type=text], textarea").each(
							function(index,item){
								$(item).val($(item).attr("title"));
							}
					   );
				   }
			   }
			});
			return false;
		}
	);
	
	$(".arrowdown").click(
		function(){
			var _slider = $(".frimgcontent .items");
			var nML3 = (parseInt(_slider.css("marginTop")) - 360) * (-1);
			var aWidth3 = 1080;
			if(aWidth3 > nML3){
				_slider.animate({"marginTop": "-=360px"}, 400);
			}else{
				_slider.animate({"marginTop": "0px"}, 400);	
			}
			return false;
		}
	)
	$(".arrowup").click(
		function(){
			var _slider = $(".frimgcontent .items");
			var nML3 = (parseInt(_slider.css("marginLeft")) + 360) * (-1);
			var aWidth3 = 0;
			if(nML3 > -1){
				_slider.animate({"marginTop": "+=360px"}, 400);
			}else{
				_slider.animate({"marginTop": aWidth3 + "px"}, 400);	
			}
			return false;
		}
	)
	
	$(".frimgcontent .itemContainer .items a").click(
		function(){
			var src = $(this).attr("href");
			$("#imageBox").fadeOut(500,
				function(){
					$(this).attr("src", src);		
					$(this).fadeIn(500);
				}
			);
			return false;
		}
	)
	
	$(".txt").blur(
		function(){
			if($(this).val() == ""){
				$(this).val($(this).attr("title"));	
			}
		}					
	)
	
	$(".menucont. ul").children("li").each(
		function(index,item){
			$(item).hover(
				function(){
					$("ul:first",this).stop(true, true).fadeIn(500);
					$(this).siblings().each(
						function(index,item){
							if($("ul:first",$(item)).is(":visible")){
								$("ul:first",$(item)).fadeOut(500);
							}
						}
					);
				},
				function(){
					$("ul:first",this).fadeOut(500);
				}
			)
		}
	);
	
	if($("body.page-id-89").length > 0){
		showGallery();	
	}
	
	$(window).hashchange( 
		function(){
			showGallery();	
		}
	);
	
});
