
var changeState = 1;
var bgimg = "/schema/gifs/hoverfadebg.png";
var bgimgIE6 = "/schema/gifs/hoverfadebg.gif";
var bgimgIE7plus = "/schema/gifs/hoverfadeIEbg.png";
var isIE6 = 0;
var isIE7plus = 0;
	
function setchange(state) {
	changeState = state;
}
		

function previousObject(obj) {
  do obj = obj.previousSibling;
	while (obj && obj.nodeType != 1);
	return obj;
}


 function hoverBG(td, img, state, show) {
				if (state ==1) {
				  if ((td.style.backgroundImage == '') || (td.style.backgroundImage == 'none')) { td.style.backgroundImage = 'url('+img+')'; }					
					var thePs=td.getElementsByTagName('p');
					if (show == 1) {
								for (var i=0; i<thePs.length; i++) {
									if (thePs[i].className == 'comingsoon') {								
										thePs[i].style.visibility = 'visible';
									}
								}
					}					
				}
				else if (changeState == 1) {
				  td.style.backgroundImage = 'none';				
					var thePs=td.getElementsByTagName('p');
					if (show == 1) {
								for (var i=0; i<thePs.length; i++) {
									if (thePs[i].className == 'comingsoon') {									
										thePs[i].style.visibility = 'hidden';
									}
								}
					}						
				}						
 }
 function hoverfadeBG(td, img, state, imageobject, opacity) {
	  if (state == 1) {
      if (isIE6 || isIE7plus) {
				if (opacity == 100) {
					  if (isIE7plus) {
					    imageobject.src = imageobject.src.substring(0,imageobject.src.indexOf("_r")) + ".png";
						}
						else {
					    imageobject.src = imageobject.src.substring(0,imageobject.src.indexOf("_r")) + ".gif";							
							//imageobject.innerHTML = '';
						}
				}
				else {
					  if (isIE7plus) {
					    imageobject.src = imageobject.src.substring(0,imageobject.src.indexOf(".png")) + "_r.png";
						}
						else {
					    imageobject.src = imageobject.src.substring(0,imageobject.src.indexOf(".gif")) + "_r.gif";							
							//imageobject.innerHTML = '<img src="'+bgimgIE6+'">';
						}
				}				
			}
			else {
				changeopacity(imageobject, opacity);
			}
			if (!isIE6 && !isIE7plus) {
			  hoverBG(td, img, state, 1);
			}
		}
		else if (changeState == 1) {
      if (isIE6 || isIE7plus) {
				if (opacity == 100) {
					  if (isIE7plus) {
					    imageobject.src = imageobject.src.substring(0,imageobject.src.indexOf("_r")) + ".png";
						}
						else {
					    imageobject.src = imageobject.src.substring(0,imageobject.src.indexOf("_r")) + ".gif";								
							//imageobject.innerHTML = '';							
						}
				}
				else {
					  if (isIE7plus) {
					    imageobject.src = imageobject.src.substring(0,imageobject.src.indexOf(".png")) + "_r.png";
						}
						else {
					    imageobject.src = imageobject.src.substring(0,imageobject.src.indexOf(".gif")) + "_r.gif";									
							//imageobject.innerHTML = '<img src="'+bgimgIE6+'">';							
						}
				}				
			}			
			else {
				changeopacity(imageobject, opacity);
			}
		}
 }
 

    function changeopacity( imageobject, opacity, state ) {
				state = 1;
        if (state == 1) {
								var object = imageobject.style;
												
				
								object.opacity = ( opacity / 100 );
				
								object.MozOpacity = ( opacity / 100 );
				
								object.KhtmlOpacity = ( opacity / 100 );
				
								object.filter = "alpha(opacity=" + opacity + ")";

				}

    }
	
	function setImageFades(){
		
		  if ((jQuery.browser.msie) && (parseInt(jQuery.browser.version) == 6)) { isIE6 = 1; bgimg = bgimgIE6; }  // IE6
			
		  if ((jQuery.browser.msie) && (document.all && !window.opera && window.XMLHttpRequest)) {
				 isIE6 = 0;
			   isIE7plus = 1;
			}  // IE7
			
			// sort out some positioning
			if ($.browser.chrome || $.browser.safari) {
				$('p.linktext2').each(function(){
						$(this).css({ top:"-18px"});
				});
				
				$('td.hover').each(function(){
						var h = $(this).html();
						if (h.indexOf('linktext2') != -1) {
							var c = $(this).children();
							c[1].firstChild.firstChild.style.top = "2px";
						}
				});					
				
				$('td.hoverfade').each(function(){
						var h = $(this).html();
						if (h.indexOf('linktext2') != -1) {
							var c = $(this).children();
							c[1].firstChild.style.top = "2px";
						}
				});
				
			
				
			}
		
			// set up mouseovers for hover class
			$('td.hover').mouseover(function() {
				hoverBG(this, bgimg, 1);			
			});
			
			$('td.hover p.linktext').mouseover(function() {
				setchange(0);
				hoverBG(this.parentNode, bgimg, 1);
			});
			
			$('td.hover img').mouseover(function() {
				//setchange(1);
			  //hoverBG(this.parentNode.parentNode, bgimg,1);					
			})
			
			// set up mouseouts for hoverfade class
			$('td.hover').mouseout(function() {
				hoverBG(this, bgimg, 0);			
			});
			
			$('td.hover p.linktext').mouseout(function() {
				setchange(1); 
			});
			
			$('td.hover img').mouseout(function() {					
			  hoverBG(this.parentNode.parentNode,'',0);
			})		
			
			// set up mouseovers for hoverfade class
			$('td.hoverfade').mouseover(function() {
				if (!isIE6 && !isIE7plus) {
				  hoverBG(this, bgimg, 1);
				}
			});
			
			$('td.hoverfade img').mouseover(function() {			
				hoverfadeBG(this.parentNode.parentNode, bgimg, 1, this, 20);
			});	
			
			
			
			$('td.hoverfade p.linktext').mouseover(function() {
				setchange(0);
				hoverfadeBG(this.parentNode, bgimg, 1, previousObject(this).firstChild, 20);						
			});
			
			// set up mouseouts for hoverfade class
			$('td.hoverfade').mouseout(function() {
				if (!isIE6 && !isIE7plus) {				
				   hoverBG(this, '', 0);
				}
			});
			
			$('td.hoverfade img').mouseout(function() {
  			hoverfadeBG(this.parentNode.parentNode, bgimg, 1, this, 100);
			})
		
			
			$('td.hoverfade p.linktext').mouseout(function() {
				setchange(1);					
				//hoverfadeBG(this.parentNode, bgimg, 1, previousObject(this).firstChild, 100);
			});

		
	}
	
	(function($) {
    var userAgent = navigator.userAgent.toLowerCase();

    $.browser = {
        version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
        safari: /webkit/.test( userAgent ),
        opera: /opera/.test( userAgent ),
        msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
        mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
				
    };
		
    $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());		
		if ($.browser.chrome) {
			$.browser.safari = false;
			
      //Add the version number
      userAgent = userAgent.substring(userAgent.indexOf('chrome/') +7);
      userAgent = userAgent.substring(0,1);			
      $('body').addClass('browserChrome') // + userAgent);
		}
		
    if($.browser.safari){
        $('body').addClass('browserSafari');
        
        // Add the version number
        userAgent = userAgent.substring(userAgent.indexOf('version/') +8);
        userAgent = userAgent.substring(0,1);
        $('body').addClass('browserSafari') // + userAgent);
    }


})(jQuery);


