
// !!!!!!! RATING PROCESS 

	function fxRate(vkey,rate,idToHide,idToShow,vid){
		cp.call(baseurl+'ajax/myajaxphp.php','process_data',return_data,rate,vid);
		hideMe(idToHide);
		showMe(idToShow);
	}

			function return_data(restul){
				
				// Collect the number of BLUE star
			var cnt=restul.getElementsByTagName('trate').item(0).firstChild.data;				
					hideMe('idViewVoteResult');
			if(cnt!='exist')
			{
				// # Show the vote 
				var x=document.getElementById('idVoteView').rows[0].cells;
					x[1].innerHTML=restul.getElementsByTagName('tvote').item(0).firstChild.data;

				
					
					if(cnt>6)
					{
						cnt=6;
					}	
					else if (cnt<0)
					{
						cnt=0;
					}
					
					blank_star=6-cnt;

					var x=document.getElementById('tblViewResult').rows[0].cells;
					
					for (i=0;i<cnt;i++ )
					{
							x[i].innerHTML='<img src='+imgurl+'/star.gif>';
					}
					
					for (j=cnt;j<5;j++ )
					{
							x[j].innerHTML='<img src=' + imgurl+'/blank_star.gif>';
					}
			}
			else
			{
				var x=document.getElementById('voteProcessthank').innerHTML="<FONT COLOR=#FF0000 >You already vote this video</FONT>";
			}
				
				return false;
			}
// RATING PROCESS END  


// !!!!!!! My voting process 

		function fxVote(voteId)
		{
				voteAnswer=document.getElementById('opAns').value;
		
				if(voteAnswer=='')
				{
					alert('Select any one');
				}
				else
				{
						cp.call(baseurl+'/ajax/myajaxphp.php','process_Vote',return_vote_result,voteId,voteAnswer);
				}
		}
					function return_vote_result(result)
					{
					var xx=result.getElementsByTagName('result').item(0).firstChild.data;
					if (xx=='1'){
							count=result.getElementsByTagName('count').item(0).firstChild.data;
							for (var  ii=0; ii<count  ; ii++ ){

								 var vv='A1'+ii;
								 var pp='P1'+ii;	
								
								vv=result.getElementsByTagName(vv).item(0).firstChild.data;
								pp=result.getElementsByTagName(pp).item(0).firstChild.data;
								
								// # Generate Voring table
								var tt=document.getElementById('tblVoteResult').insertRow(0);
								var y=tt.insertCell(0);
								var z=tt.insertCell(1);
								y.innerHTML=vv;
								z.innerHTML=pp +'%';
							
								if(vv==""){
									break;
								}
							}
							insertInToTable('tblPResult', 0,0,'Vote result');
							// # Hide the previous tale
							hideMe('divviewvresult');
							hideMe('tblVote');

					}
					else if(xx>1)
					{
						insertInToTable('tblPResult', 0,0,'<font color=#FF0000><B>Sorry you already voted..</B></FONT>');
						viewVote(xx);
							// # Hide the previous table
							//showMe('divviewvresult');
							hideMe('tblVote');
					}
				}


 // END

 // VIEW VOTE
function viewVote(pollId)
{
		cp.call(baseurl+'/ajax/myajaxphp.php','view_vote',return_view_vote,pollId);
}
		function return_view_vote(result){
			var xx;
			if (1){
					count=result.getElementsByTagName('count').item(0).firstChild.data;
					for (var  ii=0; ii<count  ; ii++ ){

						 var vv='A1'+ii;
						 var pp='P1'+ii;	
						
						vv=result.getElementsByTagName(vv).item(0).firstChild.data;
						pp=result.getElementsByTagName(pp).item(0).firstChild.data;
						
						// # Generate Voring table
						var tt=document.getElementById('tblViewVoteResult').insertRow(0);
						var y=tt.insertCell(0);
						var z=tt.insertCell(1);
						y.innerHTML=vv;
						z.innerHTML=pp +'%';
					
				if(vv==""){
					break;
				}
			}
			insertInToTable('tblViewVote', 0,0,'Current vote status');
		}
		
	}



