// JavaScript Document
function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
    return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else 
  // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}
function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
    return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

function StopFlashMovie(flashid)
{
    //alert(flashid);
	var flashMovie=getvideoobject(flashid);
	flashMovie.Stop();
}

function PlayFlashMovie(flashid)
{
	//alert(flashid); 
    var flashMovie=getvideoobject(flashid);
	flashMovie.Play();
	//embed.nativeProperty.anotherNativeMethod();
}


function videoPlay()
{
	var objMediaPlayer= document.getElementById('videoscreen');
	
	objMediaPlayer.Play();
	//if (objMediaPlayer.BufferingProgress == 100) // check to make sure video is playing and the Media player is not buffering
			//{
				//alert('hello');
				//bolIsPlaying = true; // Set boolean value true. We will need to see the video is playing later on.
			//}
}

function checkbuffer()
{
	if (objMediaPlayer.BufferingProgress != 100) // check to make sure video is  not playing and the Media player is buffering
	{
				bolIsPlaying = true; // Set boolean value true. We will need to see the video is playing later on.
	}
}
function getvideoobject(spy)
{
	if (document.getElementById&& document.getElementById(spy) != null)
	{
		//alert('IE');
          return document.getElementById(spy);
	}
	else if (document.layers&& document.layers[spy] != null)
    {
		//alert('2');
		return document.layers[spy];
	}
	else if (document.all)
    {
		//alert('3');
		return document.all[spy];
	}
}
function toggleMe(spy){
	if (spy=='flashchapteraudio')
	{
		// 
		var e=getFlashMovieObject('flashchapteraudio');
		var eaudio=getFlashMovieObject('flash-element-id');
		 //var e=document.getElementById(spy);
		  //alert(spy);
		  var flashid='flash-element-id';
		 // alert(eaudio.playing);
		 // if (eaudio.playing==true){alert('ss');}
		  PlayFlashMovie(flashid);
		 //if(!e)return true;
		  //if(e.style.display=="none")
		  //{
			//e.style.display="block";
			//document.getElementById('flash-element-id').play();
			//window.document['flash-element-id'].play();
			//document.embeds['flash-element-id'].play();
		 // }
		  // else 
		 // {
			//e.style.display="none"
			//document.getElementById('flash-element-id').StopPlay();
		  //}
		  //return true;	
		  }
	else
	{
		spy = "div"+ spy;
		  //get object compatible to all browsers
		  var e=getvideoobject(spy);
		  var flashid='videoscreen';
		  if(!e)return true;
		  if(e.style.display=="none")
		  {
			e.style.display="block";
			//var objMediaPlayer= document.getElementById('videoscreen');
			 PlayFlashMovie(flashid);
			//if (objMediaPlayer.BufferingProgress == 100) // check to make sure video is playing and the Media player is not buffering
			//{
				//alert('Please wait until the video loads.');
				//bolIsPlaying = true; // Set boolean value true. We will need to see the video is playing later on.
			//}
			//else
			//{
			//videoPlay();
			//}
			//window.document['videoscreen'].play();
			//document.embeds['videoscreen'].play();
		  }
		   else 
		  {
			e.style.display="none"
			//document.getElementById('videoscreen').stop();
			StopFlashMovie(flashid)
		  }
		  return true;
	}
}
	function popUpnewwindow(URL) {
	var my_window = null;
	my_window = window.open(URL,"","status=1,width=900,height=650,left=200,top=5,resizable=yes,modal,scrollbars=1,menubar=1,toolbar=1");
	}
	
	function popUp(URL) {
	my_window = null;
	my_window = window.open(URL,"", "status=1,width=800,height=700,left=200,top=5,top=20,left=150,resizable=yes,,scrollbars=1,modal");
	}
	function popUpcomment(URL){
		my_window = null;
		my_window = window.open(URL,"","status=1,width=500,height=300,left=200,top=20,resizable=yes,scrollbars=1,modal");
	}

	//Check if popup is closed if not closed set popup to focus
	function check() {
		if(my_window && !my_window.closed)
			my_window.focus();
	}
	
	window.onload = function() {
		window.name = "viewBusiness.php";
	}
	
	
	function showplayer(which,Value) {
var obj;
var Value;
Value='visible';
////////////////////////////////////////////////////////////////////////////11/02/08 Sud /////////////////////////////////////////////////////////////////////////
									//////////////////////////////// FOR MOZILLLA BROWER////////////////////////////////
obj = document.getElementById(which);
obj.style.visibility = Value;
////////////////////////////////////////////////////////////////////////////END/////////////////////////////////////////////////////////////////////////
										//////////////////////////////// FOR MOZILLLA BROWER////////////////////////////////

	   if (document.layers && document.layers[which] != null)
		
		document.layers[which].visibility = Value;
	   else if 
		(document.all) eval('document.all.'+which+'.style.visibility ="'+ Value+'"');
}
function Change_Thumbs(img1)
{
document.getElementById('videoimage').src=img1
}
function Change_Thumbsquiz(img1)
{
document.getElementById('quizicon').src=img1
}

function Change_Icon(ID,img1)
{
document.getElementById(ID).src=img1
}
function confirmremove(partname)
{
var agree=confirm("Are you sure you wish remove "+partname+" from this chapter?");
if (agree)
	return true ;
else
	return false ;
}
////////////////////////////////////////////////////////////Gavin SEARCH START////////////////////////////////////////////////////////
	function showadv(division)
{
 document.getElementById(division).style.visibility = "visible";
}
	function hideadv(division)
	{
	 document.getElementById(division).style.visibility = "collapse";
	}

function clean()
{
document.getElementByName("vote").value=x;
document.getElementById("WDYT").style.visibility="hidden";
document.getElementById("tanswer").value="You voted:"+ x +"/5";
}
////////////////////////////////////////////////////////////Gavin SEARCH START////////////////////////////////////////////////////////
//javascript function to load images for viewchapter menu
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_swapImgRestore() { //v3.0
  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_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
  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];}
}
//////javascript for feed back

function closejqmodal(modalwindow,overlay,igniter)
{ 
		document.getElementById(modalwindow).style.display="";
	 	document.getElementById(overlay).style.display="none";
		document.getElementById(igniter).style.display="none";
		
}

var xmlHttp2;
function vting(v)
{

var d= document.getElementById('domain').value;
var c= document.getElementById('chapterid').value;
var b= document.getElementById('businessid').value;
var i= document.getElementById('industrysecid').value;
var url1="processvote.php";
url1=url1+"?v="+v;
url1=url1+"&d="+d;
url1=url1+"&c="+c;
url1=url1+"&b="+b;
url1=url1+"&i="+i;

xmlHttp2=GetXmlHttpObject2();
if (xmlHttp2==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }

xmlHttp2.onreadystatechange=stateChanged2; 
xmlHttp2.open("GET",url1,true);
xmlHttp2.send(null);

}

function stateChanged2() 
{ 
if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
 { 
 document.getElementById("WDYT").innerHTML=xmlHttp2.responseText ;

 setTimeout("closejqmodal('ex3a','overlaydiv','feedback')",2000);

 } 
}
function GetXmlHttpObject2()
{
var xmlHttp2=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp2=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp2;
}////

