(function($){
	$.fn.popupWindow = function(instanceSettings){

		return this.each(function(){

		$(this).click(function(){

		$.fn.popupWindow.defaultSettings = {
			centerBrowser:0, // center window over browser window? {1 (YES) or 0 (NO)}. overrides top and left
			centerScreen:0, // center window over entire screen? {1 (YES) or 0 (NO)}. overrides top and left
			height:500, // sets the height in pixels of the window.
			left:0, // left position when the window appears.
			location:0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}.
			menubar:0, // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}.
			resizable:0, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
			scrollbars:0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
			status:0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
			width:500, // sets the width in pixels of the window.
			windowName:null, // name of window set from the name attribute of the element that invokes the click
			windowURL:null, // url used for the popup
			top:0, // top position when the window appears.
			toolbar:0 // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
		};

		settings = $.extend({}, $.fn.popupWindow.defaultSettings, instanceSettings || {});

		var windowFeatures =    'height=' + settings.height +
								',width=' + settings.width +
								',toolbar=' + settings.toolbar +
								',scrollbars=' + settings.scrollbars +
								',status=' + settings.status +
								',resizable=' + settings.resizable +
								',location=' + settings.location +
								',menuBar=' + settings.menubar;

				settings.windowName = this.name || settings.windowName;
				settings.windowURL = this.href || settings.windowURL;
				var centeredY,centeredX;

				if(settings.centerBrowser){

					if ($.browser.msie) {//hacked together for IE browsers
						centeredY = (window.screenTop - 120) + ((((document.documentElement.clientHeight + 120)/2) - (settings.height/2)));
						centeredX = window.screenLeft + ((((document.body.offsetWidth + 20)/2) - (settings.width/2)));
					}else{
						centeredY = window.screenY + (((window.outerHeight/2) - (settings.height/2)));
						centeredX = window.screenX + (((window.outerWidth/2) - (settings.width/2)));
					}
					window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + centeredX +',top=' + centeredY).focus();
				}else if(settings.centerScreen){
					centeredY = (screen.height - settings.height)/2;
					centeredX = (screen.width - settings.width)/2;
					window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + centeredX +',top=' + centeredY).focus();
				}else{
					window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + settings.left +',top=' + settings.top).focus();
				}
				return false;
			});

		});
	};
})(jQuery);

$(document).ready(function() {

	//
	if ($.browser.mozilla && $.browser.version <= "1.9" ){
		$('body').addClass('ff2');
	}

	//
	if ($.browser.mozilla && $.browser.version <= "1.9.1" ){
		$('body').addClass('ff3');
	}

	//
	if(window.opera){
		$('html').addClass('opera');
	}

	//
	if($.browser.safari){
		$('html').addClass('safari');
	}

	//
	$('a[rel=_blank]').click(function(){
		this.target = "_blank";
	});

	//
	Cufon.replace(
		'.GothamLight, #navigation > li.products > a, #navigation > li.support > a, #navigation > li.resources > a, #navigation > li.aboutus > a, #navigation > li.blog > a',{
			hover: true,
			fontFamily: 'GothamLight'
		}
	);
	Cufon.replace(
		'dl.banner dd',{
			fontFamily: 'GothamLight'
			//textShadow: '#888 -1px -1px, #888 1px 1px'
		}
	);
	Cufon.replace(
		'.GothamMedium, #navigation > li.customerlogin > a, .quick-showcase h2',{
			hover: true,
			fontFamily: 'GothamMedium'
		}
	);
	/*
	Cufon.replace(
		'dl.banner dt',{
			hover: true,
			fontFamily: 'CenturyGothicBold'
		}
	);
	*/

	$('.popup-window').popupWindow({
		height:500,
		width:720,
		scrollbars: 1,
		centerBrowser: 1
	});

	//
	$('a.play').click(function(){
		var video = $(this).attr('id');
		$('#content dl.banner').slideUp('fast');
		$('#content .box-video#'+video+'content').slideDown('normal');
		return false;
	});
	$('#content .box-video span.close').click(function(){
		$('#content .box-video').slideUp('fast');
		$('#content dl.banner').slideDown('normal');
		return false;
	});

	//
	if ($("#products").length > 0){
		$("#products").tabs("div.description", {event:'mouseover', rotate: true}).slideshow({autoplay: true, interval: 15000});
	}
	
	
	//product
	
	if ($('.infiniteCarousel').length > 0){
		var autoscrolling = true;
    
    $('.infiniteCarousel').infiniteCarousel().mouseover(function () {
        autoscrolling = false;
    }).mouseout(function () {
        autoscrolling = true;
    });
    
    setInterval(function () {
        if (autoscrolling) {
            $('.infiniteCarousel').trigger('next');
        }
    }, 3000);
	}
	
	 //lightbox
	if ($('a[rel=lightbox]').length > 0){
		$('a[rel=lightbox]').lightBox({
    	imageLoading:			'_ui/images/lightbox-ico-loading.gif',		
			imageBtnPrev:			'_ui/images/lightbox-btn-prev.gif',			
			imageBtnNext:			'_ui/images/lightbox-btn-next.gif',	
			imageBtnClose:			'_ui/images/lightbox-btn-close.gif',	
			imageBlank:				'_ui/images/lightbox-blank.gif'
    });
	}
	
	//print button
	if ($('.print').length > 0){
		$('.print').click(function(){
			window.print();
		})
	}
	
	
    
   
    

});