// !!!!!!!! SEND COMMENT PROCESS

	function fxSendComments(idToHide,commentId,uid,vid){
		comment_value=document.getElementById(commentId).value;
		if(comment_value==''){
			alert(' Comment box is empty !!');
		}
		else{
			hideMe(idToHide);	
			cp.call(baseurl+'/ajax/myajaxphp.php','process_comments',return_comment_response,comment_value,uid,vid);
		}		
		
	}

			function return_comment_response(restul){
				
				msg_number = restul.getElementsByTagName('a').item(0).firstChild.data;
				if(msg_number==0){
					showMe('divComResult2');
				} else if ( msg_number==1) {
					showMe('divComResult1');
				} else{
					showMe('divComResult3');
				}
			}
// END

// RECENT VIEW PROCESS
	var current_position=4;
	function recentview(amount,flag){
		
		gflag="viewrecent";
		if(flag=='next')
		{		
				var start=current_position
					current_position=current_position+amount;
				var end=current_position;
				if(dbreport!='1'){

				}

			sql="SELECT VID, title, viewtime, vkey from video where viewtime<>'0000-00-00 00:00:00' order by viewtime desc limit "+start + " , " +end;  
			executeDB(sql);	
			//alert(sql);
 			if(dbreport<0)
			{
					end=current_position;
					current_position=current_position-amount;
					start=current_position;
					alert("End");

			}
		}

		if(flag=='prev')
		{
			var end=current_position;
				current_position=current_position-amount;
			var start=current_position;

			if(start<0){
				start=amount;
				end=start+amount;
				alert("End");
			}

			sql="SELECT VID, title, viewtime, vkey from video where viewtime<>'0000-00-00 00:00:00' order by viewtime desc limit "+start + " , " +end;  
			executeDB(sql);
		}
	}
//END


function pollAnsBox(myID){
	Me=document.getElementById(myID);
	if(Me.value==""){
		  Me.style.background="#3366FF";
		
	}
	else{
		
		Me.style.background="#FFFFFF";
			xy=Me.value;
		for (i=0;i<Me.value;i++ ){		
			var x=document.getElementById('tblViweAnsBox').insertRow(0);
			var y=x.insertCell(0);
			var z=x.insertCell(1);
			y.innerHTML='Answer ' + (xy-i);			
			z.innerHTML='<INPUT TYPE=text SIZE=40 NAME=voteAnsBox'+i+' ID=voteAnsBox'+i+' onBlur=txtBoxValidation(voteAnsBox'+i+', #EAEAEA,#FF0033) >';
		}
	}
	
}

// ## Delete row of a Tabile
	function delteRow(){
		var x=document.getElementById('tblViweAnsBox').rows.length-1;

		for (var i=x;i>=0;i--){
					document.getElementById('tblViweAnsBox').deleteRow(i);
			}
	}


	function fxvalidation(){
		var flag=true;
		var x=document.getElementById('tblViweAnsBox').rows.length-1;

		// ## Question text
		flag=txtBoxValidation('txtQtn','#EAEAEA','#FF0033');

		// ## Questin qty
		flag=txtBoxValidation('txtPollAnsQty','#EAEAEA','#FF0033');
		
		
		for ( i=x; i>=0; i-- )
		{
			targetID='voteAnsBox'+i;
			if (document.getElementById(targetID).value==""){
				txtBoxValidation(targetID,'#EAEAEA','#FF0033');
				flag=false;
				break;
			}
				
							
		}

		return flag;
	}
  

function fxShowAccInfo(a,b){
	showMe(a);
	hideMe(b);	
}

function fxReportVideo(hidediv, uid, vid ) {
	if ( uid == '0' ) {
		hideMe(hidediv);
		showMe('reportVideoLogin');
	} else {
		showMe('reportVideoBox');
		
	}
}

function fxFeatureVideo( uid, vid ) {
	if ( uid == '0' ) {
		hideMe('featureVideoSuccess');
		hideMe('featureVideoFailed');
		showMe('featureVideoLogin');
	} else {
		cp.call(baseurl+'/ajax/myajaxphp.php','featureVideo', featureVideoResponse, uid, vid);
	}
}

function featureVideoResponse( feature_result ) {
	var feature_response_id=feature_result.getElementsByTagName('featureVideoMessage').item(0).firstChild.data;
	if ( feature_response_id == '0' ) {
		hideMe('featureVideoFailed');
		hideMe('featureVideoLogin');
		showMe('featureVideoSuccess');
	} else {
		hideMe('featureVideoSuccess');
		hideMe('featureVideoLogin');
		showMe('featureVideoFailed');
	}
}

