var xmlHttp;
function initfunction()
{
	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("whatsHot(1,1)", 1000);
	setTimeout("featuredVideos(1,1)", 1000);
	setTimeout("ajax_JustAdded(1,7)", 1000);
	setTimeout("showVideo1(vid)", 1000);
	setTimeout("handlebottom(0)", 1000);
	setTimeout("ajax_populatecategories(1)", 1000);
	//setTimeout("add_playlist(videoid,pl_cookie)", 1000);
}

//=====================================================
// Our partners section
function our_partner_page(startPage,currentPage)
{
	//alert("videoid="+videoid)
	//alert("navsel="+navsel)
	//loadpage = currentPage + 1
	//document.getElementById("bottompanel").innerHTML="<div align='center' class='grey_12'><br><br><br><br>Loading Page "+currentPage+"</div>";
	document.getElementById("div_our_partners").innerHTML="<div align='center' class='grey_12'><br><br><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='27' height='27' id='loader' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='movie' value='/flash/loader.swf' /><param name='menu' value='false' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='bgcolor' value='#000000' /><embed src='/flash/loader.swf' menu='false' quality='high' wmode='transparent' bgcolor='#000000' width='27' height='27' name='loader' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object><br><br></div>";
	
	var url="http://www.startv.in/advertisers/our_partner.asp?sid=" + Math.random() +"&startPage=" + startPage + "&currentPage=" +currentPage
	//alert(url)
	xmlHttp_our_partner=GetXmlHttpObject(fn_our_partner)
	xmlHttp_our_partner.open("GET", url , true)
	xmlHttp_our_partner.send(null)
	//return true;
}

function fn_our_partner()
{
	if ((xmlHttp_our_partner.readyState==4) || (xmlHttp_our_partner.readyState=="complete"))
	{
		document.getElementById("div_our_partners").innerHTML=xmlHttp_our_partner.responseText
	}
}

//=====================================================
// Add Playlist
function add_playlist_test(videoid,pl_cookie)
{
	//alert("pl_cookie="+pl_cookie)
	//alert("videoid="+videoid)
	//document.getElementById("lbl_playlist").innerHTML="<div align='center' class='grey_12'><br><br>Updating your Playlist...</div>";
	
	var url="http://www.startv.in/advertisers/includes/add_playlist.asp?sid=" + Math.random() +"&videoid=" + videoid + "&pl_cookie=" + pl_cookie
	//alert(url)
	xmlHttp_add_playlist_test=GetXmlHttpObject(playlist_add_test)
	xmlHttp_add_playlist_test.open("GET", url , true)
	xmlHttp_add_playlist_test.send(null)
	//return true;
}

function playlist_add_test()
{
	if ((xmlHttp_add_playlist_test.readyState==4) || (xmlHttp_add_playlist_test.readyState=="complete"))
	{
		document.getElementById("lbl_playlist_test").innerHTML=xmlHttp_add_playlist_test.responseText
	}
}


//=====================================================
// Add Playlist
function add_playlist(videoid,pl_cookie)
{
	//alert("pl_cookie="+pl_cookie)
	//alert("videoid="+videoid)
	//document.getElementById("lbl_playlist").innerHTML="<div align='center' class='grey_12'><br><br>Updating your Playlist...</div>";
	
	var url="http://www.startv.in/advertisers/includes/add_playlist.asp?sid=" + Math.random() +"&videoid=" + videoid + "&pl_cookie=" + pl_cookie
	//alert(url)
	xmlHttp_add_playlist=GetXmlHttpObject(playlist_add)
	xmlHttp_add_playlist.open("GET", url , true)
	xmlHttp_add_playlist.send(null)
	//return true;
}

function playlist_add()
{
	if ((xmlHttp_add_playlist.readyState==4) || (xmlHttp_add_playlist.readyState=="complete"))
	{
		document.getElementById("lbl_playlist").innerHTML=xmlHttp_add_playlist.responseText
	}
}

