/* ---------------------------- */
/* XMLHTTPRequest Enable */
/* ---------------------------- */
function createObject() {
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}

var http = createObject();
var http1 = createObject();
var http2 = createObject();
var http3 = createObject();
var http4 = createObject();
var http5 = createObject();
var http7 = createObject();
var http_Email = createObject();
/* -------------------------- */
/* LOGIN */
/* -------------------------- */
/* Required: var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */
var nocache = 0;
function videofun(vid,id) { 
document.getElementById('category1').innerHTML = "Loading..."
nocache = Math.random();
http.open('get', 'showvideo_cat.php?vid_id='+vid+'&cat_id='+id+'&nocache = '+nocache);
http.onreadystatechange = loginReply;
http.send(null);
}

function loginReply() {
if(http.readyState == 4){
var response = http.responseText;
if(response == 0){
document.getElementById('category1').innerHTML = 'Please try again';
// else if login is ok show a message: "Welcome + the user name".
} else {
document.getElementById("category2").style.display="none";
document.getElementById("category3").style.display="none";
document.getElementById("category1").style.display="";
document.getElementById('category1').innerHTML = response;
}
}
}


function videofun1(vid1,id1) {
// Optional: Show a waiting message in the layer with ID ajax_response
document.getElementById('category2').innerHTML = "Loading..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
//alert(id);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
if(id1=='2'){
http1.open('get', 'xmlcodegenfitness.php?vid_id='+vid1+'&nocache = '+nocache);
}
http1.onreadystatechange = loginReply1;
http1.send(null);
}
function loginReply1() {
if(http1.readyState == 4){
var response1 = http1.responseText;
//alert(response1);
if(response1 == 0){
// if login fails
document.getElementById('category2').innerHTML = 'Calculation Failed! Verify again for the same';
// else if login is ok show a message: "Welcome + the user name".
} else {
document.getElementById("category1").style.display="none";
document.getElementById("category3").style.display="none";
document.getElementById("category2").style.display="";
document.getElementById('category2').innerHTML = response1;
}
}
}

function videofun2(vid2,id2) {
	
// Optional: Show a waiting message in the layer with ID ajax_response
document.getElementById('category3').innerHTML = "Loading..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
//alert(vid2);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
if(id2=='3'){
http2.open('get', 'xmlcodegenyoga.php?vid_id='+vid2);
}
http2.onreadystatechange = loginReply2;
http2.send(null);
}
function loginReply2() {
if(http2.readyState == 4){
var response2 = http2.responseText;
//alert(response2);
if(response2 == 0){
// if login fails
document.getElementById('category3').innerHTML = 'Calculation Failed! Verify again for the same';
// else if login is ok show a message: "Welcome + the user name".
} else {
document.getElementById("category1").style.display="none";
document.getElementById("category2").style.display="none";
document.getElementById("category3").style.display="";
document.getElementById('category3').innerHTML = response2;
}
}
}

function tabfundiet(cat) {
	
/////////////////////////////////////////////////////////////////////////////////////
//////////Function on Tab Diet of video section on index page///////////////////////
////////////////////////////////////////////////////////////////////////////////////
// Optional: Show a waiting message in the layer with ID ajax_response
document.getElementById('category1').innerHTML = "Loading..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
//alert(cat);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http3.open('get', 'showvideo.php?vid='+cat+'&nocache = '+nocache);

http3.onreadystatechange = loginReply3;
http3.send(null);
}
function loginReply3() {
if(http3.readyState == 4){
var response3 = http3.responseText;
//alert(response3);
if(response3 == 0){
// if login fails
document.getElementById('category1').innerHTML = 'Calculation Failed! Verify again for the same';
// else if login is ok show a message: "Welcome + the user name".
} else {
document.getElementById("category1").style.display="";
document.getElementById("category2").style.display="none";
document.getElementById("category3").style.display="none";
document.getElementById('category1').innerHTML = response3;
}
}
}

/////////////////////////////////////////////////////////////////////////////////////
//////////Function on Tab Fitness of video section on index page///////////////////////
////////////////////////////////////////////////////////////////////////////////////
function tabfunfit(cat) {
// Optional: Show a waiting message in the layer with ID ajax_response
document.getElementById('category2').innerHTML = "Loading..."
// Set te random number to add to URL request
nocache = Math.random();
//alert(cat);
// Pass the login variables like URL variable
http4.open('get', 'showvideo.php?vid='+cat+'&nocache = '+nocache);
http4.onreadystatechange = loginReply4;
http4.send(null);
}
function loginReply4() {
if(http4.readyState == 4){
var response4 = http4.responseText;
//alert(response4);
if(response4 == 0){
// if login fails
document.getElementById('category2').innerHTML = 'Calculation Failed! Verify again for the same';
// else if login is ok show a message: "Welcome + the user name".
} else {
document.getElementById("category2").style.display="";
document.getElementById("category1").style.display="none";
document.getElementById("category3").style.display="none";
document.getElementById('category2').innerHTML = response4;
}
}
}