function fxReportVideo( uid, vid ) {
	if ( uid == '0' ) {
		hideMe('reportVideoSuccess');
		hideMe('reportVideoFailed');
		showMe('reportVideoLogin');
	} else {
		cp.call(baseurl+'/ajax/myajaxphp.php','reportVideo', reportVideoResponse, uid, vid);
	}
}

function reportVideoResponse( report_result ) {
	var report_response_id=report_result.getElementsByTagName('reportVideoMessage').item(0).firstChild.data;
	if ( report_response_id == '0' ) {
		hideMe('reportVideoFailed');
		hideMe('reportVideoLogin');
		showMe('reportVideoSuccess');
	} else {
		hideMe('reportVideoSuccess');
		hideMe('reportVideoLogin');
		showMe('reportVideoFailed');
	}
}

function fxAddFavorite( hidediv, uid, vid, vuid ) {	
	hideMe(hidediv);
	if ( uid == '0' ) {
		hideMe('addToFavLink');
		hideMe('addToFavSuccess');
		hideMe('addToFavFailed');
		hideMe('addToFavAlready');
		hideMe('addToFavOwner');
		showMe('addToFavLogin');	
	} else if ( uid == vuid ) {	
		hideMe('addToFavLink');
		hideMe('addToFavSuccess');
		hideMe('addToFavFailed');
		hideMe('addToFavAlready');
		hideMe('addToFavLogin');
		showMe('addToFavOwner');
	} else {
		cp.call(baseurl+'/ajax/myajaxphp.php','addToFavorites', addToFavoritesResponse, uid, vid, vuid);
	}
}

function addToFavoritesResponse( fav_result ) {
	var fav_response_id=fav_result.getElementsByTagName('addFavMessage').item(0).firstChild.data;
	if( fav_response_id == '2' ) {
		hideMe('addToFavLink');
		hideMe('addToFavSuccess');
		hideMe('addToFavFailed');
		hideMe('addToFavLogin');
		hideMe('addToFavOwner');
		showMe('addToFavAlready');
	} else if( fav_response_id == '0' ) {
		hideMe('addToFavLink');
		hideMe('addToFavFailed');
		hideMe('addToFavAlready');
		hideMe('addToFavLogin');
		hideMe('addToFavOwner');
		showMe('addToFavSuccess');
	} else {
		hideMe('addToFavLink');
		hideMe('addToFavSuccess');
		hideMe('addToFavAlready');
		hideMe('addToFavLogin');
		hideMe('addToFavOwner');
		showMe('addToFavFailed');
	}
}

function pollAnsBox($num){
	alert($num);
}

function showRelatedVideos()
{
    var tabRelatedVideos = document.getElementById('tabRelatedVideos');
    var tabUservideos = document.getElementById('tabUserVideos');
    tabUservideos.className = "";
    tabRelatedVideos.className = "tabactive";
    hideMe('userVideos');
    showMe('relatedVideos');
}

function showUserVideos()
{
    var tabRelatedVideos = document.getElementById('tabRelatedVideos');
    var tabUservideos = document.getElementById('tabUserVideos');
    tabRelatedVideos.className = "";
    tabUservideos.className = "tabactive";
    hideMe('relatedVideos');
    showMe('userVideos');
}


//START: USER-ADDED FUNCTIONS

//globals
var curCHID = "";

//functions
function switchDiv(thisHID) //added this for featured bundles on index
{
	document.getElementById("imgFeat").src = document.getElementById("hidImg"+thisHID).value;
	document.getElementById("h1Feat").innerHTML = document.getElementById("hidName"+thisHID).value;
	document.getElementById("h2Feat").innerHTML = document.getElementById("hidTitle"+thisHID).value;
	document.getElementById("pFeat").innerHTML = document.getElementById("hidFeat"+thisHID).value;
	document.getElementById("aFeat").href = "view_video.php?groupkey="+document.getElementById("hidGID"+thisHID).value;
}

//AJAX
function GetXmlHttpObject(handler)
{
	var objXmlHttp = null;
				
	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;
	}
}
			