//=====================================================
// Del Playlist
function del_playlist(videoid,pl_cookie)
{
	//alert("pl_cookie="+pl_cookie)
	//alert("videoid="+videoid)
	//document.getElementById("lbl_playlist").innerHTML="<div align='center' class='grey_12'><br><br>Updating your Playlist...</div>";
	
	var url="http://www.startv.in/advertisers/includes/del_playlist.asp?sid=" + Math.random() +"&videoid=" + videoid + "&pl_cookie=" + pl_cookie
	//alert(url)
	xmlHttp_del_playlist=GetXmlHttpObject(playlist_del)
	xmlHttp_del_playlist.open("GET", url , true)
	xmlHttp_del_playlist.send(null)
	//return true;
}

function playlist_del()
{
	if ((xmlHttp_del_playlist.readyState==4) || (xmlHttp_del_playlist.readyState=="complete"))
	{
		document.getElementById("lbl_playlist").innerHTML=xmlHttp_del_playlist.responseText
	}
}

//=====================================================
// word suggestion
function words_suggest(keyword)
{
	//alert("keywords="+keywords)
	//alert("videoid="+videoid)
	document.getElementById("lbl_suggestions").style.display = "block";
	
	var url="http://www.startv.in/advertisers/suggest_words.asp?sid=" + Math.random() +"&keyword=" + keyword 
	//alert(url)
	xmlHttp_words_suggest=GetXmlHttpObject(suggest_words)
	xmlHttp_words_suggest.open("GET", url , true)
	xmlHttp_words_suggest.send(null)
	//return true;
}

function suggest_words()
{
	if ((xmlHttp_words_suggest.readyState==4) || (xmlHttp_words_suggest.readyState=="complete"))
	{
		document.getElementById("lbl_suggestions").innerHTML=xmlHttp_words_suggest.responseText
	}
}

//=====================================================
// Starplayer Bottom Panel
function bottom_panel(videoid)
{
	//alert("videoid="+videoid)
	//alert("navsel="+navsel)
	//document.getElementById("bottompanel").innerHTML="<div align='center' class='grey_12'><br><br><br><br>Loading...</div>";
	document.getElementById("bottompanel").innerHTML="<div align='center' class='grey_12'><br><br><br><br><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='27' height='27' id='loader' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='movie' value='/flash/loader.swf' /><param name='menu' value='false' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='bgcolor' value='#000000' /><embed src='/flash/loader.swf' menu='false' quality='high' wmode='transparent' bgcolor='#000000' width='27' height='27' name='loader' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object></div>";
	
	var url="http://www.startv.in/advertisers/starplayer_bottompanel.asp?sid=" + Math.random() +"&videoid=" + videoid
	//alert(url)
	xmlHttp_bottom_panel=GetXmlHttpObject(player_bottompanel)
	xmlHttp_bottom_panel.open("GET", url , true)
	xmlHttp_bottom_panel.send(null)
	//return true;
}

function player_bottompanel()
{
	if ((xmlHttp_bottom_panel.readyState==4) || (xmlHttp_bottom_panel.readyState=="complete"))
	{
		document.getElementById("bottompanel").innerHTML=xmlHttp_bottom_panel.responseText
	}
}

//=====================================================
// Bottom Panel pagination
function bottom_panel_page(videoid,navsel,subgenreid,startPage,currentPage)
{
	//alert("videoid="+videoid)
	//alert("navsel="+navsel)
	loadpage = currentPage + 1
	//document.getElementById("bottompanel").innerHTML="<div align='center' class='grey_12'><br><br><br><br>Loading Page "+currentPage+"</div>";
	document.getElementById("bottompanel").innerHTML="<div align='center' class='grey_12'><br><br><br><br><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='27' height='27' id='loader' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='movie' value='/flash/loader.swf' /><param name='menu' value='false' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='bgcolor' value='#000000' /><embed src='/flash/loader.swf' menu='false' quality='high' wmode='transparent' bgcolor='#000000' width='27' height='27' name='loader' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object></div>";
	
	var url="http://www.startv.in/advertisers/starplayer_bottompanel.asp?sid=" + Math.random() +"&videoid=" + videoid +"&navSel=" + navsel +"&subgenreid=" + subgenreid +"&startPage=" + startPage + "&currentPage=" +currentPage
	//alert(url)
	xmlHttp_bottom_panel=GetXmlHttpObject(player_bottompanel)
	xmlHttp_bottom_panel.open("GET", url , true)
	xmlHttp_bottom_panel.send(null)
	//return true;
}

