// JavaScript Document
//var ourInterval = setInterval("showHiddenDiv()", 4000);

function hideshow()
{
	try
	  {// Firefox, Opera 8.0+, Safari, IE7
	  xmlHttp=new XMLHttpRequest();
	  }
	catch(e)
	  {// Old IE
	  try
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  catch(e)
		{
		alert ("Your browser does not support XMLHTTP!");
		return;  
		}
	  }
	var vid;  
	vid=document.getElementById('vid').value;
	var url="showvideonew.php?vid=" + vid;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	clearInterval(ourInterval);
		document.getElementById("subcontent2").className="FlashVideoRight";
	document.getElementById("subcontent").className="FlashVideoThumbsActive";

	document.getElementById('subcontent').innerHTML=xmlHttp.responseText;

	//document.getElementById('dummyDiv').style.display= "none";

}
function hideshow1()
{
	//document.getElementById('dummyDiv').style.display= "block";

	document.getElementById("subcontent").className="FlashVideoThumbs";
	document.getElementById("subcontent2").className="FlashVideoRightActive";
	
}
// --------------------- //
	function ShowDivArrow(s,t)
	{
			var j=1;
			for(i=1;i<=s;i++)
			{
				document.getElementById("DivArrow"+s+"").style.display = "block";
				
				
			}

			while(j<=t)
			{

				if(j!=s)
				{

					hide_tab(j);
				}
				j++;
			}	

	}
	function hide_tab(a)
{
			for(i=1;i<=a;i++)
			{
			document.getElementById("DivArrow"+a+"").style.display = "none";
			document.getElementById("FinalCSS").style.display = "none";


			
			}
}	

