
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-16024420-7']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

function seo_url(str){
	// Store the current title value
	var title = str;
	// Clean up the title		
	var url = title
		.toLowerCase() // change everything to lowercase
		.replace(/^\s+|\s+$/g, "") // trim leading and trailing spaces		
		.replace(/[_|\s]+/g, "-") // change all spaces and underscores to a hyphen
		.replace(/[^a-z0-9-]+/g, "") // remove all non-alphanumeric characters except the hyphen
		.replace(/[-]+/g, "-") // replace multiple instances of the hyphen with a single instance
		.replace(/^-+|-+$/g, "") // trim leading and trailing hyphens				
		; 
	return url.length>0?url:'';	
}

$(window).load(function() {
	var site = this;
	site.url = "http://benjaminweddingstudio.com/";
	site.theme_path = "assets/css/theme/";
	site.update_images_order = function(container){
		var image_list = $(container).find("li");
		var new_order = [];
		if(image_list.length>0){
			$.each(image_list,function(index,val){
				var image_id = $(val).find('input[name^="image_id"]').val();
				new_order[new_order.length] = image_id;
			});	
			//update order to server
			//call ajax function
			$.ajax({
				url:site.url + "admin/update_images_order",
				  global: false,
				  type: "POST",
				  data: ({data : new_order}),
				  dataType: "html",
				  async:false,
				  success: function(msg){
					//alert(msg);
				  }

			});
		}
	}
	site.update_galleries_order = function(container){
		var gallery_list = $(container).find("li");
		var new_order = [];
		if(gallery_list.length>0){
			$.each(gallery_list,function(index,val){
				var g_id = $(val).find('input[name^="gallery_id"]').val();
				new_order[new_order.length] = g_id;
			});	
			//update order to server
			//call ajax function
			$.ajax({
				url:site.url + "admin/update_galleries_order",
				  global: false,
				  type: "POST",
				  data: ({data : new_order}),
				  dataType: "html",
				  async:false,
				  success: function(msg){
					//alert(msg);
				  }
			});
		}
	}
	site.update_slides_order = function(container){
		var slides_list = $(container).find("li");
		var new_order = [];
		if(slides_list.length>0){
			$.each(slides_list,function(index,val){
				var g_id = $(val).find('input[name^="slider_id"]').val();
				new_order[new_order.length] = g_id;
			});	
			//update order to server
			//call ajax function
			$.ajax({
				url:site.url + "admin/update_slides_order",
				  global: false,
				  type: "POST",
				  data: ({data : new_order}),
				  dataType: "html",
				  async:false,
				  success: function(msg){
					//alert(msg);
				  }
			});
		}
	}
	
	$('#slider').nivoSlider({
		effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
        slices:15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed:500, // Slide transition speed
        pauseTime:5000, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:true, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNav:true, // 1,2,3... navigation
        controlNavThumbs:false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav:true, // Use left & right arrows
        pauseOnHover:true, // Stop animation while hovering
        manualAdvance:false, // Force manual transitions
        captionOpacity:1, // Universal caption opacity

	});
		$("#testimonial_list").simpleslider({
		transition : 'slide',
        easing : 'swing',
        direction : 'horizontal',
        speed : 500,
        auto : true,
        interval : 4000,
        hoverPause : true,
        navigation : false,
        buttons : false,
		loop:true
	});
	
	$("#admin_slider").simpleslider({
		transition : 'slide',
        easing : 'swing',
        direction : 'horizontal',
        speed : 500,
        auto : false,
        interval : 4000,
        hoverPause : true,
        navigation : false,
        buttons : true,
		loop:true
	});
	//this is for admin
	$("#admin_gallery_image_list").sortable({
		revert:true,
		stop:function(){
			//call the function to rearange things right here
			//find all the list item
			site.update_images_order(this);
		}
	});
	$("#admin_sliders_arrange_container").sortable({
		revert:true,
		stop:function(){
			//call the function to rearange things right here
			//find all the list item
			site.update_slides_order(this);
		}
	});
	//var l_list = $("#admin_gallery_image_list").find("li");
	
	
	//$.each(l_list,function(index,el){
	//	$(el).bind("dragstop",function(e){
	//		alert('just stop')
	//	});
	//});
	
	
	
	$("#admin_galleries_list").sortable({
		revert:true,
		stop:function(){
			//call the function to rearange things right here
			//find all the list item
			site.update_galleries_order(this);
		}
	});
	//--------------------
	$('.album_preview').lightBox({
		imageLoading:			site.url + site.theme_path + 'lightbox/images/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
		imageBtnPrev:			site.url + site.theme_path + 'lightbox/images/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
		imageBtnNext:			site.url + site.theme_path + 'lightbox/images/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
		imageBtnClose:			site.url + site.theme_path + 'lightbox/images/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
		imageBlank:				site.url + site.theme_path + 'lightbox/images/lightbox-blank.gif'			// (string) Path and the name of a blank image (one pixel)
	});
	$("#accordion").accordion({
			autoHeight: false
	});
	try{
	tinyMCE.init({
        // General options
			mode : "textareas",
			theme : "advanced",
			plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
			// Theme options
			theme_advanced_buttons1 : "save,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",
			theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,undo,redo,|,link,unlink,anchor,image,|,insertdate,inserttime,preview,|,spellchecker,|,insertfile,insertimage",
			theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			theme_advanced_resizing : true,
	
			// Skin options
			skin : "o2k7",
			skin_variant : "silver",
			extended_valid_elements : "img[src|width|height|class|id|style],a[href|class|id],iframe[src,width,height],p",
			// Example content CSS (should be your site CSS)
			// Drop lists for link/image/media/template dialogs
			template_external_list_url : "js/template_list.js",
			external_link_list_url : "js/link_list.js",
			external_image_list_url : "js/image_list.js",
			media_external_list_url : "js/media_list.js",
			
	});}catch(ex){}//ignore it
	
	$(".contact_images").each(function(index,el){
		$(el).click(function(e){
			/* 
			<iframe width="100%" height="428px" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;q=benjamin+wedding+studio,&amp;aq=&amp;sll=33.760227,-117.995895&amp;sspn=0.003109,0.005284&amp;ie=UTF8&amp;rq=1&amp;ev=zi&amp;split=1&amp;filter=0&amp;radius=0.18&amp;hq=benjamin+wedding+studio,&amp;hnear=&amp;ll=33.75931,-117.995154&amp;spn=0.002199,0.005284&amp;z=14&amp;iwloc=A&amp;cid=5802818429366536373&amp;output=embed"></iframe><br /><small>
        	<a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;q=benjamin+wedding+studio,&amp;aq=&amp;sll=33.760227,-117.995895&amp;sspn=0.003109,0.005284&amp;ie=UTF8&amp;rq=1&amp;ev=zi&amp;split=1&amp;filter=0&amp;radius=0.18&amp;hq=benjamin+wedding+studio,&amp;hnear=&amp;ll=33.75931,-117.995154&amp;spn=0.002199,0.005284&amp;z=14&amp;iwloc=A&amp;cid=5802818429366536373" style="color:#0000FF;text-align:left">View Larger Map</a>
        	</small>
			*/
			
			var str_img = "<img src='" +  $(el).attr("rel") + "' />";
			$("#contact_image_container").html(str_img);
			
			return false;
		});
	});
	$("#showmap_button").click(function(){
		var str_html = "<iframe width='100%' height='428px' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;q=benjamin+wedding+studio,&amp;aq=&amp;sll=33.760227,-117.995895&amp;sspn=0.003109,0.005284&amp;ie=UTF8&amp;rq=1&amp;ev=zi&amp;split=1&amp;filter=0&amp;radius=0.18&amp;hq=benjamin+wedding+studio,&amp;hnear=&amp;ll=33.75931,-117.995154&amp;spn=0.002199,0.005284&amp;z=14&amp;iwloc=A&amp;cid=5802818429366536373&amp;output=embed'></iframe><br /><small><a href='http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;q=benjamin+wedding+studio,&amp;aq=&amp;sll=33.760227,-117.995895&amp;sspn=0.003109,0.005284&amp;ie=UTF8&amp;rq=1&amp;ev=zi&amp;split=1&amp;filter=0&amp;radius=0.18&amp;hq=benjamin+wedding+studio,&amp;hnear=&amp;ll=33.75931,-117.995154&amp;spn=0.002199,0.005284&amp;z=14&amp;iwloc=A&amp;cid=5802818429366536373' style='color:#0000FF;text-align:left'>View Larger Map</a></small>";
		$("#contact_image_container").html(str_html);
		return false;
	});

});

