			var tab1 = 1;
			var tab2 = 0;
			var tab3 = 0;
			var tab1locked = 1;
			var tab2locked = 0;
			var tab3locked = 0;
			var currentVideoID = 0;

                function loadIntroVideo(videoCategory) {
                    var tempCategory = videoCategory.substring(0,1).toUpperCase() + videoCategory.substring(1,videoCategory.length);

                    document.getElementById('videoThumbnail').src = "images/video_thumbnails/pb_logo.jpg";
                    document.getElementById('videoTitle').innerHTML = "PremierBride.tv - " + tempCategory;
                    document.getElementById('videoDescription').innerHTML = "The best information from PremierBride.tv";
                    document.getElementById('videoStars').style.display = 'block';
                    s1.locked = true;
                    $f('player').stop();
                    $f().unload();
                    $f("player", {src: "flowplayer-3.1.3.swf", wmode: 'opaque'} , {
                            canvas: { backgroundColor: '#000000', backgroundGradient: 'low' },
                            plugins: { controls:  {display: 'none', backgroundColor: '#A7C5FB', backgroundGradient: 'low', timeColor : '#333333', durationColor : '#333333', progressColor: '#4B8DF9', progressGradient: 'medium', bufferColor: '#333333', bufferGradient: 'none', sliderColor: '#333333', sliderGradient: 'none', buttonColor: '#333333', buttonOverColor: '#4B8DF9', volumeSliderColor: '#333333', volumeSliderGradient: 'none', timeBgColor: '#FFFFFF' } },
                            playlist: [ { url: 'intros/'+videoCategory+'_intro.flv', scaling: 'fit', onStart: function() { document.getElementById('adPreRoll').style.display = 'block'; }, onBeforePause: function() { return false; } } ]
                    });
                }

		function loadNewVideo(videoID, loadVideo, newThumbnail, newTitle, newDescription) {
			var preRoll = -1;
			currentVideoID = videoID;

			document.getElementById('adOverlayInner').style.display = 'none';
                        document.getElementById('adOverlay').style.display = 'none';
			$f('player').stop();
			$f().unload(); 

			document.getElementById('videoThumbnail').src = newThumbnail;
			document.getElementById('videoTitle').innerHTML = newTitle;
			document.getElementById('videoDescription').innerHTML = newDescription;
			document.getElementById('videoStars').style.display = 'block'; 
			s1.locked = false;
			s1.setValue(0, false);
			preRoll = getPreRollAd(videoID, loadVideo);
		}

			function activateTab(tabSelect) {
				document.getElementById(tabSelect).className = "videoBestOfTabs_Active";
			}

			function deactivateTab(tabSelect) {
				document.getElementById(tabSelect).className = "videoBestOfTabs_Inactive";
			}

			function tabChanger(tabSelect) {
				if ((tabSelect == 1) && (tab1locked == 0)) {
					if (tab1 == 1) {
						tab1 = 0;
						deactivateTab('bestOfTab_1');
					}
					else {
						tab1 = 1;
						activateTab('bestOfTab_1');
					}
				}
				if ((tabSelect == 2) && (tab2locked == 0)) {
					if (tab2 == 1) {
						tab2 = 0;
						deactivateTab('bestOfTab_2');
					}
					else {
						tab2 = 1;
						activateTab('bestOfTab_2');
					}
				}
				if ((tabSelect == 3) && (tab3locked == 0)) {
					if (tab3 == 1) {
						tab3 = 0;
						deactivateTab('bestOfTab_3');
					}
					else {
						tab3 = 1;
						activateTab('bestOfTab_3');
					}
				}
			}

			function bestOfChange(varTab) {
				if (varTab == 1) { 
					tab1locked = 1;
					tab2locked = 0;
					tab3locked = 0;
					tab1 = 1;
					tab2 = 0;
					tab3 = 0; 
					document.getElementById('videoBestOfContent_1').style.display = 'block';
					document.getElementById('videoBestOfContent_2').style.display = 'none';
					document.getElementById('videoBestOfContent_3').style.display = 'none';
					activateTab('bestOfTab_1');
					deactivateTab('bestOfTab_2');
					deactivateTab('bestOfTab_3');
				}
				else if (varTab == 2) {
					tab1locked = 0;
					tab2locked = 1;
					tab3locked = 0; 
					tab1 = 0;
					tab2 = 1;
					tab3 = 0;
					document.getElementById('videoBestOfContent_1').style.display = 'none';
					document.getElementById('videoBestOfContent_2').style.display = 'block';
					document.getElementById('videoBestOfContent_3').style.display = 'none';
					deactivateTab('bestOfTab_1');
					activateTab('bestOfTab_2');
					deactivateTab('bestOfTab_3');
				}
				else if (varTab == 3) {
					tab1locked = 0;
					tab2locked = 0;
					tab3locked = 1; 
					tab1 = 0;
					tab2 = 0;
					tab3 = 1;
					document.getElementById('videoBestOfContent_1').style.display = 'none';
					document.getElementById('videoBestOfContent_2').style.display = 'none';
					document.getElementById('videoBestOfContent_3').style.display = 'block';
					deactivateTab('bestOfTab_1');
					deactivateTab('bestOfTab_2');
					activateTab('bestOfTab_3');
				}
			}

			function MM_jumpMenu(targ,selObj,restore){ //v3.0
			  	//eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
                                window.open (selObj.options[selObj.selectedIndex].value,"pbwindow");
			  	if (restore) selObj.selectedIndex=0;
			}

			function preloadImages() {
				if (document.images) {
					pre_nav_b1_on = new Image();
					pre_nav_b1_on.src = 'images/ico_fashion_on.png';
					pre_nav_b2_on = new Image();
					pre_nav_b2_on.src = 'images/ico_honeymoons_on.png';
					pre_nav_b3_on = new Image();
					pre_nav_b3_on.src = 'images/ico_planning_on.png';
					pre_nav_b4_on = new Image();
					pre_nav_b4_on.src = 'images/ico_professionals_on.png';
					pre_nav_b5_on = new Image();
					pre_nav_b5_on.src = 'images/ico_relationships_on.png';
					pre_nav_b6_on = new Image();
					pre_nav_b6_on.src = 'images/ico_trends_on.png';
				}
			}