function GetResponse()
{
	var urlString = "?search_id=" + document.getElementById("search_id").value ;
	var url = "search_result_index.php" + urlString;
	xmlHttp = GetXmlHttpObject(stateChanged);
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
function GetResponse2(whichVID)
{
	var urlString = "?vid=" + whichVID ;
	var url = "view_video_single.php" + urlString;
	xmlHttp = GetXmlHttpObject(stateChanged2);
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);	
}

function GetResponse3(whichCHID)
{
	var urlString = "?axshun=1&CHID=" + whichCHID ;
	var url = "/tutorials/woop_cust1.php" + urlString;
	xmlHttp = GetXmlHttpObject(stateChanged3);
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);	
}

function GetResponse4(whichCHID)
{
	var urlString = "?axshun=1&CHID=" + whichCHID ;
	var url = "/tutorials/woop_cust1.php" + urlString;
	xmlHttp = GetXmlHttpObject(stateChanged4);
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);	
}

function stateChanged() //SEARCH
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") 
	{
		
		document.getElementById('searchSlider').innerHTML = xmlHttp.responseText;
				
	}
}


function stateChanged2() //GROUP BUNDLES ON HOMEPAGE
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") 
	{
		
		document.getElementById('flashHolder').innerHTML = xmlHttp.responseText;
				
	}
}

function stateChanged3() //2nd LEVEL DROPDOWN
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") 
	{
		document.getElementById('selSub1').innerHTML = xmlHttp.responseText;
		GetResponse4(document.getElementById('selSub1').options[0].value);
	}
}

function stateChanged4() //3rd LEVEL DROPDOWN
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") 
	{
		document.getElementById('selSub2').innerHTML = xmlHttp.responseText;
	}
}


//END AJAX

function switchLibraryView(whichA)
{
	var divTitle = document.getElementById('divTitle');
	var divTitlePop = document.getElementById('divTitlePop');
	var divSubj = document.getElementById('divSubj');
	var divSubjPop = document.getElementById('divSubjPop');
	
	var rdSort1 = document.getElementById('rdSort1');
	var rdSort2 = document.getElementById('rdSort2');
	
	switch(whichA)
	{
		case 1:
		  if(rdSort1.checked == true)
		  {
		  	divTitle.style.display = "none";
			divTitlePop.style.display = "none";
			divSubj.style.display = "";
			divSubjPop.style.display = "none";
		  }
		  else
		  {
		  	divTitle.style.display = "none";
			divTitlePop.style.display = "none";
			divSubj.style.display = "";
			divSubjPop.style.display = "none";
		  }
		  break;
		case 2:
		  if(rdSort1.checked == true)
		  {
		  	divTitle.style.display = "";
			divTitlePop.style.display = "none";
			divSubj.style.display = "none";
			divSubjPop.style.display = "none";
		  }
		  else
		  {
		  	divTitle.style.display = "none";
			divTitlePop.style.display = "";
			divSubj.style.display = "none";
			divSubjPop.style.display = "none";
		  }
		  break;    
		case 4: //radio -> diff logic
			if(divTitle.style.display == "" || divTitlePop.style.display == "")
			{
				divTitle.style.display = "";
				divTitlePop.style.display = "none";
			}
			else if (divSubj.style.display == "" || divSubjPop.style.display == "")
			{
				divSubj.style.display = "";
				divSubjPop.style.display = "none";
			}
		  break;
		case 5: //radio -> diff logic
			if(divTitle.style.display == "" || divTitlePop.style.display == "")
			{
				divTitle.style.display = "none";
				divTitlePop.style.display = "";
			}
			else if (divSubj.style.display == "" || divSubjPop.style.display == "")
			{
				divSubj.style.display = "none";
				divSubjPop.style.display = "";
			}
		  break;  	
		default:
	}
	
	
}


function MoveLeft()
{
    new Effect.MoveBy('divScroller', 0, 600 , 
                              {
                                  duration: 0.4,  
                                  transition: Effect.Transitions.sinoidal
                              });
}

function MoveRight()
{
    new Effect.MoveBy('divScroller', 0, -600 , 
                              {
                                  duration: 0.4,  
                                  transition: Effect.Transitions.sinoidal
                              });
}


function generateWidth(itemTotal)//write style block based off of total of items for slider
{
	document.writeln("<style type='text/css'>#divScroller {width: "+(615 * itemTotal)+"px;}</style>");
}

