

function resizeFlashTitle(who,h)
{
	//alert(who+" : "+h);
	var obj = $(who);
	//alert(obj+":"+h);
	$('#'+who+' object').attr('height',h);
}
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function rgbToHex(rgb) {  
  if(jQuery.browser.msie || jQuery.browser.opera)
  {
	  return(rgb);
  }
  var rgbvals = /rgb\((.+),(.+),(.+)\)/i.exec(rgb);
  var rval = parseInt(rgbvals[1]).toString(16);
  var gval = parseInt(rgbvals[2]).toString(16);
  var bval = parseInt(rgbvals[3]).toString(16);
  if(rval=='0') rval = "00";
  if(gval=='0') gval = "00";
  if(bval=='0') bval = "00";
  return '#' + (rval + gval + bval).toUpperCase();

} 
/*
jQuery.fn.outerHTML = function() {
  return $( $('<p></p>').html(this.clone()) ).html();

} 
*/
(function($) {
 // Returns whether or not a result set has results in it
 $.fn.outerHTML = function() {
	 
   return ($("<p>").append( this.eq(0).clone() ).html());
 };
})(jQuery);

$(document).ready(function() {  
   
    num = 0;
   
   $(".flashTitle").each(function(){
		//alert($(this).attr("class"));
		
		
		var classes = $(this).attr("class");
		$(this).removeClass();
		
		var str = $(this).outerHTML();
		
		$(this).addClass(classes);	
		
		$(this).attr("id", 'flashTitle'+num);

		num++;
		
		str = ltrim(rtrim(str));		
		str = str.replace(/\n/g, "");
		var reg=new RegExp("(</p>)", "g");
		str = str.replace(reg, "<br />$1");
		
		reg=new RegExp("(</P>)", "g");
		str = str.replace(reg, "<br />$1");
		
		//alert(str);
		$(this).flash({  
			// test_flashvars.swf is the flash document  			
			swf: 'swf/flashTitle.swf',
			width:'100%',
			menu:false,
			wmode:'transparent',
			height:20,
			// these arguments will be passed into the flash document   
			flashvars: {  
				id: $(this).attr('id'),  
				bodytext: str,
				css : FlashCSS
				
			}  
		}); 
		
	});
   
   
   num = 0;
	

   
   $("p.H2Title, p.H3Title,p.H4Title, p.H5Title").each(function(){
		//alert($(this).attr("class"));
		
		//$(document.createElement("div")).attr("id","error").text(json.bad).prependTo("body"); 
		
		var classes = $(this).attr("class");
		$(this).removeClass();
		
		//var str = $(this).html();	
		var poil = $(this);
		var str = innerXHTML(this);
		
		$(this).addClass(classes);			
		
		var out = '<span class="'+classes+'">'+str+'</span>';
		
		//str = claune.outerHTML();
		
		$(this).attr("id", 'tinyTitle'+num);

		num++;
		
		
		
		//str = ltrim(rtrim(str));
		out = ltrim(rtrim(out));
		/*
		reg=new RegExp("(<br>)", "g");
		str = str.replace(reg, "<br />$1");
		
		reg=new RegExp("(<BR>)", "g");
		str = str.replace(reg, "<br />$1");
		*/
		//alert(out);
		$(this).flash({  
			// test_flashvars.swf is the flash document  			
			swf: 'swf/flashTitle.swf',
			width:'100%',
			menu:false,
			wmode:'transparent',
			height:20,
			// these arguments will be passed into the flash document   
			flashvars: {  
				id: $(this).attr('id'),  
				bodytext: out,
				css : FlashCSS
				
			}  
		}); 
		
	});
   
   
   num = 0;

	
	
	
   $(".flashInner").each(function(){
		//alert($(this).attr("class"));
		var classes = $(this).attr("class");
		$(this).removeClass();
		
		//var str = $(this).html();
		
		
		
		
		
		
		
		var myElements = $(this).find('*');
		
		//alert(myElements);
		var str = '';
		myElements.each(function(el){
			//alert($(this).html());
			str += '<'+this.tagName+'>'+$(this).html()+'</'+this.tagName+'>';
		});
		
		$(this).addClass(classes);		
		//alert(this.tagName);
		
		
		$(this).attr("id", 'flashInner'+num);

		num++;
		
		
		
		//str = ltrim(rtrim(str));
		//alert(str);
		
		$(this).flash({  
			// test_flashvars.swf is the flash document  			
			swf: 'swf/flashTitle.swf',
			width:'100%',
			menu:false,
			wmode:'transparent',
			height:50,
			// these arguments will be passed into the flash document   
			flashvars: {  
				id: $(this).attr('id'),  
				bodytext: str,
				css : FlashCSS
				
			}  
		}); 
		
	});
   
   
   num = 0;
   
   $(".homeFlashTitle").each(function(){
		//alert($(this).attr("class"));
		var classes = $(this).attr("class");
		$(this).removeClass();		
		var str = $(this).outerHTML();
		$(this).addClass(classes);		
		//alert(str);
		
		
		$(this).attr("id", 'homeFlashTitle'+num);

		num++;
		
		
		
		str = ltrim(rtrim(str));
		$(this).flash({  
			// test_flashvars.swf is the flash document  			
			swf: 'swf/homePageTitle.swf',
			width:'100%',
			menu:false,
			wmode:'transparent',
			//height:50,
			// these arguments will be passed into the flash document   
			flashvars: {  
				id: $(this).attr('id'),  
				bodytext: str
				
			}  
		}); 
		
	});
   
   
  
   
  
   $("a[rel^='tinybox|']").lightBox();
  
   $("input,textarea,select").focus(function () {
         $(this).addClass("focus");
    });
   
   $("input,textarea,select").blur(function () {
         $(this).removeClass("focus");
    });
   
		
 });