function player_bottompanel()
{
	if ((xmlHttp_bottom_panel.readyState==4) || (xmlHttp_bottom_panel.readyState=="complete"))
	{
		document.getElementById("bottompanel").innerHTML=xmlHttp_bottom_panel.responseText
	}
}

//=====================================================
// load signup
function load_signup()
{
	//alert("videoid="+videoid)
	//alert("navsel="+navsel)
	document.getElementById("signup").innerHTML="<center><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='27' height='20' id='loader' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='movie' value='/flash/loader.swf' /><param name='menu' value='false' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='bgcolor' value='#000000' /><embed src='/flash/loader.swf' menu='false' quality='high' wmode='transparent' bgcolor='#000000' width='27' height='20' name='loader' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object></center>";
	
	var url="http://www.startv.in/advertisers/registration/l1_signup.asp?sid=" + Math.random()
	//alert(url)
	xmlHttp_load_signup=GetXmlHttpObject(signup_load)
	xmlHttp_load_signup.open("GET", url , true)
	xmlHttp_load_signup.send(null)
	//return true;
}

function signup_load()
{
	if ((xmlHttp_load_signup.readyState==4) || (xmlHttp_load_signup.readyState=="complete"))
	{
		document.getElementById("signup").innerHTML=xmlHttp_load_signup.responseText
	}
}
//=====================================================
// email verification
function verify_email(email)
{
	//alert("videoid="+videoid)
	//alert("navsel="+navsel)
	document.getElementById("email_status").innerHTML="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='27' height='20' id='loader' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='movie' value='/flash/loader.swf' /><param name='menu' value='false' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='bgcolor' value='#000000' /><embed src='/flash/loader.swf' menu='false' quality='high' wmode='transparent' bgcolor='#000000' width='27' height='20' name='loader' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";
	
	var url="http://www.startv.in/advertisers/registration/verify_email.asp?sid=" + Math.random() +"&email=" + email 
	//alert(url)
	xmlHttp_verify_email=GetXmlHttpObject(email_verify)
	xmlHttp_verify_email.open("GET", url , true)
	xmlHttp_verify_email.send(null)
	//return true;
}

function email_verify()
{
	if ((xmlHttp_verify_email.readyState==4) || (xmlHttp_verify_email.readyState=="complete"))
	{
		document.getElementById("email_status").innerHTML=xmlHttp_verify_email.responseText
	}
}

//=====================================================
// Captcha verification
function verify_captcha(captcha)
{
	//alert("videoid="+videoid)
	//alert("captcha="+captcha)
	document.getElementById("captcha_status").innerHTML="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='27' height='20' id='loader' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='movie' value='/flash/loader.swf' /><param name='menu' value='false' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='bgcolor' value='#000000' /><embed src='/flash/loader.swf' menu='false' quality='high' wmode='transparent' bgcolor='#000000' width='27' height='20' name='loader' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";
	
	var url = "http://www.startv.in/advertisers/registration/verify_captcha.asp";
	var params = "captcha="+captcha;
	xmlHttp_verify_captcha=GetXmlHttpObject(captcha_verify)
	xmlHttp_verify_captcha.open("POST", url, true);

	//Send the proper header information along with the request
	xmlHttp_verify_captcha.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp_verify_captcha.setRequestHeader("Content-length", params.length);
	xmlHttp_verify_captcha.setRequestHeader("Connection", "close");
	xmlHttp_verify_captcha.send(params);
}

function captcha_verify()
{
	if ((xmlHttp_verify_captcha.readyState==4) || (xmlHttp_verify_captcha.readyState=="complete"))
	{
		document.getElementById("captcha_status").innerHTML=xmlHttp_verify_captcha.responseText
	}
}