/////////////////////////////////////////////////////////////////////////////////////
//////////Function on Tab Yoga of video section on index page///////////////////////
////////////////////////////////////////////////////////////////////////////////////
function tabfunyoga(cat) {
// Optional: Show a waiting message in the layer with ID ajax_response
document.getElementById('category1').innerHTML = "Loading..."
// Set te random number to add to URL request
//alert(cat);
nocache = Math.random();
// Pass the login variables like URL variable
http5.open('get', 'showvideo.php?vid='+cat+'&nocache = '+nocache);
http5.onreadystatechange = loginReply5;
http5.send(null);
}
function loginReply5() {
if(http5.readyState == 4){
var response5 = http5.responseText;
//alert(response5);
if(response5 == 0){
// if login fails
document.getElementById('category3').innerHTML = 'Calculation Failed! Verify again for the same';
// else if login is ok show a message: "Welcome + the user name".
} else {
document.getElementById("category3").style.display="";
document.getElementById("category2").style.display="none";
//document.getElementById("category1").style.display="none";
document.getElementById('category1').innerHTML = response5;
}
}
}


///////////////Function for showing article page from left panel.////////////////

function showarticle(cat) { 

nocache = Math.random();
http7.open('get', 'showarticle.php?cat='+cat+'&nocache = '+nocache);
http7.onreadystatechange = showarticles;

http7.send(null);
}
function showarticles() 
{ 
	if(http7.readyState == 4)
	{
		var response7 = http7.responseText;
		document.getElementById('articlecontent').innerHTML = response7
	}
}

////////////////////////////////////////////////////////////////////////////////

function ajax_videoplay(vid2,id2) {
	
// Optional: Show a waiting message in the layer with ID ajax_response
document.getElementById("video1_aaa").innerHTML = "";
document.getElementById('play_video').innerHTML = "Loading..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
//alert(vid2);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http2.open('get', 'xmlgen.php?vid_id='+vid2+'&cat_id='+id2+'&nocache='+nocache);

http2.onreadystatechange = videoplay_Reply;
http2.send(null);
}
function videoplay_Reply() {
if(http2.readyState == 4){
var response2 = http2.responseText;
//alert(response2);
if(response2 == 0){
// if login fails
document.getElementById('play_video').innerHTML = 'Calculation Failed! Verify again for the same';
// else if login is ok show a message: "Welcome + the user name".
} else {
	nocache = Math.random();
	var abc="<div id=\""+nocache+"\"><object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"500\" height=\"450\" id=\"FLV_Player"+nocache+"\" align=\"middle\"><param name=\"allowScriptAccess\" value=\"sameDomain\" /><param name=\"movie\" value=\"FLV_Player1.swf?id="+nocache+"\" /><param name=\"quality\" value=\"high\" /><param name=\"allowFullScreen\" value=\"true\"><param name=\"bgcolor\" value=\"#ffffff\" /><PARAM NAME=\"WMODE\" VALUE=\"transparent\"><embed src=\"FLV_Player1.swf?id="+nocache+"\" quality=\"high\" bgcolor=\"#ffffff\" width=\"500\" height=\"450\" name=\"FLV_Player\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" WMODE=\"transparent\" allowFullScreen=\"true\" /></object></div>";
document.getElementById("play_video").innerHTML = "";
document.getElementById("play_video").style.display="none";
document.getElementById("play_video").style.display="";
document.getElementById("play_video").innerHTML = response2;
//alert(abc);
//document.getElementById("video1_aaa").innerHTML = abc;

}
}
}


function ajax_videoEmail(vid2,id2,to,from,url) {
// Optional: Show a waiting message in the layer with ID ajax_response
document.getElementById('txt_comment').innerHTML = "Loading..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
//alert(vid2);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http_Email.open('get', 'mail_video.php?vid_id='+vid2+'&cat_id='+id2+'&to='+to+'&from='+from+'&url='+url+'&nocache='+nocache);

http_Email.onreadystatechange = videoplay_Reply1;
http_Email.send(null);
}
function videoplay_Reply1() {
if(http_Email.readyState == 4){
var response2 = http_Email.responseText;
//alert(response2);
if(response2 == 0){
// if login fails
document.getElementById('txt_comment').innerHTML = 'Mail Sending Failed! Please Try again.';
// else if login is ok show a message: "Welcome + the user name".
} else {
document.getElementById("txt_comment").style.display="";
document.getElementById("txt_comment").innerHTML = response2;
document.getElementById("emailid").value = "";
document.getElementById("mail").value = "";
}
}
}

function ajax_homeopathy(id2) {
// Optional: Show a waiting message in the layer with ID ajax_response
document.getElementById('hm_TabbedPanels1').innerHTML = "Loading..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
//alert(vid2);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http2.open('get', 'Homeopathy_ajax.php?id='+id2+'&nocache='+nocache);
http2.onreadystatechange = homeopathy_Reply;
http2.send(null);
}
function homeopathy_Reply() {
if(http2.readyState == 4){
var response2 = http2.responseText;
//alert(response2);
if(response2 == 0){
// if login fails
document.getElementById('hm_TabbedPanels1').innerHTML = 'Calculation Failed! Verify again for the same';
// else if login is ok show a message: "Welcome + the user name".
} else {
document.getElementById("hm_TabbedPanels1").style.display="";
document.getElementById("hm_TabbedPanels1").innerHTML = response2;
var TabbedPanels1 = new Spry.Widget.TabbedPanels("hm_TabbedPanels1");
}
}
}