var xmlHttp;
function initfunction()
{
	//alert("hi");
	var1=window.location.href;
	myvar=var1.split("?")
	//alert(myvar.length)
	if (myvar.length==2)
	{
		myvar2=myvar[1].split("=")
		vid=myvar2[1];
	}
	else
	{
		vid=0
	}
	setTimeout("get_relatedvideos(vid)", 1000)
	setTimeout("showVideo1(vid)", 1000);
	
}
function showVideo1(vid)
{
	//alert(vid)
	screen_width=1024
	//var url="detect.asp?sid=" + Math.random() +"&videoid=" + vid +"&screen_width=" + screen_width
	var url="playvideo.asp?sid=" + Math.random() +"&videoid=" + vid +"&screen_width=" + screen_width
	//alert(url)
	xmlHttp_PlayVideo=GetXmlHttpObject(getPlayVideo)
	xmlHttp_PlayVideo.open("GET", url , true)
	xmlHttp_PlayVideo.send(null)
	return true;
}

function get_relatedvideos(vid)
{
	section_id=2;
	cat_id=30;
	subcat_id=602
	//alert("hi11111");
	var url="getRelVideos.asp?sid=" + Math.random() + "&section_id=" +section_id+ "&cat_id=" +cat_id+ "&subcat_id=" +subcat_id+"&vdo_limit=7"
	//alert (url)
	xmlHttp_RelVideos=GetXmlHttpObject(getRelVideos)
	xmlHttp_RelVideos.open("GET", url , true)
	xmlHttp_RelVideos.send(null)
	return true;
}

function getRelVideos()
{
	if ((xmlHttp_RelVideos.readyState==4) || (xmlHttp_RelVideos.readyState=="complete"))
	{
		document.getElementById("RelVideos_div").innerHTML=xmlHttp_RelVideos.responseText
	}
}



//=====================================================
// Get More Releated videos
function getMoreRelVdos(section_id,cat_id,subcat_id)
{
	document.getElementById("RelVideos_div").innerHTML="<div align='center'><br><br><img src='images/loading1.gif' alt='' width='45' height='5' border='0'></div>";
	//document.getElementById("dyn_heading_div").innerHTML="<div align='left'>"+heading+"</div>";

	var url="getRelVideos_more.asp?sid=" + Math.random() + "&section_id=" +section_id+ "&cat_id=" +cat_id+ "&subcat_id=" +subcat_id+"&vdo_limit=7"
	//alert (url)
	xmlHttp_MoreRelVideos=GetXmlHttpObject(getMoreRelVideos)
	xmlHttp_MoreRelVideos.open("GET", url , true)
	xmlHttp_MoreRelVideos.send(null)
	return true;
}

function getMoreRelVideos()
{
	if ((xmlHttp_MoreRelVideos.readyState==4) || (xmlHttp_MoreRelVideos.readyState=="complete"))
	{
		document.getElementById("RelVideos_div").innerHTML=xmlHttp_MoreRelVideos.responseText
	}
}


//=====================================================



//=====================================================
// Get Releated Paging
function ajax_GetRelVideo_page(subcat_id,page,heading,vdo_limit)
{
		
	//alert(cat_id);
	document.getElementById("rel_Videos_div").innerHTML="<div align='center'><br><br><img src='images/loading1.gif' alt='' width='45' height='5' border='0'></div>";
	//document.getElementById("dyn_heading_div").innerHTML="<div align='left'>"+heading+"</div>";

	var url="getRelVideos.asp?sid=" + Math.random() + "&section_id=" +section_id+ "&cat_id=" +cat_id+ "&subcat_id=" +subcat_id+"&vdo_limit=7&Page="+page
	//alert (url)
	xmlHttp_RelVideos_page=GetXmlHttpObject(getRelVideos_page)
	xmlHttp_RelVideos_page.open("GET", url , true)
	xmlHttp_RelVideos_page.send(null)
	return true;
}
function getRelVideos_page()
{
	if ((xmlHttp_RelVideos_page.readyState==4) || (xmlHttp_RelVideos_page.readyState=="complete"))
	{
		document.getElementById("rel_Videos_div").innerHTML=xmlHttp_RelVideos_page.responseText
	}
}
//=====================================================


//show video


function showVideo(vid)
{
	//alert(vid)
	screen_width=1024;
	var url="playvideo.asp?sid=" + Math.random() +"&videoid=" + vid+"&play_status=yes"+"&screen_width=" + screen_width
	//alert(url)
	window.scrollTo(0,0);
	//alert("here");
	xmlHttp_PlayVideo=GetXmlHttpObject(getPlayVideo)
	xmlHttp_PlayVideo.open("GET", url , true)
	xmlHttp_PlayVideo.send(null)
	return true;
}

function getPlayVideo()
{
	if ((xmlHttp_PlayVideo.readyState==4) || (xmlHttp_PlayVideo.readyState=="complete"))
	{
		document.getElementById("videoplayer").innerHTML=xmlHttp_PlayVideo.responseText
	}
}


/************************************************************************/
//do not change this code
function GetXmlHttpObject(handler)
{
	//alert(handler);
    var objXmlHttp=null
 
    if (navigator.userAgent.indexOf("Opera")>=0)
    {
        alert("Opera not supported...")
        return;
    }
    if (navigator.userAgent.indexOf("MSIE")>=0)
    {
        var strName="Msxml2.XMLHTTP"
        if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
        {
            strName="Microsoft.XMLHTTP"
        }
        try
        {
            objXmlHttp=new ActiveXObject(strName)
            objXmlHttp.onreadystatechange=handler
            return objXmlHttp
        }
        catch(e)
        {
            alert("Error. Scripting for ActiveX might be disabled")
            return
        }
    }
    if (navigator.userAgent.indexOf("Mozilla")>=0)
    {
        objXmlHttp=new XMLHttpRequest()
        objXmlHttp.onload=handler
        objXmlHttp.onerror=handler
        return objXmlHttp
    }
}




//for enter key

function kp_enterkey()
{
	if (document.layers) document.captureEvents(Event.KEYPRESS); // needed if you wish to cancel the key

document.onkeypress = keyhandler;
function keyhandler(e) 
{
    if (document.layers)
        Key = e.which;
    else
        Key = window.event.keyCode;
    if (Key != 0)
	{
        //alert("Key pressed! ASCII-value: " + Key);
		if (Key==13)
			return false;
		else
			return true;
	}
		
}

} 