function addRolloverToImages(containerID){	
	$(containerID + ' * a img').each(function(){
		var containerArray = $(this).attr("src").split("?");
		containerArray = containerArray[0].split(".");
		//$(this).attr("onMouseOver", "this.src = '"+containerArray[0]+"_over."+containerArray[1]+"'");
		//$(this).attr("onMouseOut", "this.src = '"+containerArray[0]+"."+containerArray[1]+"'");
		
		$(this).mouseover(function() {
        	$(this).attr("src", containerArray[0]+"_over."+containerArray[1]);
  		}).mouseout(function(){
    		$(this).attr("src", containerArray[0]+"."+containerArray[1]);
  		});

	})
}

function addBorderHeight(){
	var heightAmount = $('#column-2').height();
	var heightAmount2 = $('#column-1').height();
	if (heightAmount > heightAmount2){
		$('#column-1').css('height', heightAmount);
	}
}


function loadPopupScript()
{
	$("a.pop-up-link").each(function() { //Find every a tag with img+class inside
		var url = $(this).attr("href").toLowerCase(); //Grab the url
		$(this).attr("href", "#").removeAttr("target"); //Remove attributes making it a usable link
	
		$(this).click(function() { //Add an on-click event
			positionPopupContent();
	   	  	$('#pop-up-container-bg').fadeTo("slow",0.8); 			 
			$("#pop-up .button_links").css("width", "45px").css("float", "left");
			$("#pop-up-container").fadeIn("slow", function() { //Show pop-up div
				$("#pop-up-loader").hide( function() { //Hide loader placeholder 	
												   
					if (url.indexOf("pdf") > 0){						
						$('<div class="popup-area"><IFRAME id="myPDFPopup" frameborder="0" scrolling="no" height="600" width="850"></div>').appendTo("#pop-up-content");						
						$('.popup-area').css('visibility', 'hidden');
						$("IFRAME#myPDFPopup").attr('src', url);						
						$("#pop-up-loading").fadeOut("slow", function() { //Hide loading animation															  
							$("#pop-up-loader").fadeIn("slow"); //Show loaded page
							//Set the popup window to center  
							setTimeout('positionPopupContent();',600);
							setTimeout("$('.popup-area').css('visibility', 'visible');" , 800);
							$(window).bind("resize", resizeWindow);
							function resizeWindow( e ) {								
								setTimeout('positionPopupContent();',600);							
							}
						});						
					}					
					
				});
			}); 
		});
  	});

  	$("a#close-button").click(function() { //Close button click event
		/*if($.browser.msie && parseInt($.browser.version) == 7) {
    		alert($.browser.msie +"   "+ parseInt($.browser.version));
		} */ 
		$("#pop-up-content").html("");
    	$("#pop-up-container").fadeOut("fast", function() { //Hide loaded page, to stop transparency issues
      		$("#pop-up-container").fadeOut("slow", function() {  //Hide pop-up div
        		$("#pop-up-loader").hide();  //Hide page data placeholder
				$("#pop-up-content").html("");
        		$("#pop-up-loading").show();  //Show loading animation
      		});
    	});
  	});
}

function positionPopupContent() {
	//$("#pop-up-content").css("height", "700px");
	//$("#pop-up-content").css("width", "900px");
	//alert("Postion " + $("#pop-up-content").height());
	var winH = $(window).height();  
	var winW = $(window).width();
	var maskHeight = $(document).height();  
	//$(".popup-area:last-child").addClass('image_style1');
	if (($(window).height() > $("#pop-up-content").height()+100) && ($(window).width() > $("#pop-up-content").width()+50)) {
		$("#pop-up-loading").css('top',  (winH/2) - 16);
		$("#pop-up-loading").css('left', (winW/2) - 16);
		//$("#pop-up-content").css('top',  winH/2-($(".popup-area").height()/2));
		//$("#pop-up-content").css('left', winW/2-($(".popup-area").width()/2));	
		$("#pop-up-content").css('top',  winH/2-(300));
		$("#pop-up-content").css('left', winW/2-(450));	
		var content_position = $("#pop-up-content").position();
		$(".popup_close_button").css('top',  content_position.top-20);
		//alert('content_position.top ' + content_position.top + "          " + content_position.left + "   " + $("#pop-up-content").width() + "     " + $(".popup_close_button").css('top') + "  " + $(".popup_close_button").css('left'));
		$(".popup_close_button").css('left', content_position.left+$("#pop-up-content").width()-$(".popup_close_button").width());
	}
	
	//Set height and width to mask to fill up the whole screen 	
	if ($(window).width() <= 1001) { 	
		$('#pop-up-container').css({'width':$(document).width(),'height':maskHeight}); 
	}
	else {
		$('#pop-up-container').css({'width':'100%','height':maskHeight}); 
	}	
}