//=====================================================
// Sign Up process
function signup_level1(name,email,pwd,emval,captchacode,valSession)
{
	//alert("videoid="+videoid)
	//alert("navsel="+navsel)
	cntPwd=document.regForm.password.value.length
	cntFirstname=document.regForm.firstname.value.length
	if(document.regForm.firstname.value=="")
	{
		alert("Please enter Firstname");
		document.regForm.firstname.focus();
		return false;
	}
	
	if(document.regForm.firstname.value.indexOf(" ") > -1)
	{
		alert("No Space between firstname");
		document.regForm.firstname.value="";
		document.regForm.firstname.focus();
		return false;
	}
	if(cntFirstname > 20)
	{
		alert("Firstname should not be more than 20 charcters.");
		document.regForm.firstname.value="";
		document.regForm.firstname.focus();
		return false;
	}

	if (!(isEmail(document.regForm.email.value))){
		alert("Please enter your valid e-Mail ID");	
		document.regForm.email.value="";
		document.regForm.email.focus();
		return false;
	}
	
	if(emval == 1)
	{
		alert("your e-Mail ID alreaty exist.");	
		document.regForm.email.value="";
		document.regForm.email.focus();
		return false;
	}
	
	if(document.regForm.password.value=="")
	{
		alert("Please enter Password");
		document.regForm.password.focus();
		return false;
	}
	
	if(cntPwd < 4)
	{
		alert("Password should be minimum 4 charcters.");
		document.regForm.password.value="";
		document.regForm.password.focus();
		return false;
	}
	if(document.regForm.password.value.indexOf(" ") > -1)
	{
		alert("No Space in the Password");
		document.regForm.password.value="";
		document.regForm.password.focus();
		return false;
	}
	
	if(document.regForm.captchacode.value == "")
	{
		alert("Please enter Verification Code");
		document.regForm.captchacode.focus();
		return false;
	}
	/*if(imval == 1)
	{
		alert("Verification Code doesn't match");	
		document.regForm.captchacode.value="";
		document.regForm.captchacode.focus();
		return false;
	}*/
	
	
	document.getElementById("signup").innerHTML="<div align='center' class='grey_12'><br><br><br><br><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='27' height='27' id='loader' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='movie' value='/flash/loader.swf' /><param name='menu' value='false' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='bgcolor' value='#000000' /><embed src='/flash/loader.swf' menu='false' quality='high' wmode='transparent' bgcolor='#000000' width='27' height='27' name='loader' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object></div>";
	
	var url = "signup1.asp";
	var params = "name="+name+"&email="+email+"&pwd="+pwd+"&captcha="+captchacode+"&valSession="+valSession;
	//alert(url+"?"+params)
	xmlHttp_signup=GetXmlHttpObject(level1_signup)
	xmlHttp_signup.open("POST", url, true);

	//Send the proper header information along with the request
	xmlHttp_signup.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp_signup.setRequestHeader("Content-length", params.length);
	xmlHttp_signup.setRequestHeader("Connection", "close");
	xmlHttp_signup.send(params);
	
	
	
	
	//var url="http://www.startv.in/starplayer_bottompanel.asp?sid=" + Math.random() +"&videoid=" + videoid +"&navSel=" + navsel +"&subgenreid=" + subgenreid +"&startPage=" + startPage + "&currentPage=" +currentPage
	//alert(url)
	//xmlHttp_bottom_panel=GetXmlHttpObject(player_bottompanel)
	//xmlHttp_bottom_panel.open("GET", url , true)
	//xmlHttp_bottom_panel.send(null)
	//return true;
}

function level1_signup()
{
	if ((xmlHttp_signup.readyState==4) || (xmlHttp_signup.readyState=="complete"))
	{
		document.getElementById("signup").innerHTML=xmlHttp_signup.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;
		*/
	 var Key;

     if(window.event)
          Key = window.event.keyCode;     //IE
     else
          Key = e.which;     //firefox	
    if (Key != 0)
	{
        //alert("Key pressed! ASCII-value: " + Key);
		if (Key==13)
			return false;
		else
			return true;
	}
		
}

} 