//must be used in conjunction with QTObject script, otherwise nothing will happen

function embedmyQTObjects() {
	var qtcontainer = new Array(), qtCount = 0, allDivs = document.getElementsByTagName('div');
	
	for(var i = 0; i<allDivs.length; i++){
		if(allDivs[i].className =='video'){
			qtcontainer[qtCount] = allDivs[i];
			qtCount++;
		}
	}
	
	if( qtcontainer.length > 0 && typeof(QTObject) == 'function' ){ //test for presence of element, and function
		//loop through array of matched containers
		for(var i = 0; i<qtcontainer.length; i++){
			//get attributes of the container to define sfw src, dims, etc
			var thisinfo = stripSpaces(qtcontainer[i].id);
			var qtinfo = thisinfo.split('__'); // pattern is [path]__[width]__[height]
			var qtpath = 'cmsvideo/'+qtinfo[0]+'.mov', qtwidth = qtinfo[1], qtheight = qtinfo[2];
			var myQTObject = new QTObject(qtpath, 'QTObject_instance'+i, qtwidth, qtheight, 'autostart', 'false');
			myQTObject.write();
		}
	} else {
		//do nothing
	}
	function stripSpaces(string){
		while(string.indexOf(' ') != -1){
			string = string.replace(' ', '');
		}
		return string;
	}
}

//always check to see if the addLoadEvent function exists before trying to call it!
if(typeof addLoadEvent == 'function'){
	addLoadEvent(embedmyQTObjects);
}