function getBundleVids(thisBundle)
{
	var divToIterate	= document.getElementById("divBundleLinksContainer");
	var divCollection 	= divToIterate.getElementsByTagName("div");
	for (var i = 0; i < divCollection.length; i++) 
	{
		if((divCollection[i].id).substr(0,14) == "divBundleVids_")
		{
			var theBID = divCollection[i].id.split("_");
			if(thisBundle == theBID[1])
			{
				divCollection[i].style.display = "";
			}
			else
			{
				divCollection[i].style.display = "none";
			}
		}
	}
	
}


function treeMemVids(thisCAT)//thisCAT is the active CAT --> close all others divTitle
{
	var divToIterate	= document.getElementById("divVids");
	var divCollection 	= divToIterate.getElementsByTagName("div");
	
	var sortAlpha		= 1;
	var radioSort		= document.getElementById("rdSort1");
	if(radioSort.checked == false)
	{
		sortAlpha = 0;
	}
	
	for (var i = 0; i < divCollection.length; i++) 
	{
		var theBID = divCollection[i].id.split("_");
			if(thisCAT == theBID[1])
			{
				//check which radio is selected: alpha or popular
				if(sortAlpha == 1)
				{
					if(divCollection[i].id.slice(0,9) == "divTitle_")
					{
						divCollection[i].style.display = "";
					}
					else
					{
						divCollection[i].style.display = "none";
					}
					
				}
				else
				{
					if(divCollection[i].id.slice(0,9) == "divTitleP")
					{
						divCollection[i].style.display = "";
					}
					else
					{
						divCollection[i].style.display = "none";
					}
				}
				
			}
			else
			{
				if(divCollection[i].id.slice(0,8) == "divTitle")
				{
					divCollection[i].style.display = "none";
				}
				
			}
	}
}

function treeMemVidsTitle(thisCAT)//thisCAT is the active CAT --> close all others divTitle
{
	var divToIterate	= document.getElementById("divVidsTitle");
	var divCollection 	= divToIterate.getElementsByTagName("div");
	
	var sortAlpha		= 1;
	var radioSort		= document.getElementById("rdSort1");
	if(radioSort.checked == false)
	{
		sortAlpha = 0;
	}
	
	for (var i = 0; i < divCollection.length; i++) 
	{
		//alert(divCollection[i].id);
		var theBID = divCollection[i].id.split("_");
			if(thisCAT == theBID[1])
			{
				//check which radio is selected: alpha or popular
				if(sortAlpha == 1)
				{
					if(divCollection[i].id.slice(0,9) == "divTitle2")
					{
						//alert(divCollection[i].id);
						divCollection[i].style.display = "";
					}
					else
					{
						divCollection[i].style.display = "none";
					}
					
				}
				else
				{
					if(divCollection[i].id.slice(0,9) == "divTitleP")
					{
						divCollection[i].style.display = "";
					}
					else
					{
						divCollection[i].style.display = "none";
					}
				}
				
			}
			else
			{
				if(divCollection[i].id.slice(0,9) == "divTitle2")
				{
					divCollection[i].style.display = "none";
				}
				
			}
	}
}

function switchTrees(whichTREE)
{
	var divSubject 	= document.getElementById("divSubject");
	var divTitle	= document.getElementById("divTitle");
	var divVendor	= document.getElementById("divVendor");
	switch(whichTREE)
	{
		case 1:
			divSubject.style.display = "";
			divTitle.style.display = "none";
			divVendor.style.display = "none";
		break;
		case 2:
			divSubject.style.display = "none";
			divTitle.style.display = "";
			divVendor.style.display = "none";
		break;
		case 3:
			divSubject.style.display = "none";
			divTitle.style.display = "none";
			divVendor.style.display = "";
		break;
	}
	/**
	* @added by : John Smith
	* @added on : 29-Aug-08
	* @purpose  : reset the value of common video display div
	**/
	document.getElementById('divVideoList').innerHTML="&nbsp;";
}

