// JavaScript Document


var totalImageCount = 0;
var nowShowing = 1;
var ww;
var wh;
function openMask()
	{
	(!runningOnIE6())?$("#mask").css("position","fixed"):false;	
	$("#mask").css("width",ww);
	$("#mask").css("height",wh);
	$("#mask").show();
	}
function closeLightBox()
	{
	$("#mask").css("position","absolute");	
	!runningOnIE6()?$("#pop_up_light").css("position","absolute"):false;	
	$("#pop_up_light").fadeOut('slow');
	$("#mask").hide();
	}
function runningOnIE6()
	{
	if($.browser.msie && $.browser.version=="6.0") return true;
	else return false;
	}
function openLightBox(src)
	{
	var imgLoc = $("#big_file_path").val();
	//alert(siteUrl+imgLoc);
	openMask();
	(!runningOnIE6())?$("#pop_up_light").css("position","fixed"):false;	
	alert($("#img1").width());
	
	$("#load_big_image").attr("src",siteUrl+imgLoc+'/'+src.rel);
	$("#load_image_title").html(src.title);
	//var imgWidth = src.width();
	//alert(imgWidth);
	$("#pop_up_light").css("left",((ww/2)-(824/2)));
	$("#pop_up_light").css("top",20);
	$(".photo-light-box").css("width",392+'px');
	$(".light-box-image").css("width",392+'px');
	$(".light-box-text").css("width",392+'px');
	
	
	
	//$(window).scrollTop()
	runningOnIE6()?$("#pop_up_light").show():$("#pop_up_light").fadeIn("slow");
		
	nowShowing = parseInt(src.id.replace("gallery_image",""));
	$("#image_total").html(totalImageCount);
	$("#image_showing").html(nowShowing);
	
	}
function imageMove(dir)	
	{
	if(dir=="l")
		{
		if(nowShowing>1)
			{
			nowShowing -= 1;
			openLightBox(document.getElementById("gallery_image"+nowShowing));
			
			}
		}
	else	
		{
		if(nowShowing<totalImageCount)
			{
			nowShowing += 1;
			openLightBox(document.getElementById("gallery_image"+nowShowing));
			}
		}	
	}
function getDocumentHeight()
	{
	   if($.browser.msie)
	   {
	       var $temp = $("<div>")
	             .css("position","absolute")
	             .css("left","-10000px")
	             .append($("body").html());
	 
	       $("body").append($temp);
	        var h = $temp.height();
	        $temp.remove();
	        return h;
	    }
	    return $("body").height();
	}


$(document).ready(function() {
	$(".photo-gallery-body2 a").click(function(){
		openLightBox(this);
		});
	$(".light-box-cross img").click(function(){
		closeLightBox();
		});
	$(".gallery_imge_set").each(function(index){
		totalImageCount += 1;
		});
	$("#mask").click(function(){
		closeLightBox();
		});

	ww = $(document).width();
	//ie6t = $("#powerd_by").position().top;
	//wh = runningOnIE6()?(ie6t+90):$(window).height();
	
	});
