
//-----------------------------
// $(document).ready() 
//-----------------------------
$(document).ready(function() {
	$("a[tooltipid]").tooltip({
		delay: 100,
		track: true,
		showBody: "|",
		extraClass: "tooltip_Cal",
		top: 15,
		left: 15,
		bodyHandler: function() {
			if ($(this).attr("tooltipTitle")!=undefined) {
				$('#tooltip h3').html($(this).attr("tooltipTitle")).show();
			} else {
				$('#tooltip h3').hide();
			}
			return $('#'+$(this).attr("tooltipid")).html();
		},
		showURL: false
	});
	$('.date').datepicker({changeYear:true,changeMonth:true,yearRange:'1912:2012'});
	$('.over18').datepicker({changeYear:true,changeMonth:true,yearRange:'1912:2012',maxDate:'-18y',defaultDate:'02/22/93'});
	$('.over13').datepicker({changeYear:true,changeMonth:true,yearRange:'1912:2012',maxDate:'-13y',defaultDate:'02/22/98'});
	$('.over5').datepicker({changeYear:true,changeMonth:true,yearRange:'1912:2012',maxDate:'-5y',defaultDate:'02/22/98'});
	$('.futuredate').datepicker({changeYear:true,changeMonth:true,yearRange:'2012:2022',minDate:'-0d'});
	$('.pastdate').datepicker({changeYear:true,changeMonth:true,yearRange:'1994:2012',maxDate:'-0d'});
	$('input[placeholder]').addClass('placeholder').placeholder({blankSubmit:false});
	$('a.email').nospam({replaceText:true});
	$.smoothAnchors(1500, "easeInOutQuad", false);
	$('#scrollbar').slider({
		min: 0,
		max: 8,
		value: 0,
		slide: function(event, ui) {
			if(event.originalEvent) {
				var newVal = Math.round(ui.value);
				$('#flip' ).jcoverflip( 'current', newVal );
				$('#scrollbar').slider('value', newVal);
			}
		}
	});
	var top = $('.vfloat').offset().top - parseFloat($('.vfloat').css('marginTop').replace(/auto/, 0));
	var top2 = $('#UIModalContent').parent().offset().top - parseFloat($('#UIModalContent').parent().css('marginTop').replace(/auto/, 0));
	$(window).scroll(function (event) {
		fixSidebar();
	});
	$(".UIBtn").css('font-size', '10px').button();
	$('#iss_main_logo').mouseover(function(){showhidesubnav('main_menu_blank')});
	$('#iss_main_content').mouseover(function(){showhidesubnav('main_menu_blank')});
	
	$('a.ajaxdialog').click(function() { 
		var url = this.href;
		var ttl = this.title?this.title:'';
		var mywidth = parseInt(this.getAttribute('dialogwidth')?this.getAttribute('dialogwidth'):450);
		var myheight = parseInt(this.getAttribute('dialogheight')?this.getAttribute('dialogheight'):300);
		//alert(mywidth+' x '+myheight);
		$.ajax({
			  url: url,
			  cache: false,
			  async: true,
			  success: function(html){ 
				$('#UIModalContent').dialog('destroy').html(html).dialog({
					title: ttl, modal: true, width: mywidth, height: myheight, resizable: false,
					buttons:{"Cerrar": function() { $(this).dialog("close"); }},
					open: function(event, ui) {
						//$(this).dialog( "option", "position", 'center' );
						$(this).parent().css("left",($(window).width()-$(this).width())/2+"px");
						$(this).parent().css("top",($(window).height()-$(this).height())/2-50+"px");
						$(this).attr("uimtop",$(this).parent().offset().top-$(window).scrollTop()).attr("uimleft",$(this).parent().offset().left);
						fixSidebar();
						block_rightclick();
					},
					dragStop: function(event, ui){
						$(this).attr("uimtop",$(this).parent().offset().top-$(window).scrollTop()).attr("uimleft",$(this).parent().offset().left);
					}
				});
			}
		});
		return false; 
	});
	$('a.dialog').click(function() { 
		var html = $(this).attr('content') ? $(this).attr('content') : $('#'+this.name).html();
		var ttl = this.title ? this.title : '';
		var mywidth = parseInt(this.getAttribute('dialogwidth')?this.getAttribute('dialogwidth'):450);
		var myheight = parseInt(this.getAttribute('dialogheight')?this.getAttribute('dialogheight'):300);
		$('#UIModalContent').dialog('destroy').html(html).dialog({
			title: ttl, modal: true, width: mywidth, height: myheight, resizable: false,
			buttons:{"Cerrar": function() { $(this).dialog("close"); }},
			open: function(event, ui) {
				$(this).parent().css("left",($(window).width()-$(this).width())/2+"px");
				$(this).parent().css("top",($(window).height()-$(this).height())/2-50+"px");
				$(this).attr("uimtop",$(this).parent().offset().top-$(window).scrollTop()).attr("uimleft",$(this).parent().offset().left);
				fixSidebar();
				block_rightclick();
			},
			dragStop: function(event, ui){
				$(this).attr("uimtop",$(this).parent().offset().top-$(window).scrollTop()).attr("uimleft",$(this).parent().offset().left);
			}
		});
		return false;
	});
	$('a.dialogframe').click(function() { 
		var url = this.href;
		var ttl = this.title ? this.title : '';
		var mywidth = parseInt(this.getAttribute('dialogwidth')?this.getAttribute('dialogwidth'):785);
		var myheight = parseInt(this.getAttribute('dialogheight')?this.getAttribute('dialogheight'):550);
		$('#UIModalContent').dialog('destroy').html('<iframe src="'+url+'" name="dialog_frame" id="dialog_frame"width="100%" marginwidth="0" height="100%" marginheight="0" scrolling="auto" frameborder="0" hspace="0" vspace="0" allowtransparency="true"></iframe>').dialog({
			title: ttl, modal: true, width: mywidth, height:myheight, resizable: false,
			buttons:{"Cerrar": function() { $(this).dialog("close"); }},
			open: function(event, ui) {
				$(this).parent().css("left",($(window).width()-$(this).width())/2+"px");
				$(this).parent().css("top",($(window).height()-$(this).height())/2-50+"px");
				$(this).attr("uimtop",$(this).parent().offset().top-$(window).scrollTop()).attr("uimleft",$(this).parent().offset().left);
				fixSidebar();
				
			},
			dragStop: function(event, ui){
				$(this).attr("uimtop",$(this).parent().offset().top-$(window).scrollTop()).attr("uimleft",$(this).parent().offset().left);
			}
		});
		return false;
	});
	$('a.imgbox').fancybox({
        'autoScale' : true,
        'showCloseButton' : true,
        'showNavArrows' : true,
        'overlayOpacity' : 0.5,
        'titleShow' : true,
        'transitionIn' : 'elastic',
        'transitionOut' : 'elastic',
        'cyclic' : true,
        'overlayColor' : '#000',
        'padding' : 5,
        'margin' : 0
	});
	$('a.holidayvideo').click(function(){
		$.fancybox({
			'padding' : 0,
			'autoScale' : false,
			'transitionIn' : 'none',
			'transitionOut' : 'none',
			'width' : 358,
			'height' : 206,
			'showCloseButton' : true,
			'showNavArrows' : false,
			'overlayOpacity' : 0.5,
			'titleShow' : false,
			'hideOnOverlayClick' : true,
			'hideOnContentClick' : false,
			'overlayColor' : '#000',
			'margin' : 0,
			'href' : this.href,
			'type' : 'swf',
			'swf' : {
				'wmode' : 'transparent',
				'allowfullscreen' : 'false'
			}
		});
		return false;
	});
    $('a.vidbox').fancybox({
        'padding': 0,
        'autoScale': false,
        'transitionIn' : 'elastic',
        'transitionOut' : 'elastic',
        'width' : 480,
        'height' : 268,
        'hideOnOverlayClick' : true,
        'hideOnContentClick' : false,
        'overlayOpacity' : 0.9,
        'overlayColor' : '#000000',
        'titlePosition' : 'outside',
        'showCloseButton' : true,
        'showNavArrows' : true, 
        'type' : 'swf',
        'swf' : {
            'wmode' : 'transparent',
            'allowfullscreen' : 'true'
        }
    });

	$('.cycle').cycle({fx:'turnLeft',cleartype:true,cleartypeNoBg:true});
	function fixSidebar(){
		var y = $(this).scrollTop();
		if (y >= top) {
			$('.vfloat').addClass('fixed');
			$('.vfloat_hide').hide();
		} else {
			$('.vfloat').removeClass('fixed');
			$('.vfloat_hide').show();
		}
		$('#UIModalContent').parent().css("top",(parseInt($('#UIModalContent').attr("uimtop"))+parseInt(y))+"px");
		$('.ui-widget-overlay').height($(window).height());
		$('.ui-widget-overlay').css('top',y);
	}
	$("input:radio").click( function () {
		this.blur();
		this.focus();
	});
	initISSjs();
	block_rightclick();
	$('div[contentFlow="simple"]').each( function (index) {
		new ContentFlow($(this).attr('id'), { 
			reflectionHeight: 0,
			circularFlow: false,
			startItem: 0,
			visibleItems: 4,
			flowSpeedFactor: 2.5,
			endOpacity: .7,
			maxItemHeight: 0,
			scaleFactor: 1.0,
			scaleFactorLandscape: 1.33,
			scaleFactorPortrait: 1.0,
			relativeItemPosition: "top center",
			
			calcSize: function (item) {
				var rP = item.relativePosition;
				
				var h = 1/(Math.abs(rP)+1);
				var w = h;
				return {width: w, height: h};
			}
		} ) ;
		$(this).show();
	});
	$('div[contentFlow="simple-slowScroll"]').each( function (index) {
		new ContentFlow($(this).attr('id'), { 
			reflectionHeight: 0,
			circularFlow: false,
			startItem: 0,
			visibleItems: 4,
			flowSpeedFactor: 1,
			endOpacity: .7,
			maxItemHeight: 0,
			scaleFactor: 1.0,
			scaleFactorLandscape: 1.33,
			scaleFactorPortrait: 1.0,
			relativeItemPosition: "top center",
			
			calcSize: function (item) {
				var rP = item.relativePosition;
				
				var h = 1/(Math.abs(rP)+1);
				var w = h;
				return {width: w, height: h};
			}
		} ) ;
		$(this).show();
	});
	$('div[contentFlow="intense-slowScroll"]').each( function (index) {
		new ContentFlow($(this).attr('id'), {
			reflectionColor: "#ffffff",
			startItem: 0,
			visibleItems: 4,
			flowSpeedFactor: .5,
			
			maxItemHeight: 0,
			scaleFactor: 1.0,
			scaleFactorLandscape: 1.33,
			scaleFactorPortrait: 1.0,
			relativeItemPosition: "top center",
			
			calcSize: function (item) {
				var rP = item.relativePosition;
				
				var h = 1/(Math.abs(rP)+1);
				var w = h;
				return {width: w, height: h};
			}
		} ) ;
		$(this).show();
	});
	$('div[contentFlow="intense"]').each( function (index) {
		new ContentFlow($(this).attr('id'), {
			reflectionColor: "#ffffff",
			startItem: 0,
			visibleItems: 4,
			flowSpeedFactor: 3,
			
			maxItemHeight: 0,
			scaleFactor: 1.0,
			scaleFactorLandscape: 1.33,
			scaleFactorPortrait: 1.0,
			relativeItemPosition: "top center",
			
			calcSize: function (item) {
				var rP = item.relativePosition;
				
				var h = 1/(Math.abs(rP)+1);
				var w = h;
				return {width: w, height: h};
			}
		} ) ;
		$(this).show();
	});
	
	
	$(".scrollable").scrollable({
			
			speed: 1300,
			circular: true, 
			mousewheel: true
		}).navigator();
	
	$('img.order_picture_btn').mousedown( function() {
		var marginTop = '-'+$(this).parent().parent().css('height');
		$(this).css('margin-top', marginTop)
	}).mouseup( function() {
		$(this).css('margin-top', '0px')
	}).mouseout( function() {
		$(this).css('margin-top', '0px')
	});
		
	
});

