function ajaxFunction1()
{
	var xmlHttp1;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp1=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp1=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp1=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return xmlHttp1;
}
var filter_content1="";
var getR1;
var selfURL1 = document.location.href;

var req1 = ajaxFunction1();
if (req1) {
	req1.onreadystatechange = processStateChange1;
    req1.open("GET",selfURL1, true);
    req1.send(null);
}

function processStateChange1(){
		if (req1.readyState == 4){
		var strpos1 = '';
		scontent1 = req1.responseText;
		strpos1 = scontent1.indexOf('Tags:');
		var nst1 = parseInt(strpos1)+13;
		if(parseInt(strpos1) <= 0 )
		{
			strpos1 = scontent1.indexOf('Topics:');
			nst1 = parseInt(strpos1)+15;
		}

		var endpos1 = scontent1.indexOf("</p>",nst1);
		var cid1 = document.getElementById('cat-ids').value;
		filter_content1 = strip_tags1(scontent1.substring(nst1,endpos1));
		getVideosResponse1(filter_content1,cid1);
	}
}

function trimString1(String){
	if (String == null){return ("");}
	return String.replace(/(^\s+)|(\s+$)/g,"");
}
function getVideosResponse1(fcontent1,cid1)
{
	getR1 = ajaxFunction1();
	if (getR1) {
		fcontent1=trimString1(fcontent1);
		fcontent1 = fcontent1.replace(/(,\s+)/g,",");
		fcontent1 = fcontent1.replace(/(.$)/g,"");

		getR1.onreadystatechange = getReponse1;
	    getR1.open("GET","/common/js/getVideos.php?tags="+fcontent1+"&cat-ids="+cid1, true);
		
    	getR1.send(null);
	}
}

function getReponse1()
{
	var origCnt1="";
	if (getR1.readyState == 4){
		if(getR1.responseText.length > 1) {
			restext1 = getR1.responseText;
			//alert(restext);
			document.getElementById('related_videos_content').innerHTML = restext1;
		}
	}
}





//Strip html tags
function strip_tags1( str ){
    return str.replace(/<\/?[^>]+>/gi, '');
}