function hideTheKids(whoseKids)
{
	curCHID = whoseKids;
	var divSubject 	= document.getElementById("divSubject");
	var divTitle	= document.getElementById("divTitle");
	var divVendor	= document.getElementById("divVendor");
	var ulHideMe = document.getElementById("ulChildrenOf_" + whoseKids);
	if(divSubject.style.display == "")
	{
		
	}
	else if(divTitle.style.display == "")
	{
		ulHideMe = document.getElementById("ulTitleChildrenOf_" + whoseKids);
	}
	else if(divVendor.style.display == "")
	{
		//added by John Smith on 29-Aug-2008
		ulHideMe = document.getElementById("ulVendorChildrenOf_" + whoseKids);
	}
		
	
	try
	{
		ulHideMe.style.display == "" ? ulHideMe.style.display = "none" : ulHideMe.style.display = "";
	}
	catch(err)
	{
		//commented by: John Smith on 29-Aug-2008 to avoid alert for third level children
		//alert("No subcategories exist for that category");
	}
}
/**
* @added by : John Smith
* @added on : 29-Aug-08
* @purpose  : display the vendor second level children
**/
function hideTheVendorKids(whoseKids)
{
	curCHID = whoseKids;
	var divVendor	= document.getElementById("divVendor");
	//var ulHideMe = document.getElementById("ulChildrenOf_" + whoseKids);
	if(divVendor.style.display == "")
	{
		//added by John Smith on 29-Aug-2008
		//ulHideMe = document.getElementById("ulVendorChildrenOf_" + whoseKids);
		ulHideMe = document.getElementById("ulVendorChildrenChildOf_" + whoseKids);
	}
	try
	{
		ulHideMe.style.display == "" ? ulHideMe.style.display = "none" : ulHideMe.style.display = "";
	}
	catch(err)
	{
		//alert("No subcategories exist for that category");
	}
}//end of function

function sortRadio(whichOrder)
{
	//step 1: find the active div (subject,title,vendor)
	//step 2: iterate to find the shown divs, & switch to popular view
	var divSubject 	= document.getElementById("divSubject");
	var divTitle	= document.getElementById("divTitle");
	var divVendor	= document.getElementById("divVendor");
	
	if(divSubject.style.display == "") // in each one of these we will iterate thru the apropos video div container & switch on/off the apropos divs
	{
		var divToIterate = document.getElementById("divVids");
		var divCollection 	= divToIterate.getElementsByTagName("div");
		var divToSwitch = ""; // this will determine which divs to switch on/off
		whichOrder == 1 ? divToSwitch = "divTitle" : divToSwitch = "divTitlePop";
		for (var i = 0; i < divCollection.length; i++)
		{
			var theCHID = divCollection[i].id.split("_");
			if(theCHID[0] == "divTitle" || theCHID[0] == "divTitlePop")
			{
				if(theCHID[0] == divToSwitch && theCHID[1] == curCHID)
				{
					divCollection[i].style.display = "";
				}
				else
				{
					divCollection[i].style.display = "none";
				}
			}
		}
		
	}
	else if(divTitle.style.display == "")
	{
		var divToIterate = document.getElementById("divVidsTitle");
		var divCollection 	= divToIterate.getElementsByTagName("div");
		var divToSwitch = ""; // this will determine which divs to switch on/off
		whichOrder == 1 ? divToSwitch = "divTitle2" : divToSwitch = "divTitlePop2";
		for (var i = 0; i < divCollection.length; i++)
		{
			var theCHID = divCollection[i].id.split("_");
			if(theCHID[0] == "divTitle2" || theCHID[0] == "divTitlePop2")
			{
				if(theCHID[0] == divToSwitch && theCHID[1] == curCHID)
				{
					divCollection[i].style.display = "";
				}
				else
				{
					divCollection[i].style.display = "none";
				}
			}
		}
	}
	else if(divVendor.style.display == "")
	{
		
	}
	
}