function Left(str, n)
{
   if (n <= 0)
         return "";
   else if (n > String(str).length)
         return str;
   else
         return String(str).substring(0,n);
}

function getXMLHttp()
{
  var xmlHttp

  try
  {
    //Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    //Internet Explorer
    try
    {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
      try
      {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
        alert("Your browser does not support AJAX!")
        return false;
      }
    }
  }
  return xmlHttp;
}

function getPreRollAd(videoID, loadVideo)
{
  var xmlHttp = getXMLHttp();
  var returnBoolAd = -1;
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
        returnBoolAd = placeAd(xmlHttp.responseText);
	if (returnBoolAd > 0) {
				$f("player", {src: "flowplayer-3.1.3.swf", wmode: 'opaque'} , {
					canvas: { backgroundColor: '#000000', backgroundGradient: 'low' },
					plugins: { controls:  {display: 'none', backgroundColor: '#A7C5FB', backgroundGradient: 'low', timeColor : '#333333', durationColor : '#333333', progressColor: '#4B8DF9', progressGradient: 'medium', bufferColor: '#333333', bufferGradient: 'none', sliderColor: '#333333', sliderGradient: 'none', buttonColor: '#333333', buttonOverColor: '#4B8DF9', volumeSliderColor: '#333333', volumeSliderGradient: 'none', timeBgColor: '#FFFFFF' } },
					playlist: [ { url: 'ad_bg.flv', scaling: 'fit', duration: 5, onStart: function() { document.getElementById('adPreRoll').style.display = 'block'; }, onBeforePause: function() { return false; } },
						{ url: loadVideo, scaling: 'fit', onStart: function() { this.getControls().show(); document.getElementById('adOverlay').style.display = 'block'; document.getElementById('adOverlayInner').style.display = 'block'; document.getElementById('adPreRoll').style.display = 'none'; }, onFinish: function() { this.unload(); document.getElementById('adOverlay').style.display = 'none'; document.getElementById('adOverlayInner').style.display = 'none'; } } ]
						});
	}
	else {
				$f("player", {src: "flowplayer-3.1.3.swf", wmode: 'opaque'} , {
					canvas: { backgroundColor: '#000000', backgroundGradient: 'low' },
					plugins: { controls:  {display: 'none', backgroundColor: '#A7C5FB', backgroundGradient: 'low', timeColor : '#333333', durationColor : '#333333', progressColor: '#4B8DF9', progressGradient: 'medium', bufferColor: '#333333', bufferGradient: 'none', sliderColor: '#333333', sliderGradient: 'none', buttonColor: '#333333', buttonOverColor: '#4B8DF9', volumeSliderColor: '#333333', volumeSliderGradient: 'none', timeBgColor: '#FFFFFF' } },
					playlist: [ 
						{ url: loadVideo, scaling: 'fit', onStart: function() { this.getControls().show(); document.getElementById('adOverlay').style.display = 'none'; document.getElementById('adOverlayInner').style.display = 'none'; document.getElementById('adPreRoll').style.display = 'none'; }, onFinish: function() { this.unload(); document.getElementById('adOverlay').style.display = 'none'; document.getElementById('adOverlayInner').style.display = 'none'; } } ]
						});
	}
    }
  }

  var xmlURL = "ajax/local_ad_insert.php?videoid=" + currentVideoID;
  xmlHttp.open("GET", xmlURL, true);
  xmlHttp.send(null);
}

function placeAd(response)
{
	boolAd = Left(response, 1);
        var originalCopy = String(response).substring(1, String(response).length - 1);
        var newCopy = originalCopy.split("|||");
        if (boolAd == 1) {
            document.getElementById('adContainer').innerHTML = newCopy[0];
	}
	else {
            document.getElementById('adPreRoll').style.display = 'none';
            document.getElementById('adOverlayInner').style.display = 'none';
	}
        if (newCopy[1].length > 1) {
            document.getElementById('categoryVideoAd').innerHTML = newCopy[1];
        }
	return parseInt(boolAd);
}
