
/*
	
	addWMode() - Adds wmode attribute and parameter to flash video embed code




*/

// START 	----------------------------------------------------------------------------------------------------------------------------	
// END 		----------------------------------------------------------------------------------------------------------------------------	


// START 	----------------------------------------------------------------------------------------------------------------------------	addWMode()

function addWMode(sVideo)//Adds wmode attribute and parameter to flash video embed code
{
	var splitVideo = null;
	
	if(sVideo.indexOf('name="wmode"') == -1)//If wmode has not been added as a param child of the object tag
	{
		splitVideo = sVideo.split(/\/param\>/gi);//split string according to 'param'
				
		for(var i = (splitVideo.length - 1); i > -1; i--)//Loop through array in reversed order
		{
			if(splitVideo[i].indexOf('param') != -1)//When 'param' is found
			{
				splitVideo.splice(i,0,'<param name="wmode" value="transparent"><');//Add wmode param to array
				break;	
			}
		}
		sVideo = splitVideo.join('/param>');//Rejoin
	}
			
	if(sVideo.indexOf('embed') != -1 && sVideo.indexOf('wmode=') == -1)//If wmode has not been added as a parameter to the embed tag
	{
		splitVideo = sVideo.split('embed');//split ccording to 'embed'
		splitVideo[1] = ' wmode="transparent" ' + splitVideo[1];//Add wmode param	
		sVideo = splitVideo.join('embed');//Rejoin accroding to embed
	}
	return(sVideo);	
}


// END 		----------------------------------------------------------------------------------------------------------------------------	addWMode()