function isNull(val)
{
	return(val==null);
}
//added by : John Smith to call Step Back video
function getStepBackword()
{
	var count  = parseInt(document.getElementById('countVideo').value);
	var videos = document.getElementById('allVideo').value;
	var videoArr = videos.split(',');
	var vdLength = videoArr.length;
	if(count >= vdLength || videoArr[count]=="")
	{
		count = 0;
	}
	
	if(videoArr[count]!="")
	{
		//change count value
		document.getElementById('countVideo').value = parseInt(count+1);
	
		var urlString = "?viewkey=" + videoArr[count];
		//var urlString = "?vid=" + whichVID ;
		var url = "view_video_single.php" + urlString;
	
		/*if(document.getElementById('countVideo').value >= vdLength)
		{
			alert("sssss");
			document.getElementById('getStepBackword').innerHTML="no";
			//return false;
		}*/
		xmlHttp = GetXmlHttpObject(stateChanged2);
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}
//added by : John Smith to call Moving Forward video
function getStepForward()
{
	var count  = parseInt(document.getElementById('countVideo').value);
	var videos = document.getElementById('allVideo').value;
	//var fwdVideo = videos.split('');
	var videoArr = videos.split(',');
	var vdLength = videoArr.length;
	if(count >= vdLength)
	{
		count = 0;
	}
	if(videoArr[count]!="")
	{
		//change count value
		document.getElementById('countVideo').value = parseInt(count+1);
	
		var urlString = "?viewkey=" + videoArr[count];
		//var urlString = "?vid=" + whichVID ;
		var url = "view_video_single.php" + urlString;
	
		/*if(document.getElementById('countVideo').value >= vdLength)
		{
			alert("sssss");
			document.getElementById('getStepBackword').innerHTML="no";
			//return false;
		}*/
		xmlHttp = GetXmlHttpObject(stateChanged2);
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}
/*
function moveStepBackward()
{
	var videos = document.getElementById('moveBack').value;
	var videoArr = videos.split(',');
	var vdLength = videoArr.length;
	if(videoArr[0]!="")
	{
		
		var urlString = "?viewkey=" + videoArr[0];
		var url = "view_video.php" + urlString;
	
window.location = url;
	}
}
function moveStepForward()
{
	var videos = document.getElementById('moveFwd').value;
	var videoArr = videos.split(',');
	var vdLength = videoArr.length;
	if(videoArr[0]!="")
	{
		
		var urlString = "?viewkey=" + videoArr[0];
		var url = "view_video.php" + urlString;
		window.location = url;
	}
}
*/
function moveStepForward(Url)
{
	window.location.href = Url;
}
function moveStepBackward(Url)
{
	window.location.href = Url;
	
}
//added this 

function addthis_open_deux(elt, _42, _43, _44){
    _atw.xwait();
    addthis_url = _43;
    addthis_title = _44;
    if (addthis_url === "" || addthis_url === "[URL]") {
        addthis_url = location.href;
    }
    if (addthis_title === "" || addthis_title === "[TITLE]") {
        addthis_title = document.title;
    }
    var _45 = 16;
    var _46 = elt.getElementsByTagName("img");
    if (_46 && _46[0]) {
        elt = _46[0];
        _45 = 0;
    }
    _atw.show(_42);
    var _47 = _atw.cumulpos(elt), _48 = _47[0] + addthis_offset_left, _49 = _47[1] + _45 + 1 + addthis_offset_top, _4a = _atw.wsize(), _4b = _atw.spos(), _4c = _atw.get(_atw.divid), dir = 0;
    _4c.style.display = "block";
	
    if (_48 - _4b[0] + _4c.clientWidth + 20 > _4a[0]) {
        _48 = _48 - _4c.clientWidth + 50;
        dir++;
    }
    /*
	if (_49 - _4b[1] + _4c.clientHeight + elt.clientHeight + 20 > _4a[1]) {
        _49 = _49 - _4c.clientHeight - 20;
        dir += 2;
    }
    */
    _ate.cev("dir", dir);
    _4c.style.left = _48 + "px";
    _4c.style.top = (_49 + elt.clientHeight) + "px";
    if (addthis_hide_embed) {
        var _4e = _48 + _4c.clientWidth;
        var _4f = _49 + _4c.clientHeight;
        var e = document.getElementsByTagName("embed");
        var _51 = 0, _52 = 0, _53 = 0;
        for (i = 0; i < e.length; i++) {
            _51 = _atw.cumulpos(e[i]);
            _52 = _51[0];
            _53 = _51[1];
            if (_48 < _52 + e[i].clientWidth && _49 < _53 + e[i].clientHeight) {
                if (_4e > _52 && _4f > _53) {
                    if (e[i].style.visibility != "hidden") {
                        e[i].addthis_hidden = true;
                        e[i].style.visibility = "hidden";
                    }
                }
            }
        }
    }
    if (!_atw.odone) {
        var _55 = addthis_options.replace(/\s/g, "");
        var _56 = _55.split(",");
        for (var i = 0; i < _56.length; i++) {
            var _57 = _56[i];
            if (_57 in _atw.list) {
                var bms = _atw.get("addthis_" + _57 + "15");
                if (bms) {
                    bms.src = _atw.serv + _atw.list[_57][1];
                }
            }
        }
        _atw.odone = true;
    }
    return false;
}

// added this to override deux
function addthis_open_trois(elt, _4b, _4c, _4d){
    var d = document;
    if (_atc.defer && _atw.div) {
        d.body.insertBefore(_atw.div, d.body.firstChild);
        _atw.div.style.zIndex = 1000000;
        _atw.div = null;
    }
    _atw.xwa();
    addthis_url = _4c;
    addthis_title = _4d;
    if (addthis_url === "" || addthis_url === "[URL]") {
        addthis_url = location.href;
    }
    if (addthis_title === "" || addthis_title === "[TITLE]") {
        addthis_title = d.title;
    }
    var _4f = 16;
    var _50 = elt.getElementsByTagName("img");
    if (_50 && _50[0]) {
        elt = _50[0];
        _4f = 0;
    }
    _atw.sho(_4b);
    var _51 = _atw.cumpos(elt), _52 = _51[0] + addthis_offset_left, _53 = _51[1] + _4f + 1 + addthis_offset_top, _54 = _atw.wsize(), _55 = _atw.spos(), _56 = _atw.get(_atw.did), _57 = _56.style, dir = 0;
    _57.display = "block";
    var _59 = _56.clientWidth, _5a = _56.clientHeight;
    if (_52 - _55[0] + _59 + 20 > _54[0]) {
        _52 = _52 - _59 + 50;
        dir++;
    }
	/*
    if (_53 - _55[1] + _5a + elt.clientHeight + 20 > _54[1]) {
        _53 = _53 - _5a - 20;
        dir += 2;
    }
    */
    _ate.cev("dir", dir);
    _57.left = _52 + "px";
    _57.top = (_53 + elt.clientHeight) + "px";
    if (addthis_hide_embed) {
        var _5b = _52 + _59, _5c = _53 + _5a, e = d.getElementsByTagName("embed"), _5e = 0, _5f = 0, _60 = 0;
        for (i = 0; i < e.length; i++) {
            _5e = _atw.cumpos(e[i]);
            _5f = _5e[0];
            _60 = _5e[1];
            if (_52 < _5f + e[i].clientWidth && _53 < _60 + e[i].clientHeight) {
                if (_5b > _5f && _5c > _60) {
                    if (e[i].style.visibility != "hidden") {
                        e[i].addthis_hidden = true;
                        e[i].style.visibility = "hidden";
                    }
                }
            }
        }
    }
    if (!_atw.ost) {
        if (_atw.addr >= 0) {
            _ate.ab = _atw.addt;
            var nl = 2;
            switch (_ate.ab) {
                case 3:
                    nl = 65;
                    break;
            }
            var _63 = nl, pxl = _63 * 23, atf = _atw.get("at_plus");
            if (_63 > 3) {
                pxl = _63;
            }
            if (_63 > 250) {
                _56.style.width = "310px";
            }
            else {
                if (_63 > 50 && _63 < 100) {
                    _56.style.width = "240px";
                }
            }
            atf.src = "http://www.addthis.com/ads.php?r=" + _ate.ran() + "&url=" + _euc(addthis_url) + "&ate=" + _ate.sta() + "&adt=" + _atw.addt + "&pub=" + _atw.pub + "&lnz=" + _63;
            switch (_ate.ab) {
                case 0:
                    _atw.sla(atf, pxl, 5, pxl / 16, 2000);
                    break;
                case 1:
                    _atw.sla(atf, pxl, 5, pxl / 16, 0);
                    break;
                default:
                    _atw.sla(atf, pxl, 5, pxl, 0);
                    break;
            }
        }
        else {
            _ate.ab = "~";
        }
        var _66 = addthis_options.replace(/\s/g, "");
        var _67 = _66.split(",");
        for (var i = 0; i < _67.length; i++) {
            var _68 = _67[i];
            if (_68 in _atw.list) {
                var bms = _atw.get("addthis_" + _68 + "15");
                if (bms) {
                    bms.src = _atw.serv + _atw.list[_68][1];
                }
            }
        }
        _atw.ost = true;
    }
    return false;
}



