var flashvars = {};
var params = {
    wmode : "transparent",
    scale : "noscale"
};
var attributes = {};

var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);

jQuery(function (){	
	jQuery('.share').html('<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-lang="es">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script><iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo rawurlencode(URL)?>&amp;layout=button_count&amp;show_faces=true&amp;width=150&amp;action=recommend&amp;font=tahoma&amp;colorscheme=light&amp;height=20" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:150px; height:20px;" allowTransparency="true"></iframe>');

	jQuery("#mapa").fancybox({
		'width'				: '75%',
		'height'			: '75%',
	    'autoScale'     	: false,
	    'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe',
		'overlayshadow'		: true
	});
	jQuery(".item .vermas").fancybox({'modal' : false, 'titleShow' : false});
	/*jQuery(".page-id-5 .item img").each(function (){
        //jQuery(this).attr("rel",jQuery(this).attr("src").substr(0,jQuery(this).attr("src").length-4));
        jQuery(this).attr("src","/images/clientes/"+(jQuery(this).parent().attr("rel")+".jpg"));
        jQuery(this).hover(function (){
            jQuery(this).attr("src","/images/clientes/"+jQuery(this).parent().attr("rel")+".jpg");
        })
        jQuery(this).mouseleave(function (){
            jQuery(this).attr("src","/images/clientes/"+jQuery(this).parent().attr("rel")+"_bn.jpg");
        })
    })*/
    var i=0;
	var anterior=null;
	if (!agentID){
	jQuery("a.video").each(function() {
		switch (jQuery(this).attr("href").lastIndexOf("youtube.com")) {
		case -1:
			jQuery("#main #content").prepend("<div id=\"player"+i+"\" style=\"width:665px;height:480px;display:none\"></div>");
			jQuery(this).data('id',i);
			jQuery(this).data('url',jQuery(this).attr('href'));
			jQuery(this).data('img',jQuery(this).find('img').attr('src'));
			jQuery(this).fancybox( {
				'scrolling' : false,
				'titleShow' : false,
				'padding' : 0,
				'onStart' : function( links, index ) {
				if (anterior!=null){
					jQuery('#player'+anterior).hide();
					$f().unload();
				}
				anterior=jQuery(links[index]).data('id');
					jQuery('#player'+jQuery(links[index]).data('id')).show();
					//jQuery('#player'+jQuery(links[index]).data('id')).html('<video class="video-js" width="665" height="480" controls preload poster="'+jQuery(links[index]).data('img')+'">      <source src="'+jQuery(links[index]).data('url')+'" type=\'video/mp4; codecs="avc1.42E01E, mp4a.40.2"\' /> </video>');
					//jQuery('#player'+jQuery(links[index]).data('id')).VideoJS();
					$f('player'+jQuery(links[index]).data('id'), '/js/flowplayer-3.2.5.swf', jQuery(links[index]).data('url'));
				},
				'onClosed' : function( links, index ) {
					jQuery('#player'+jQuery(links[index]).data('id')).hide();
					$f().unload();
				}
			});
			jQuery(this).attr("href","#player"+i);
			i++;
			break;
		default:
			jQuery(this).click(
					function() {
						jQuery.fancybox( {
							'transitionIn' : 'elastic',
							'transitionOut' : 'elastic',
							'speedIn' : 600,
							'speedOut' : 200,
							'overlayShow' : true,
							'padding' : 0,
							'href' : this.href.replace(new RegExp('watch\\\?v=', 'i'), 'v/'),
							'type' : 'swf',
							'swf' : {
								'wmode' : 'transparent',
								'allowfullscreen' : 'true'
							}
						});
						return false;
					}
			);
		};
	});
	jQuery("a.audio").each(function() {
			jQuery("#main #content").prepend("<div id=\"player"+i+"\" style=\"width:665px;height:29px;display:none\"></div>");
			jQuery(this).data('id',i);
			jQuery(this).data('url',jQuery(this).attr('href'));
			jQuery(this).fancybox( {
				'scrolling' : false,
				'titleShow' : false,
				'padding' : 0,
				'onStart' : function( links, index ) {
					if (anterior!=null){
						jQuery('#player'+anterior).hide();
						$f().unload();
					}
					anterior=jQuery(links[index]).data('id');
					jQuery('#player'+jQuery(links[index]).data('id')).show();
					$f('player'+jQuery(links[index]).data('id'), '/js/flowplayer-3.2.5.swf', {
							plugins: {
								controls: {
									fullscreen: false,
									height: 30,
									autoHide: false
								}
							},
							clip: { 
								   url: jQuery(links[index]).data('url')
							}
						}
					
					);
				},
				'onClosed' : function( links, index ) {
					jQuery('#player'+jQuery(links[index]).data('id')).hide();
					$f().unload();
				}
			});
			jQuery(this).attr("href","#player"+i);
			i++;
		});
	}
	jQuery("a.imagen, a.medio").fancybox( {
		'transitionIn' : 'elastic',
		'transitionOut' : 'elastic',
		'speedIn' : 600,
		'speedOut' : 200,
		'overlayShow' : true
	});
	jQuery("#menubutton").click (function(event){
		event.preventDefault();
		jQuery("#branding #mainnav").toggle();
	});
});
function tour(codigo){
	jQuery('#tourframe').attr('src','http://photosynth.net/embed.aspx?cid='+codigo+'&delayLoad=true&slideShowPlaying=false');
	return (false);
}
