
function samiGetStyleCommentBlock(xml)
{
	var s = xmlGetString(xml);
	var start = s.indexOf("<!--")+4;
	var end = s.indexOf("-->");
	return s.slice(start,end);
}

function samiGetLanguageCount(xml)
{
	var s =samiGetStyleCommentBlock(xml);
	var lines = s.replace(/^\s+|\s+$/g,"").split("\n");
	return lines.length;
}

function samiGetLanguageName(xml,index)
{
	var s =samiGetStyleCommentBlock(xml);
	var lines = s.replace(/^\s+|\s+$/g,"").split("\n");
	var start = lines[index].indexOf("name:")+5;
	var end = start+lines[index].substr(start,lines[index].length-start).indexOf(";");
	return lines[index].slice(start,end).replace(/^\s+|\s+$/g,"");
}	

function samiGetLanguageCode(xml,index)
{
	var s =samiGetStyleCommentBlock(xml);
	var lines = s.replace(/^\s+|\s+$/g,"").split("\n");
	var start = lines[index].indexOf("lang:")+5;
	var end = start+lines[index].substr(start,lines[index].length-start).indexOf(";");
	return lines[index].slice(start,end).replace(/^\s+|\s+$/g,"");
}

function samiGetCaptionCount(xml)
{
	return xml.getElementsByTagName("P").length;


}

function samiGetCaptionLanguageCode(xml,index)
{
	return xml.getElementsByTagName("P")[index].getAttribute("class").replace(".","");

}

function samiGetCaptionTime(xml,index)
{
	var mstime = xml.getElementsByTagName("P")[index].parentNode.getAttribute("Start");
	var stime = Number(mstime)/1000;
	return stime;
}

function samiGetCaptionText(xml,index)
{
	if(xml.getElementsByTagName("P")[index].firstChild)
		return xml.getElementsByTagName("P")[index].firstChild.nodeValue;
	else
		return "";
}
