var xmlhttp = false;

if (!xmlhttp) 
{
	if (window.XMLHttpRequest) 
	{ 
		xmlhttp=new XMLHttpRequest(); 
	} 
	else 
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	}
	 
	if (!xmlhttp) 
	{
		alert("Your browser doesn't support AJAX.");
	}
}



/********* TO SEND MAIL **********/

function sendEmail(name, email, femail, link)
{
	//alert("AICI1");
    if(!xmlhttp)
    {
        //alert("Ajax not active!");
        return;
    }
    
	//alert("AICI1");
    xmlhttp.open("GET", "http://www.flabell.com/projects/livecast/js/sendmail.php?name=" + name + "&email=" + email + "&femail=" + femail + "&link=" + link , true);
    
    xmlhttp.onreadystatechange = function ()
    {
 		if (xmlhttp.readyState == 4)
 		{
 	   		//document.getElementById('result').innerHTML = xmlhttp.responseText;
	   		//alert(xmlhttp.responseText);
	   		callReceiveFlashFunction(xmlhttp.responseText);
	   		return xmlhttp.responseText;
		}
	};
    xmlhttp.send(null);    	
}

function callReceiveFlashFunction(error) 
{
	var flash = document.getElementById("flashMovieId");
	flash.receiveMessage(error);
}


/******* TO GET A FLV PATH FROM A YOUTUBE LINK *******/
function getFLV(select)
{
	//alert("AICI1");
    if(!xmlhttp)
    {
        alert("Ajax not active!");
        return;
    }

    xmlhttp.open("GET", "js/download.php?link=" + select , true);
    
    xmlhttp.onreadystatechange = function ()
    {
 		if (xmlhttp.readyState == 4)
 		{
 	   		//document.getElementById('result').innerHTML = xmlhttp.responseText;
	   		//alert(xmlhttp.responseText);
	   		callFlashFunction(xmlhttp.responseText);
	   		return xmlhttp.responseText;
		}
	};
    xmlhttp.send(null);
}

function getFlashMovieObject(movieName)
{ 
	if(document.embeds[movieName])
		return document.embeds[movieName];
	
	if(window.document[movieName])
		return window.document[movieName];
	
	if(window[movieName])
		return window[movieName];
	
	if(document[movieName])
		return document[movieName];
	
	return null;
}

function callFlashFunction(flvUrl) 
{
	var flash = document.getElementById("flashMovieId");
	flash.callStartFlv(flvUrl);
}






