// Specific Javascript for Gore.com  
// Image pop-up layer
// (Unless there is image Enlarge, Text alignment for image caption in 'document' DIV or H2,H3 top margin problems) 

//Cufon Call
function replaceFont() {
//Important: a class=font_replacement is highly recommended to add , in all the html tags where a font replacement will be applied as bellow:
//http://wiki.github.com/sorccu/cufon/api

	Cufon.replace('.font_replacement', {
		hover: true			  
	});


}
//Call replaceFont():
replaceFont();


(function () {
				
				// Zoom  Panels  (enlarge image)
                
				var zoomLinks = YAHOO.util.Dom.getElementsByClassName("zoom");
				
                  var zoomPanel = new YAHOO.widget.Panel("zoomPanel", {
                  		constraintoviewport: true, 
						underlay:"shadow", 
						close:true, 
						visible:false, 
						draggable:false,
						fixedcenter:true,
						modal:true
						
				});
                
                 zoomPanel.render(document.body);
                
				// Loop over zoom links and wire up to panel
				for (var i = 0; zoomLinks[i]; i += 1) {
                		
                        
                    // Create a panel to display zoom image
                    zoomLinks[i].id = 'imagetoenlarge'+i;
                   
					zoomLinks[i].onclick = function (e) {
                    	
                        
                       
                       
						e = e || event;
						zoomPanel.setHeader(this.title);
						zoomPanel.setBody("<img src=" + this.href + " />" );
						
                        
                        
                       
                      

                     
                         		
                              zoomPanel.render(document.body);
							  zoomPanel.show();
							  
							  
							
                        
                        
						YAHOO.util.Event.preventDefault(e);
                        
                       
					};
                   
				}
			})();
           	(function () {
				
				// Text alignment(caption) for "document" tag with image.
                
				var allDocuments = YAHOO.util.Dom.getElementsByClassName("document");
				
				
				for (var i = 0; allDocuments[i]; i += 1) {
                		// FF
				if (typeof window.innerWidth != 'undefined')
                         {
                             
					
  					imageSRC = allDocuments[i].childNodes[1].getAttribute('src');
 					
 				
                         }
                         
                        // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
                        
                         else if ( typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !='undefined' && document.documentElement.clientWidth != 0)
                         {
                              imageSRC = allDocuments[i].childNodes[0].getAttribute('src');
                         }					
				
                         else
                         {
                               imageSRC = allDocuments[i].childNodes[1].getAttribute('src');
                         }

				var newImg = new Image();
				newImg.src = imageSRC;
			
				var thewidth = newImg.width;
				if (thewidth != 0){
				for (var j = 0; allDocuments[i].childNodes[j]; j += 1) {
					if (allDocuments[i].childNodes[j].nodeType == 1){
						if (allDocuments[i].childNodes[j].className == 'pdf' || allDocuments[i].childNodes[j].className == 'zip' || allDocuments[i].childNodes[j].className == 'enlarge' ){
							allDocuments[i].childNodes[j].style.width = thewidth - 21 +"px";
						} else { 
							allDocuments[i].childNodes[j].style.width = thewidth +"px";
						}
						
					}
				}
				 
				}

				
               }
                
			})();
			
  		(function () {
				
				// Share this page POPUP
                
				var sendToFriendLinks = YAHOO.util.Dom.getElementsByClassName("sharePage");
				
                  var sendToFriend = new YAHOO.widget.Panel("sendToFriend", {
                  		constraintoviewport: true, 
						underlay:"shadow", 
						close:true, 
						visible:false, 
						draggable:false,
						fixedcenter:true,
						width:"450px",
						modal:true
						
				});
                
                 sendToFriend.render(document.body);
                
				// Loop over zoom links and wire up to panel
				for (var i = 0; sendToFriendLinks[i]; i += 1) {
                		
                        
                   
					sendToFriendLinks[i].onclick = function (e) {
                    	
                        
                     e = e || event;
                        
			
                         		
                              sendToFriend.render(document.body);
							  sendToFriend.show();
							
						
     
						YAHOO.util.Event.preventDefault(e);
                        
                       
					};
                   
				}
			})();
        


	

