// ------- START GOOGLE ANALYTICS US SITE ------- //
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));


try {
var pageTracker = _gat._getTracker("UA-5300828-6");
pageTracker._trackPageview();
} catch(err) {}

// ------- END GOOGLE ANALYTICS US SITE ------- //


//-------------------------------------------------------------------------------------------
// IMAGE ZOOM
//-------------------------------------------------------------------------------------------

function jqImagePopupByClass() {

	//cache
	
	$('body').append('<div id="jqBufer"></div>');
	$('#jqBufer').css({"visiblity":"hidden", "position":"absolute", "overflow":"hidden", "width":"1px", "height":"1px"});
	$('.jqPopup').each(function(){
		var largesource = $(this).attr("src");
		largesource = largesource.replace(/_sm/gi, "");
		$('#jqBufer').append('<img>');
		$('#jqBufer img:last').attr("src",largesource);
	});
	$('.jqPopup').css("cursor", "pointer").each(function(iteration){
		var largesource = $(this).attr("src");
		largesource = largesource.replace(/_sm/gi, "");
		$(this).hover(function(e){
			$('body').prepend('<div id="hoverTip">Click to Enlarge</div>');
			$('#hoverTip').css({
							"backgroundColor":"#FFFFE2",
							"fontFamily":"Arial, Helvetica",
							"fontSize":"9px",
							"textAlign":"center",
							"borderColor": "#8da891",
							"borderWidth": "1px",
							"borderStyle": "solid",
							"padding":"5px",
							"position":"absolute"
					});
		}, function(){
			$('#hoverTip').remove();
		})
		.mousemove(function(e){
			$('#hoverTip').css({"left":e.pageX - $('#hoverTip').width()/2, "top": e.pageY - $('#hoverTip').height() - 20});
		})
		.click(function(){
			if ($('#popupimage').length == 0) {
				//alert('')
				var offset = $(this).offset();
				$('body').prepend('<div id="popupimage"><div>');
				 var pos = getCenterPosition($('#jqBufer img').eq(iteration).width(),$('#jqBufer img').eq(iteration).height());
				$('#popupimage').css("visibility","hidden").append($('#jqBufer img').eq(iteration).clone());
				$('#popupimage').css({	
							"backgroundColor":"#ffffff",
							"marginLeft":"auto",
							"marginRight":"auto",
							"cursor":"pointer",
							"textAlign":"center",
							"borderColor": "#8da891",
							"borderWidth": "3px",
							"borderStyle": "solid",
							"paddingTop":"20px",
							"paddingBottom":"20px",
							"paddingLeft":"20px",
							"paddingRight":"20px",
							"visibility":"visible",
							"display":"none",
							"position":"absolute",
							'top' : pos.top,
							'left' : pos.left
					});
				//$('#popupimage img').css("visibility","visible")
				$('#popupimage').fadeIn(200, function(){
					$(this).click(function(){
						$(this).fadeOut(200,function(){
							$(this).remove();
						});
					})
				});
			} else {
				$('#popupimage').fadeOut(100,function(){
					$(this).remove();
					$(this).trigger("click");
				});
			}
		});
		$('div').not(this).not('#popupimage').click(function(){
			$('#popupimage').trigger("click");
		});	
	});
}




function jqPopupImage (target, newImageURL) {
	$(target).css("cursor", "pointer")
	.hover(function(e){
		$('body').prepend('<div id="hoverTip">Click to Enlarge</div>');
		$('#hoverTip').css({
						"backgroundColor":"#FFFFE2",
						"fontFamily":"Arial, Helvetica",
						"fontSize":"9px",
						"textAlign":"center",
						"borderColor": "#8da891",
						"borderWidth": "1px",
						"borderStyle": "solid",
						"padding":"5px",
						"position":"absolute"
				});
	}, function(){
		$('#hoverTip').remove();
	})
	.mousemove(function(e){
		$('#hoverTip').css({"left":e.pageX - $('#hoverTip').width()/2, "top": e.pageY - $('#hoverTip').height() - 20});
	})
	.click(function(){
		if ($('#popupimage').length == 0) {
			//alert('')
			var offset = $(this).offset();
			$('body').prepend('<div id="popupimage"><div>');
			$('#popupimage').css({	
						
						"backgroundColor":"#ffffff",
						"cursor":"pointer",
						"textAlign":"center",
						"borderColor": "#8da891",
						"borderWidth": "3px",
						"borderStyle": "solid",
						"paddingTop":"50px",
						"paddingBottom":"50px",
						"paddingLeft":"50px",
						"paddingRight":"50px",
						"display":"none",
						"position":"absolute",
						'top' : offset.top - $(this).height()/4,
						'left' : $(window).width()/2 - 300
				}).append('<img>');
			$('#popupimage img').attr("src",newImageURL);
			$('#popupimage').fadeIn(200, function(){
				$(this).click(function(){
					$(this).fadeOut(200,function(){
						$(this).remove();
					});
				})
			});
		} else {
			$('#popupimage').fadeOut(100,function(){
				$(this).remove();
				$(target).trigger("click");
			});
		}
	});
	$('div').not(target).not('#popupimage').click(function(){
		$('#popupimage').trigger("click");
	});
}




function getCenterPosition(targetWidth,targetHeight) { 
  var win = $(window); 
  var target = { 
    top: Math.round((win.height()-targetHeight)/2)+win.scrollTop(), 
    left: Math.round((win.width()-targetWidth)/2)+win.scrollLeft() 
  } 
  if (target.top<0) target.top = 0; 
  if (target.left<0) target.left = 0; 
  return target; 
}


//-------------------------------------------------------------------------------------------
// OLD
//-------------------------------------------------------------------------------------------

IE = navigator.appName=="Microsoft Internet Explorer";
NS = navigator.appName=="Netscape";
bVer = parseInt(navigator.appVersion);
var newWin=null;
function popup(loc, name, width, height, allowscroll) {
        var _params = "width="+width+",height="+height+", resizable = "+allowscroll+" ,status = "+allowscroll+", scrollbars="+allowscroll+"";
        if (bVer >= 4) {
                 _left = ( (screen.width-width) >>1 );
                 _top = ( (screen.height-height) >>1 );
        } else {
                 _left = ( (800-width) >>1 );
                 _top = ( (600-height) >>1 );
        }
        if (IE) _params += ",top=" + _top + ",left=" + _left;
        else if (NS) _params += ",screenX=" + _left + ",screenY=" + _top;

        newWin = window.open(loc, name, _params);
        if ( newWin!=null && !(IE && bVer<5) )
                newWin.focus();
}