function showhidemenu()
{

	document.getElementById("DivArrow2").style.display = "block";
}
function showhidemenu1()
{
	document.getElementById("DivArrow2").style.display = "block";
	document.getElementById("FinalCSS").style.display = "block";
}
// -------------------- //
var ourInterval1;
function MM_swapImgRestore() { //v3.0
  setimgsrc();
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  setimgsrc();
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function showdivcontent(divID,id){
	
	if(id == 1)
	{
		
		m=0;
		while(m<=5000)
		{
			m++;
		}
		if(m==5001)
		{
			document.getElementById("dhtmlcontentLeft").style.display = "none";
			document.getElementById("dhtmlcontent").style.display = "block";
			document.getElementById("ContentTitle").innerHTML = document.getElementById(divID+"_1").innerHTML;
			document.getElementById("MainContent").innerHTML = document.getElementById(divID+"_2").innerHTML;
		}
	} 
	else
	{
	document.getElementById("dhtmlcontent").style.display = "none";
	document.getElementById("dhtmlcontentLeft").style.display = "block";
	document.getElementById("ContentTitleLeft").innerHTML = document.getElementById(divID+"_1").innerHTML;
	document.getElementById("MainContentLeft").innerHTML = document.getElementById(divID+"_2").innerHTML;
	}
}
function hidedivcontent(id){
	if(id == 1){
	document.getElementById("dhtmlcontent").style.display = "none";
	}else{
	document.getElementById("dhtmlcontentLeft").style.display = "none";
	}
}
function setimgsrc(){
	document.getElementById("Constipation").src = "images/Constipation.gif";
}


function showMoreVideos()
{
	/*if (http==null)
	{
		 alert ("Browser does not support HTTP Request")
		 return
	} 
	url='showvideo.php';
	url=url+'?vid='+vid;
	http.open("GET",url,true);
	http.onreadystatechange=stateChanged; 
	http.send(null);
	*/
		try
	  {// Firefox, Opera 8.0+, Safari, IE7
	  xmlHttp=new XMLHttpRequest();
	  }
	catch(e)
	  {// Old IE
	  try
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  catch(e)
		{
		alert ("Your browser does not support XMLHTTP!");
		return;  
		}
	  }
	var vid;  
	vid=document.getElementById('vid').value;
	var url="showvideonew.php?vid=" + vid;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	document.getElementById('defaulVidoes').style.display='none';
	document.getElementById('VideoQuote').className="FlashVideoText";
	document.getElementById('VideoQuote').innerHTML=xmlHttp.responseText;

}
function show2images(vid)
{
		try
	  {// Firefox, Opera 8.0+, Safari, IE7
	  xmlHttp=new XMLHttpRequest();
	  }
	catch(e)
	  {// Old IE
	  try
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  catch(e)
		{
		alert ("Your browser does not support XMLHTTP!");
		return;  
		}
	  }

	var url="showvideo.php?vid="+ vid+"&flag=2";
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	document.getElementById('VideoQuote').className="FlashVideoRightText";
	document.getElementById('defaulVidoes').style.display='block';
	document.getElementById('defaulVidoes').innerHTML = xmlHttp.responseText;

}
function hideMoreVideos()
{

	document.getElementById('defaulVidoes').style.display='block';
	var vid=document.getElementById('vid').value;
	if(vid==1)
	{
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text.gif" title="Vid 1" alt="Vid 1" />';
	}
	else if(vid==2){
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text2.gif" title="Vid 2" alt="Vid 2" />';
	}
	else if(vid==3){
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text3.gif" title="Vid 3" alt="Vid 3" />';
	}
	
	else if(vid==4){
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text4.gif" title="Vid 4" alt="Vid 4" />';
	}
	
	else if(vid==5){
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text5.gif" title="Vid 5" alt="Vid 5" />';
	}
	
	else if(vid==6){
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text6.gif" title="Vid 6" alt="Vid 6" />';
	}
	else
	{
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text.gif" title="Vid 1" alt="Vid 1" />';
	}

}
function playVideo(vid){
	document.getElementById("subcontent").className="FlashVideoThumbs";
	document.getElementById("subcontent2").className="FlashVideoRightActive";

	if(vid==1){
		document.getElementById("CurrentVideo").innerHTML = '&nbsp;<object width="369" height="237"><param name="movie" value="http://www.youtube.com/v/0FdIg5A6LrY&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/0FdIg5A6LrY&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="369" height="237"></embed></object>';
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text.gif" title="Vid 1" alt="Vid 1" />';
		document.getElementById('vid').value=vid;
//		document.getElementById('VideoQuote').innerHTML = 'Image 1';
		show2images(vid);
	}
	else if(vid==2){
		document.getElementById("CurrentVideo").innerHTML = '&nbsp;<object width="369" height="237"><param name="movie" value="http://www.youtube.com/v/QWUxZyPR0J8&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/QWUxZyPR0J8&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="369" height="237"></embed></object>';
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text2.gif" title="Vid 2" alt="Vid 2" />';
		document.getElementById('vid').value=vid;
//		document.getElementById('VideoQuote').innerHTML = 'Image 2';
		show2images(vid);
	}
	else if(vid==3){
		document.getElementById("CurrentVideo").innerHTML = '&nbsp;<object width="369" height="237"><param name="movie" value="http://www.youtube.com/v/eBDQerSZHaw&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/eBDQerSZHaw&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="369" height="237"></embed></object>';
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text3.gif" title="Vid 3" alt="Vid 3" />';
		document.getElementById('vid').value=vid;
//		document.getElementById('VideoQuote').innerHTML = 'Image 3';
		show2images(vid);
	}
	else if(vid==4){
		document.getElementById("CurrentVideo").innerHTML = '&nbsp;<object width="369" height="237"><param name="movie" value="http://www.youtube.com/v/b1chtYyZee0&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/b1chtYyZee0&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="369" height="237"></embed></object>';
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text4.gif" title="Vid 4" alt="Vid 4" />';
		document.getElementById('vid').value=vid;
//		document.getElementById('VideoQuote').innerHTML = 'Image 4';
			show2images(vid);
	}
	else if(vid==5){
		document.getElementById("CurrentVideo").innerHTML = '&nbsp;<object width="369" height="237"><param name="movie" value="http://www.youtube.com/v/WeuQfToa254&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/WeuQfToa254&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="369" height="237"></embed></object>';
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text5.gif" title="Vid 5" alt="Vid 5" />';
		document.getElementById('vid').value=vid;
//		document.getElementById('VideoQuote').innerHTML = 'Image 5';	
		//	show2images(vid);
	}
	else if(vid==6){
		document.getElementById("CurrentVideo").innerHTML = '&nbsp;<object width="369" height="237"><param name="movie" value="http://www.youtube.com/v/wkWJ-7jOO9U&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/wkWJ-7jOO9U&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="369" height="237"></embed></object>';
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text6.gif" title="Vid 6" alt="Vid 6" />';
		document.getElementById('vid').value=vid;
//		document.getElementById('VideoQuote').innerHTML = 'Image 6';
		show2images(vid);
		}
	else if(vid==7){
		document.getElementById("CurrentVideo").innerHTML = '&nbsp;<object width="369" height="237"><param name="movie" value="http://www.youtube.com/v/6kL6GIe-iu8&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/6kL6GIe-iu8&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="369" height="237"></embed></object>';
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text7.gif" title="Vid 7" alt="Vid 7" />';
		document.getElementById('vid').value=vid;
//		document.getElementById('VideoQuote').innerHTML = 'Image 7';
		show2images(vid);

	}
	else{
		document.getElementById("CurrentVideo").innerHTML = '&nbsp;<object width="369" height="237"><param name="movie" value="http://www.youtube.com/v/0FdIg5A6LrY&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/0FdIg5A6LrY&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="369" height="237"></embed></object>';
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text.gif" title="Vid 1" alt="Vid 1" />';
		document.getElementById('vid').value=vid;
//		document.getElementById('VideoQuote').innerHTML = 'Image 8';
		show2images(vid);
	}
	ourInterval1 = setInterval("intervalfun()", 1000);
//	clearInterval(ourInterval1);
}
function intervalfun()
{
	
	clearInterval(ourInterval1);
	//document.getElementById('dummyDiv').style.display= "block";
}
function showHiddenDiv()
{
	var ran_number=Math.floor(Math.random()*7);
	if(ran_number==0)
		ran_number=1;
	

	if(ran_number==1)
	{
	//opacity("CurrentVideo", 0, 100, 900);
	opacity("VideoQuote", 0, 100, 900);


	//document.getElementById("CurrentVideo").innerHTML = '&nbsp;<img src="images/1.jpg" width="369" height="237">';
	document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text.gif" title="Vid 6" alt="Vid 6" />';
	document.getElementById('vid').value=1;
	}
	else if(ran_number==2)
	{
	//opacity("CurrentVideo", 0, 100, 900);
	opacity("VideoQuote", 0, 100, 900);


	//		document.getElementById("CurrentVideo").innerHTML = '&nbsp;<img src="images/2.jpg" width="369" height="237">';
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text2.gif" title="Vid 2" alt="Vid 2" />';
		document.getElementById('vid').value=ran_number;
	}
	else if(ran_number==3)
	{
	//opacity("CurrentVideo", 0, 100, 900);
	opacity("VideoQuote", 0, 100, 900);

	//			document.getElementById("CurrentVideo").innerHTML = '&nbsp;<img src="images/3.jpg" width="369" height="237">';
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text3.gif" title="Vid 3" alt="Vid 3" />';
		
		document.getElementById('vid').value=ran_number;
	}
	else if(ran_number==4)
	{
	//opacity("CurrentVideo", 0, 100, 900);
	opacity("VideoQuote", 0, 100, 900);

	//	document.getElementById("CurrentVideo").innerHTML = '&nbsp;<img src="images/4.jpg" width="369" height="237">';
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text4.gif" title="Vid 4" alt="Vid 4" />';
		document.getElementById('vid').value=ran_number;
	}
	else if(ran_number==5)
	{
	//opacity("CurrentVideo", 0, 100, 900);
	opacity("VideoQuote", 0, 100, 900);

	//			document.getElementById("CurrentVideo").innerHTML = '&nbsp;<img src="images/5.jpg" width="369" height="237">';
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text5.gif" title="Vid 5" alt="Vid 5" />';
		document.getElementById('vid').value=ran_number;
	}
	else if(ran_number==6)
	{
	//opacity("CurrentVideo", 0, 100, 900);
	opacity("VideoQuote", 0, 100, 900);

	//			document.getElementById("CurrentVideo").innerHTML = '&nbsp;<img src="images/6.jpg" width="369" height="237">';
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text6.gif" title="Vid 6" alt="Vid 6" />';
		document.getElementById('vid').value=ran_number;
	}
	else if(ran_number==7)
	{
//	opacity("CurrentVideo", 0, 100, 900);
	opacity("VideoQuote", 0, 100, 900);

	//			document.getElementById("CurrentVideo").innerHTML = '&nbsp;<img src="images/7.jpg" width="369" height="237">';
		document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text7.gif" title="Vid 7" alt="Vid 7" />';
		document.getElementById('vid').value=ran_number;
	}
	else
	{
	//opacity("CurrentVideo", 0, 100, 900);
	opacity("VideoQuote", 0, 100, 900);

//	document.getElementById("CurrentVideo").innerHTML = '&nbsp;<img src="images/1.jpg" width="369" height="237">';
	document.getElementById('VideoQuote').innerHTML = '<img src="images/video-right-text.gif" title="Vid 6" alt="Vid 6" />';
	document.getElementById('vid').value=1;
	}
	//var ran_number=Math.floor(Math.random()*7);
}

var TimeToFade = 1000.0;

function fade(eid)
{

  var element = document.getElementById(eid);
  if(element == null)
    return;
   
  if(element.FadeState == null)
  {
    if(element.style.opacity == null
        || element.style.opacity == ''
        || element.style.opacity == '1')
    { element.FadeState = -2; }
    else
    { element.FadeState = 2; }
  }
   
  if(element.FadeState == 1 || element.FadeState == -1)
  {
    element.FadeState = element.FadeState == 1 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
	    setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
  }
  else
  {
    element.FadeState = element.FadeState == 2 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade;
    element.style.visibility = element.FadeState == 2
        ? 'hidden' : 'visible'; // Switch visibility style rather than Dislay
	dd=new Date().getTime();
//	animateFade(dd,eid);
    setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);

  }
}

