document.onselectstart = function () { return false; };
var zoomViewer=null;
				var isResizing;
                
function f_scrollTop() {
    return f_filterResults (
        window.pageYOffset ? window.pageYOffset : 0,
        document.documentElement ? document.documentElement.scrollTop : 0,
        document.body ? document.body.scrollTop : 0
    );
}
function f_filterResults(n_win, n_docel, n_body) {
    var n_result = n_win ? n_win : 0;
    if (n_docel && (!n_result || (n_result > n_docel)))
        n_result = n_docel;
    return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

                
var setMenuPosition = function (){
    if(f_scrollTop()>=125){
        if($('#menu').css('position')!='fixed'){
        $('#menu').css({'position':'fixed','top':'10px'});
        $("#lightbox").css({'position':'fixed','top':'10px'});
        }
    }else{
        if($('#menu').css('position')!='absolute'){
        $('#menu').css({'position':'absolute','top':'auto'});
        $("#lightbox").css({'position':'absolute','top':'135px'});
        }
    }
}				
				var setContainerHeight = function()
				{
                    //return;
					
					if (!isResizing) { 
						isResizing = true;
						$w = $(window);
					//console.log("Resizing:"+$w.height()+":"+$w.width());
						var p = 135;
						$g = $('#gallery');
						$g.css({'min-height': ($w.height()-p) + 'px'});
                        $bgimg=$("#ie_bgimg");
                        $bgimg.css("height",$g.height()+ 'px');
                        $bgimg.css("width",$g.innerWidth()+ 'px');
                        //$g.css({'width':$w.width()-300+'px'});
						/*$f=$('#gallery-foot');
						
						$('#gallery>.jScrollPaneContainer').css({'height': ($g.height()-$f.height()-p) + 'px', 'width': $g.width() + 'px'});*/
                        
						//$('#gallery>.jScrollPaneContainer').css({'height': ($g.height()) + 'px', 'width': $g.width() + 'px'});
						//resetScrollPane();
						isResizing = false;	
					}
				};

function initZoomViewer(){
    return;
	Seadragon.Config.maxZoomPixelRatio=1;
	zoomViewer=new Seadragon.Viewer("gallery-image");
	zoomViewer.addControl(makeControl(), 
   Seadragon.ControlAnchor.BOTTOM_RIGHT);
   zoomViewer.clearControls();
   zoomViewer.tracker.oldScrollHandler=zoomViewer.tracker.scrollHandler;
   zoomViewer.tracker.scrollHandler=zoomScrollClickHandler;   
   zoomViewer.tracker.oldClickHandler=zoomViewer.tracker.clickHandler;
   zoomViewer.tracker.clickHandler=zoomScrollClickHandler;
   
}



function zoomScrollClickHandler(tracker,position,scroll,shift){
}
var homeZoom=-1;

function setZoomLevel(zoomPercent){

if(homeZoom<0) 
	homeZoom=zoomViewer.viewport.getZoom() ;

maxZoom=(zoomViewer.source.dimensions.x ) / (zoomViewer.viewport.getContainerSize().x);
if(maxZoom<homeZoom)
return;

zoomRange=maxZoom-homeZoom;
var zoomLevel = zoomPercent*zoomRange;
//zoomViewer.viewport.panTo(new Seadragon.Point();
zoomViewer.viewport.zoomTo(homeZoom+zoomLevel);
zoomViewer.viewport.ensureVisible();

}

function loadZoomImage(dzi) {
	if(!dzi)
	return;
	//zoomViewer.close();
	//$('#reset-button').show();
homeZoom=-1;	
	// Read the contents odthe dzi file.
	var dzi_str = "";

	$.post( "dzi_reader.php",{ dzi : dzi}, function( data ){
			dzi_str = data;
			
			zoomViewer.openDzi(dzi, dzi_str);
			$('#gallery-image').show();
			//resetScrollPane();
			$('#gallery-thumbs').hide();
			//resetScrollPane();
						var newSize = Seadragon.Utils.getElementSize(document.getElementById('gallery-image')); 
					
						if(zoomViewer.viewport)
						zoomViewer.viewport.resize(newSize, false);
						$('#gallery-slider-tack').css('left','0px');
						//alert(newSize);
		}
	);
}

function closeZoomImage(){
	$('#gallery-thumbs').show();
	$('#gallery-image').hide();
	//resetScrollPane();
	
}

function galleryLoaded(){
	$('#gallery-loading').hide();
	//console.log("---Gallery Loaded---");
//	if( !is_news ) {
		$('#gallery').show();


		$('#page-'+currGal).show();
		 galdivid='gallery-thumbs-'+currGal;
	        if( currGalVid )
	            galdivid+='-videos';
	        $('#'+galdivid).show();
	 
        if(currGal=='home'){
        	
            //setTimeout(setupHomePageMasonry,10);
            $('#page-home').hide();
            
        }
if(currGal=='aff1' || currGal=='aff3' ||currGal=='aff5')
	setTimeout(setupAffilatePageMasonry,10);
	
            //setTimeout(resetScrollPane,10);

}
  
function zoomSliderDrag(){
	if($.browser.msie){
		var parentnodeie=this.parentNode.parentNode.offsetLeft;
	}
	else{
		parentnodeie=this.parentNode.offsetLeft;
		}
	
relativeOffset=this.offsetLeft-parentnodeie;//relativeOffset=this.offsetLeft-this.parentNode.offsetLeft;
//alert(this.parentNode.offsetLeft);
totalAvail=this.parentNode.offsetWidth-this.offsetWidth;
currZoomLevel=relativeOffset/totalAvail;
var ua=$.browser;
	if(ua.msie){
		currZoomLevel=Math.round(currZoomLevel);	
	if(ua.version== "7.0")
		{
		currZoomLevel-=2.7;
		}
	}
	
		setZoomLevel(currZoomLevel);
	
}
function zoomSliderReset(perc){
el=$('#gallery-slider-tack')[0];
defaultOffset=el.parentNode.offsetLeft;
relativeOffset=el.offsetLeft-el.parentNode.offsetLeft;
totalAvail=el.parentNode.offsetWidth-el.offsetWidth;
el.offsetLeft=defaultOffset+(perc*totalAvail);
zooView.viewport.goHome();
}
function resetImageCenter()
{
	zoomViewer.viewport.goHome();
	$('#gallery-slider-tack').css('left','0px');
}
 
  function setupHomePageMasonry(){
	  $('#gallery-thumbs-home').masonry({
          singleMode: false,
          itemSelector: 'div.gallery-thumb:visible',
          resizeable: true,
          animate: true,
          columnWidth: 5
    },  function() { 
        if(currGal!='home')
         $('#gallery-thumbs-home').hide();
          //if( $('#gallery-thumbs-home').is(':visible'))
           //resetScrollPane();
           var wid='';
           if($.browser.msie)
        	   {
        	   wid=$c.width()+25;
        	   }
           else{
           wid=$c.width()+15;
           }
			$('#gallery-foot').css('width',wid);
           
    });      
  }
  function setupAffilatePageMasonry(){
	    $('#gallery-thumbs-aff1, #gallery-thumbs-aff3, #gallery-thumbs-aff5').masonry({
	          singleMode: false,
	          itemSelector: 'div.gallery-thumb:visible',
	          resizeable: true,
	          animate: true,
	          columnWidth: 5
	    },  function() { 
	        if(currGal!='aff1')
	        	$('#gallery-thumbs-aff1').hide();
	        if(currGal!='aff3')
	        	$('#gallery-thumbs-aff3').hide();
	        if(currGal!='aff5')
	         $('#gallery-thumbs-aff5').hide();
	          //if( $('#gallery-thumbs-home').is(':visible'))
	           //resetScrollPane();
	           //var wid=$c.width()+15;
			//	$('#gallery-foot').css('width',wid);
	    });      
	  }
  
  
var imageArray=new Array();  
var destImg="";

function scrollToImg(){
         if(destImg && destImg!=""){
             var imgOffset=$('#portfolio_img_'+destImg).offset();
         if(imgOffset)
            $(document).scrollTop(imgOffset.top);
         destImg="";
     }
}

  function showGal(gal_id, showVideos,createOnly){

	  
	  
		var is_news = false;
		if( gal_id == "news" ) {
			gal_id = "7elwZkuBs1";
			is_news = true;
		}
	    
	    galdivid='gallery-thumbs-'+gal_id;
		if( showVideos )
			galdivid+='-videos';

			
		
		//galdivid='gallery-thumbs-'+gal_id;
		
		//alert( "galdivid_id: " + galdivid_id );
		
		if( ! is_news && !createOnly) {
			//$('#gallery').hide();
			//$('#gallery-loading').show();
		}

		
		galcontainer=$('#'+galdivid);
		gal_data=gallery_data[galdivid];
		if(galcontainer.length<1)
		{
			
				
			if(!gal_data){
				//alert( "!gal_data && gal_id != home...." );
				//showGal('home', false);
				//break;
				gal_data={"class":'',"style":"","images":[]};
			}
			galhtml="<div id='"+galdivid+"' class='"+gal_data['class']+"' style='"+gal_data['style']+"; height:auto;'></div>";
			galobj=$(galhtml);
			
	var rowid='';
		
		$.each(gal_data['images'],function(idx,irow){
	/*
			if( showVideos ) {
				imgurl = iimg['imgurl'];
				if( imgurl.indexOf('/movies/',0) ) {
	*/
		
					rowid=galdivid+'_row_'+idx;
		//--		rowobj=$("<div id='"+rowid+"' class='gallery-row'></div>");
					rowobj = $("<span></span>");
					$.each(irow,function(iidx,iimg){
					
						if( showVideos ) {
							//jQuery(document).ready(function($) {
					    		 
					    		//}) ;    	
							imgurl = iimg['imgurl'];
							//if( imgurl.indexOf('/movies/',0) > -1 ) {
							
								imgid=galdivid+'_thumb_'+idx+'_'+iidx;
								//imghtml='<div id="'+imgid+'" '+iimg['go']+' class="gallery-thumb">';						
								imghtml='<div id="'+imgid+'" class="gallery-thumb">';
								//alert(imgurl.length);
								//var matches = imgurl.match(/([a-zA-Z0-9\-_]+)/);
								if(imgurl.indexOf('.')<0 && imgurl.indexOf('/')<0)
								{
								
								//if(imgurl.length==11)//gets youtube url codes lenght 
									
									
								//imghtml+='<a href="#vid_'+idx+'_'+iidx+'_'+gal_id+'" rel="facebox">';
								//imghtml+='<img src="http://img.youtube.com/vi/'+imgurl+'/0.jpg" height="150" width="200"/></a>';
								//imghtml+='<div id="vid_'+idx+'_'+iidx+'_'+gal_id+'" style="display: none;"><object id="youtubevideo" width="640" height="385"><param name="movie" value="http://www.youtube.com/v/'+imgurl+'?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+imgurl+'?rel=1&color1=#000000&color2=#ffffff&border=1&fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="650" height="400"></embed></object></div>';
								imghtml+='<div id=vid_'+idx+'_'+iidx+'_'+gal_id+'" class="video_full"><iframe src="http://player.vimeo.com/video/'+imgurl+'" width="400" height="309" frameborder="0"></iframe>';	
								//imghtml+='<video src="'+iimg['imgurl']+'" id="'+imgid+'" class="video-gallery-thumb" controls="controls" '+iimg['go']+'>your browser does not support the video tag</video>';
								//<img src="'+iimg['imgurl']+'" id="'+imgid+'_img" class="gallery-thumb" '+iimg['go']+' /><span class="thumb-text">';
								
		//						<video src="'+iimg['imgurl']+'" id="'+imgid+'_img" class="gallery-thumb" '+iimg['go']+'>your browser does not support the video tag</video>';
								}//else{
									//imghtml+="<img src='/images/galleryimages/"+gal_id+"/sml/"+iimg['id']+".jpg' />";
									//iimg['info']="(Not a youtube video)";
								//}
								
								if(iimg['info']!=''){
									imghtml+='<span class="thumb-overlay">'+iimg['info']+'</span>';}

								if(iimg['newtext']!=''){
									imghtml+='<span class="thumb-newtext">'+iimg['newtext']+'</span>';}
									
								imghtml+=iimg['imgname']+'</span></div>';
															    
								rowobj.append($(imghtml));
								
							}
						else {
								
								imgid=galdivid+'_thumb_'+idx+'_'+iidx;
                                home_thumb_class='';
                                if(gal_id=='home'){
                                    t_gal_id=iimg['go'].substr(19);
                                    home_thumb_class='thumb-'+t_gal_id;
                                }
								imghtml='<div id="'+imgid+'" '+iimg['go']+' class="gallery-thumb '+home_thumb_class+'"><img src="/'+iimg['imgurl']+'" id="'+imgid+'_img" class="gallery-thumb" '+iimg['go']+' /><span class="thumb-text">';
								
								if(iimg['info']!='' && gal_id=='7elwZkuBs1'){
									imghtml+='<span id="thumb-overlay_'+idx+'_'+iidx+'" class="thumb-overlay">'+iimg['info']+'</span>';
									
									
									var newImg1 = new Image();
									newImg1.src = iimg['imgurl'];
									newImg1.onload = function()
									{
										var wid=newImg1.width-4;
										//$('#thumb-overlay_'+idx+'_'+iidx).css('width',wid);*/
										
										ht=100 / wid * -36;
										$('#thumb-overlay_'+idx+'_'+iidx).css('width',wid);
										$('#thumb-overlay_'+idx+'_'+iidx).css('marginTop',ht);
										
									};
									
									/*$('#'+imgid).mouseenter(function(ev){
										
										ovl=$('.thumb-overlay',ev.target);
										$(ovl).show();
												var ht=$(ovl).height();
										
										//ht=ht+25;
										
										alert(ht);
												$(ovl).css('marginTop',0-ht);
									});*/
									
									if($.browser.msie)
										imghtml+='<br style="clear:both;">';
									
								}
								
								//if(iimg['newtext']!=''){
								//	imghtml+='<span class="thumb-newtext">'+iimg['newtext']+' </span>';}
								
								imghtml+=iimg['imgname']+'</span></div>';
								
								rowobj.append($(imghtml));
								
						}
						
					});
					 
                    galobj.append(rowobj);
					galobj.append($('<br style="clear:both;">'));

		});

		//if( is_news ) {
				//$('#news-gallery-content').html(galobj);
		//	}else {
				$('#gallery-thumbs').append(galobj);
		//	}
		}

	  if(gal_id==currGal && showVideos==currGalVid && !createOnly)
		 {
		  galleryLoaded();
		  return;
		 }        
        
	currGal=gal_id;
	currGalVid=showVideos;
	
	if(createOnly)
		return;
	
	//var loader= new Loader('#'+galdivid, {userCallback:galleryLoaded});
	 if(!currGalVid && gal_data['images'].length>0){
		var img_arr=gal_data['images'][0];
		loadingTotal=loadingCounter=img_arr.length;
	if(currGal=='home'||currGal=='aff1'||currGal=='aff3'||currGal=='aff5')
	{
	$('#gallery-thumbs-home .gallery-thumb').hide();
	$('#gallery-thumbs-aff1 .gallery-thumb').hide();
	$('#gallery-thumbs-aff3 .gallery-thumb').hide();
	$('#gallery-thumbs-aff5 .gallery-thumb').hide();
	}
		
		
		var i;
		imageArray.length=0;
        //$('#gallery-loading').show();
        $('#loading-status').html('');
        
        if(currGal=='home'||currGal=='aff1'||currGal=='aff3'||currGal=='aff5'){
		for(i=0;i<loadingCounter;i++)
		{
			imageArray[i]=new Image();
			imageArray[i].src=img_arr[i]['imgurl'];
			
			$(imageArray[i]).load(onThumbLoaded);
			$(imageArray[i]).error(onThumbError);
			
			//galleryLoaded();		
		}
        }
                    if(gal_id=='home')
                    {    $('#gallery-thumbs-home .gallery-thumb').show();}
                    if(gal_id=='aff1')
                    {    $('#gallery-thumbs-aff1 .gallery-thumb').show();}
                    if(gal_id=='aff3')
                    {    $('#gallery-thumbs-aff3 .gallery-thumb').show();}
                    if(gal_id=='aff5')
                    {    $('#gallery-thumbs-aff5 .gallery-thumb').show();}

		//if($.browser.msie)
		    	galleryLoaded();	
		    	
		
	}else{
		galleryLoaded();
	}
	 
		$('.pod-photographer').removeClass('pod-photographer-current');
		$('#gallery-link-'+gal_id).addClass('pod-photographer-current');
        

		
  }
 

function portfolio(gal_id){
    full_gallery(gal_id);
}
 
 var lightboxImages=[];
 

 function lightboxContains(img_id){
     if($.inArray(img_id,lightboxImages)>=0)
        return true;
    return false;
 }
 
 function updateLightboxView(addimg,removeimg){
     if(addimg!=""){
         var imgid="";
         var myregexp = /galleryimages\/([\s\S]*)\/([\s\S]*)\/([\s\S]*)\.jpg$/i;
var match = myregexp.exec(addimg);
if (match != null) {
    imgid = match[3];
}
         if(addToLightbox(imgid)){
         var newHTML='<li id="lightbox_thumb_'+imgid+'"><img style="zoom: 50%" src="'+addimg.replace("/mid/","/sml/")+'"/></li>';
        // if($("#lightbox_list li").length()>0)
            $(newHTML).prependTo("#lightbox_list");
         //else
         //   $(newHTML).appendTo("#lightbox_list");
         }
     }
     if(removeimg!=""){
         $('#lightbox_thumb_'+removeimg).remove();
         removeFromLightbox(removeimg);
     }
     
/*     if(lightboxImages.length>0){
         $("#lightbox").show();
     }else{
         $("#lightbox").hide();
     } */
 }
 
 function removeFromLightbox(imgid){
     var imgidx=$.inArray(imgid,lightboxImages);
     
     if(imgidx>=0)
        lightboxImages.splice(imgidx,1);
     $("#gallery-portfolio-lightbox #portfolio_img_"+imgid).remove();   
     updateLightboxCookie();
 }
 
 
 function addToLightbox(imgid){
     if(!lightboxContains(imgid)){
         lightboxImages.unshift(imgid);
         updateLightboxCookie();
         return true;
     }
     return false;
 }
   
function updateLightboxCookie(){
    $("#lightbox_counter").html("LIGHTBOX ("+lightboxImages.length+")");
    $.cookie("lightbox",lightboxImages.join('|'));
}
 
 
function clearLightbox(){
    while(lightboxImages.length>0){
        updateLightboxView("",lightboxImages[lightboxImages.length-1]);
    }
} 

function initLightbox(){
    if(!showLightbox)
    return;
    
    if($.cookie("lightbox")!=null && $.cookie("lightbox")!=""){
        lightboxImages=$.cookie("lightbox").split("|");
    }
   /* if(lightboxImages.length>0){
        $("#lightbox").show();
    }else{
        $("#lightbox").hide();
    }                     */
    
    $("#lightbox_counter").click(function(){$("#lightbox_actions").toggle();});
    $("#lightbox_clear").click(clearLightbox);
} 
   
function lightboxEdit(){
  var imgsrc=$("img",$(this).parent().parent()).attr("src");
  var imgid="";  
 var myregexp = /galleryimages\/([\s\S]*)\/([\s\S]*)\/([\s\S]*)\.jpg$/i;
var match = myregexp.exec(imgsrc);
if (match != null) {
    imgid = match[3];
} 

if(imgid=="")
return;

if(lightboxContains(imgid)){
    updateLightboxView("",imgid);
    $(this).html("Add to Lightbox");
    if(currGal=="lightbox"){
        $(this).parent().parent().remove();
    }
}else{
    updateLightboxView(imgsrc,"");
    $(this).html("Remove from Lightbox");
}

}  

function full_gallery(gal_id)
{
	//alert(gal_id);
	galdataid='gallery-thumbs-'+gal_id;
	galdivid='gallery-portfolio-'+gal_id;
    imgcount=0;
    var srcattr="temp";
    var origattr="src";
    $('#gallery_img').empty();
	if($('#'+galdivid).length<1)
	{
		gal_data=gallery_data[galdataid];
		galhtml="<div id='"+galdivid+"' class='"+gal_data['class']+"' style='"+gal_data['style']+"; height:auto;'></div>";
		galobj=$(galhtml);
		//var rowid='';
		$.each(gal_data['images'],function(idx,irow){
			//rowid=galdivid+'_row_'+idx;
			rowobj1 = $("<span></span>");
			$.each(irow,function(iidx,iimg){
                if(iimg['afflink']!='')
                    igourl=iimg['afflink'];
                else
                    igourl=iimg['go'];
                affclass='';
                
                if(iimg['afflink']!='')
                    affclass=' affimg';
                    
				imgidportfolio=galdivid+'_port_'+idx+'_'+iidx;
                if(imgcount++==4){
                    srcattr="src";
                    origattr="original";
                }
                var divheight=iimg['height'];
                
                var infotxt='';

                if(iimg['lnkurl'] && iimg['lnkurl']!=''){
                    if(!iimg['info'] || iimg['info']==''){
                        iimg['info']=galdata['name'];
                    }
                    iimg['info']='<a href="'+iimg['lnkurl']+'" target="_blank">'+iimg['info']+'</a>';
                }

                if(iimg['info'] && iimg['info']!=''){
                    infotxt='<div style="text-align: center">'+iimg['info']+'</div>';
                    divheight+=12;
                }
                
                if(lightboxContains(iimg['id']))
                    lightboxText="Remove from Lightbox";
                else
                    lightboxText="Add to Lightbox";
                    
				imgporthtml='<div '+igourl+' id="portfolio_img_'+iimg['id']+'" class="gallery-img'+affclass+'" style="height: '+divheight+'px;"><div class="img_container" style="position: relative; margin: auto; width: '+iimg['width']+'px; height:'+iimg['height']+'px;"><img '+srcattr+'="/images/test_images/grey.gif" '+origattr+'="/'+iimg['imgportfolio']+'" id="'+imgidportfolio+'_img" class="portfolio-img" width="'+iimg['width']+'" height="'+iimg['height']+'" '+igourl+' /><div class="lightbox_Btn">'+lightboxText+'</div></div>';
                
                                if(iimg['afflink']!='' && iimg['imgname']!=''){
                                    imgporthtml+='<span class="thumb-text">'+iimg['imgname']+'</span>';}
                                    
                                    imgporthtml+=infotxt;
                
				rowobj1.append($(imgporthtml));
			});
			galobj.append(rowobj1);
		});
		$('#gallery_img').append(galobj);
	}
    currGal=gal_id;
	$('#'+galdivid).show();	
	$('#'+galdivid+' img').lazyload({
				placeholder 	: "/images/test_images/grey.gif",       
                effect          : "fadeIn",
				effectspeed      	: "fast",
				failurelimit 	: 1//,
				//event			: "scroll",
				//container    	: $('#gallery')
			});
  scrollToImg();               
}


 
function onThumbLoaded(){

   // if(console && console.log)
  //  console.log("Loaded: "+loadingCounter+"::"+imageArray.length);
    
    decLoadingCounter();

    
}

function onThumbError(){

 //   if(console && console.log)
 //   console.log("Error: "+loadingCounter+"::"+imageArray.length);
    
    decLoadingCounter();
    
}


function decLoadingCounter(){    
				loadingCounter--;
				$('#loading-status').html(Math.round(((loadingTotal-loadingCounter)/loadingTotal)*100)+"%");
				//alert("loaded");
				if(loadingCounter<1)
					{
					//document.body.appendChild(newdiv);
					galleryLoaded();
                    }
				//loader.Start();
				
}
  
 var loadingCounter=0;
 var loadingTotal=0;
 
 
  
 function initGallery() {
//    $('#pod').draggable({ cursor: 'crosshair' });
//    $('#gallery-slider-tack').draggable({ containment: 'parent',axis: 'x',drag: zoomSliderDrag });
    
    
    $(window).bind('resize', setContainerHeight);
//    initZoomViewer();
    //setTimeout(setContainerHeight,500);
    //setTimeout(setContainerHeight,1000);
    //setTimeout(setContainerHeight,2000);
    $('.gallery-thumb, .gallery-thumb, .affimg').live('click',thumbClick);
   // $('a').live('click',thumbClick);
    
//                        $('#nav_next').click(thumbClick);        
//                        $('#nav_previous').click(thumbClick);

    
//    showInfo($("#latest_news"));
    
    
  /*  $("#download_pdf_form").submit( function() {
        
        // window.setTimeout('window.close()',5000); return false;
        if(this.agree_terms.checked!=true) { 
            alert('Please indicate that you have read the copyright notice and agree to it\'s conditions'); 
            return false; 
        }else {
        
            $("#pdf_link").hide();
            $("#pdf_error").html("");
            $.post( $("#download_pdf_form").attr("action"), { 
                        "gal" : $("#pdf_gal").val(),
                        "email" : $("#pdf_email").val(),
                        "agree_terms" : $("#agree_terms").val()
                    },
                    function(data){                    
                        if( data.pdf_link != null ) {
                            pdf_link_str = "pdf/" + data.pdf_link;
                            $("#pdf_link").attr("href", pdf_link_str );
                            $("#pdf_link").show();
                        }
                        
                        if( data.result != null ){
                            $("#pdf_error").html(data.result);
                        }

                    }, "json");
               
/*
            $.ajax({url: $("#download_pdf_form").attr("action"),
                    type: "POST",
                    dataType: "JSON",
                    data: {
                        gal : $("#pdf_gal").val(),
                        email : $("#pdf_email").val(),
                        agree_terms : $("#agree_terms").val()
                    },
                    success: function(data) {

                        alert( "data: " + data );


                            alert( "check link..." );                        
                        if( data.pdf_link != null ) {
                            alert( "showing link..." );
                            $("#pdf_link").attr("href", data.pdf_link );
                            $("#pdf_link").show();
                        }
                        
                                            
                        alert( "got back" );
                        if( data.result != null ){
                            $("#pdf_error").html(data.result);
                        }


                    },
                    error: function(data)
                    {
                        alert( "error... data: " +data+", data.result: " + data.result );            
                    }
            });
         return false;

        }
        
    });*/
    
  }
  
  $(window).load(function() {
	  
	  initGallery();
	  $('#gallery-loading').hide();
	  $('#gallery').show();
	  
    $(window).scroll(setMenuPosition);
    initLightbox();
    $('.lightbox_Btn').live('click',lightboxEdit);
    setContainerHeight();
    setContainerHeight();
    //setupHomePageMasonry();

    thumbClick();
    	 
   /* $(window).hashchange( function(){
    	//console.log("Hashchange:");
    	//console.log("go:"+$(this).attr('go')+"::href:"+$(this).attr('href')+"::hash:"+location.hash);
    	
    	
    	thumbClick();
    	
    	
    });*/
   randBG(); 
  });
   
