/* This function takes 4 args:
1) css - the elements/ids/classes that you want to replace
2) newElement - the type of element you would like to create as a container for the new flash
3) newElementClassName - class name for the new element container
4) flashCSS - name of the CSS style that you would like the flash to read (remember to include # or .)*/


function styleReplacement(orgElement, newElement, newElementClassName, flashCSS, SWF) {
	
	//set default values
	SWF = (typeof SWF == 'undefined') ? 'titles' : SWF;
		
	//creates an array of the element/id/class
	elementArray = $(orgElement);
	flashArray = new Array();
	
	//loops through elementArray, creates a unique flash instance, replaces current element with flash element
	 $(orgElement).each(
	 	function(i) {
	
		if (document.location.protocol == "http:") {
			flash = '<' + newElement + ' class="' + newElementClassName + '"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="100%" height="100%"><param name=wmode VALUE=transparent><param name="movie" value="assets/images/flash/' + SWF + '.swf"><param name="FlashVars" value="Title=' + this.innerHTML + '&flashCSS=' + flashCSS + '"><param name="quality" value="high"><embed src="assets/images/flash/' + SWF + '.swf" FlashVars="Title=' + this.innerHTML + '&flashCSS=' + flashCSS + '" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100%" height="100%"></embed></object></' + newElement + '>';
		
		} else {
			
			flash = '<' + newElement + ' class="' + newElementClassName + '"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="100%" height="100%"><param name=wmode VALUE=transparent><param name="movie" value="assets/images/flash/' + SWF + '.swf"><param name="FlashVars" value="Title=' + this.innerHTML + '&flashCSS=' + flashCSS + '"><param name="quality" value="high"><embed src="assets/images/flash/' + SWF + '.swf" FlashVars="Title=' + this.innerHTML + '&flashCSS=' + flashCSS + '" quality="high" wmode="transparent" pluginspage="https://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100%" height="100%"></embed></object></' + newElement + '>';
		};
		flashArray.push(flash);
	}
	);
	 
	 for (i=elementArray.length-1; i>-1; i--) {
		 $(orgElement).eq(i).replaceWith(flashArray[i]);
	 }
	 
	
		
	
}