function animateFade(lastTick, eid)
{

  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
 
  var element = document.getElementById(eid);
 
  if(element.FadeTimeLeft <= elapsedTicks)
  {
   // element.style.visibility = element.FadeState == 1 ? 'visible' : 'hidden'; // Switch visibility style rather than Dislay
    element.style.opacity = element.FadeState == 1 ? '1' : '0';
    element.style.filter = 'alpha(opacity = '
        + (element.FadeState == 1 ? '100' : '0') + ')';
    //element.FadeState = element.FadeState == 1 ? 2 : -2; // This code is commented out to prevent a fade out
    return;
  }
 
  element.FadeTimeLeft -= elapsedTicks;
  var newOpVal = element.FadeTimeLeft/TimeToFade;
  if(element.FadeState == 1)
    newOpVal = 1 - newOpVal;

  
  element.style.opacity = newOpVal;

  element.style.filter =
      'alpha(opacity = ' + (newOpVal*100) + ')';
 
  setTimeout("animateFade(" + curTick  + ",'" + eid + "')", 33);
}


function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

function showContent(s,t,n)
			{
				var j=1;

				for(i=1;i<=s;i++)
				{
					if(n==1)
					{
					opacity("DivArrow"+s, 0, 100, 500);
					opacity("showMenu"+s, 0, 100, 500);
					}
					document.getElementById("DivArrow"+s).style.display = "block";
					if(s==1 || s==6 || s==11)
					{
						document.getElementById("DivArrowImage"+s).style.height = "43px";
					}
					else if(s==2 || s==7 || s==12)
					{
						document.getElementById("DivArrowImage"+s).style.height = "70px";
					}
					else if(s==3 || s==8 || s==13)
					{
						document.getElementById("DivArrowImage"+s).style.height = "97px";
					}
					else if(s==4 || s==9 || s==14)
					{
						document.getElementById("DivArrowImage"+s).style.height = "124px";
					}
					else if(s==5 || s==10 || s==15)
					{
						document.getElementById("DivArrowImage"+s).style.height = "151px";
					}
					document.getElementById("showMenu"+s).style.display="block";
				}
				
				while(j<=t)
				{
				
					if(j!=s && j<16)
					{
						HideMenuContent(j);
					}
					j++;
				}	
			
			}
			function HideMenuContent(a)
			{
					for(i=1;i<=a;i++)
					{
							document.getElementById("DivArrow"+a).style.display = "none";
							document.getElementById("showMenu"+a).style.display="none";
					}
			}