var tb_pathToImage = "img/shared/loadingAnimation.gif";

function setGuideWin ( targetStr ) {
	var $targets = $(targetStr);
	if ( !$targets.length ) return;
	setHeight($targets);
	$(window).resize(function(){
		setHeight($targets);
	});

	if ( $.browser.msie && $.browser.version < 7 ) {
		$targets.click(function(){
			if($("#TB_window").offset().top < 25) {
				var setPos = $("#TB_window").position().top + Math.abs($("#TB_window").offset().top) + 25;
				$('#TB_iframeContent').load(function(){
					$("#TB_window").css({
						'top': setPos + 'px',
						'margin-top': '0'
					});
				});
			}
			if ( parseInt($(window).scrollTop()) > 0 ) {
				var sp = $("#TB_window").position().top + parseInt($(window).scrollTop());
				$("#TB_window").css({
					'top': sp + 'px',
					'margin-top': '0'
				});
			}
			return false;
		})
	}
}

function setHeight ($targets) {
	if ( !$targets.length ) return;
	var setHeight = $(window).height() - 120;
	$targets.each(function(){
		$(this).attr('href', $(this).attr('href').replace(/height=\d+/, 'height='+setHeight));
	});
	if($('#TB_iframeContent').length) {
		$('#TB_iframeContent').attr('height', setHeight+2).css('height', setHeight+2 + 'px');
		if ( !$.browser.msie ) { //!(jQuery.browser.msie && jQuery.browser.version < 7)) {
			$("#TB_window").css({marginTop: '-' + parseInt((setHeight / 2),10) + 'px'});
		}
	}
}

function isMacFF2 () {
	var res = false;
	
	var userAgent = navigator.userAgent.toLowerCase();
	if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
		var v = $.browser.version.split(".");
		var major = v[0];
		var minor = v[1];
		if ( major == 1 && minor < 9 ) {
			res = true;
		}
	}
	return res;
}

if ( isMacFF2() ){
	// override tb_showIframe
	function tb_showIframe(){
		if ( isMacFF2() ){
			try {
					$('#flashcontent').css('top', '-3000px');
			}
			catch (e) {
			
			}
		}

		$("#TB_load").remove();
		$("#TB_window").css({display:"block"});
	}
	
	/*
	 * override tb_remove
	 */
	function tb_remove() {
		try {
			if ( isMacFF2() ){
				$('#flashcontent').css('top', '0');
			}
		}
		catch (e) {
		
		}
	 	$("#TB_imageOff").unbind("click");
		$("#TB_closeWindowButton").unbind("click");
		$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
		$("#TB_load").remove();
		if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
			$("body","html").css({height: "auto", width: "auto"});
			$("html").css("overflow","");
		}
		document.onkeydown = "";
		document.onkeyup = "";
		return false;
	}
}



