var mi = null;
var JQ = jQuery.noConflict(true);







var marquees = Array();
var marqint = Array();

function showMarquee(wat) {
 clearTimeout(marqint[wat]);
 if (!marquees[wat]) {
   marquees[wat]=0;
   JQ("#marquee"+wat+" div").css({'opacity':0});
//   JQ("#marquee"+wat+" div").eq(marquees[wat]).css({'opacity':1});
 } else {
  JQ("#marquee"+wat+" div").eq(marquees[wat]).animate({ opacity: 0 }, 250);
 }
 marquees[wat]++;
 aantal = JQ("#marquee"+wat+" div").length;
 if (marquees[wat]>=aantal) marquees[wat] = 0;
 JQ("#marquee"+wat+" div").eq(marquees[wat]).animate({ opacity: 1 }, 250);
 marqint[wat] = setTimeout("showMarquee("+wat+")", 2000);
}







JQ(document).ready(function() {

function isScrolledIntoView(elem)
{
    var docViewTop = JQ(window).scrollTop();
    var docViewBottom = docViewTop + JQ(window).height();

    var elemTop = JQ(elem).offset().top;
    var elemBottom = elemTop + JQ(elem).height();

    return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}

var previewShown = false;
function showPreview() {
 if (JQ("#webcamvidholder")) {
  // alert("*"+JQ("#webcamvidholder").text()+"*");
  //  width:'194',
  //  height:'146',
  JQ('#webcamvidholder').flash({
   swf:'assets/swf/player.swf',
   width:'234',
   height:'176',
   allowScriptAccess: 'always',
   allowFullScreen: 'true',
   controlbar: "none",
   scale: 'noscale',
   bgcolor:'#FFFFFF',
   flashVars:'bufferlength=5&icons=false&controlbar=false&mute=true&autostart=true&file=../video/'+JQ("#webcamvidholder").text()+'&repeat=always&shuffle=false',
   wmode:'opaque'
   }
  );
  previewShown = true;
 }
}



JQ(window).scroll(function(){
 // JQ("porno-video-1").html("<b>Scrolling</b>");
 if (JQ("#webcamvidholder") && !previewShown) {
  if (isScrolledIntoView(JQ("#webcamvidholder"))) showPreview();
//  if (isScrolledIntoView(JQ("#marquee1"))) showMarquee(1);
 }
});




 JQ("#navnext").mouseenter(function() {
  var curmargin = Math.abs(JQ("#nav").css("margin-left").replace("px", ""));
  var remtime = (1 - (curmargin/500)) * 2000;
  JQ("#nav").animate({marginLeft:-500},  { queue: false, duration: remtime });
 });

 JQ("#navnext").mouseleave(function() {
  JQ("#nav").stop(true);
 });

 JQ("#navprev").mouseenter(function() {
  var curmargin = Math.abs(JQ("#nav").css("margin-left").replace("px", ""));
  var remtime = (1 * (curmargin/500)) * 2000;
  JQ("#nav").animate({marginLeft:21},  { queue: false, duration: remtime });
 });

 JQ("#navprev").mouseleave(function() {
  JQ("#nav").stop(true);
 });


/*
 JQ('#chatwindow').flash({
  swf:'http://www.livevideochat.nl/vchat/vchat.swf?nce=1323618757',
  width:'231',
  height:'141',
  allowScriptAccess: 'always',
  allowFullScreen: 'true',
  scale: 'noscale',
  bgcolor:'#FFFFFF',
  wmode:'opaque'
  }
 );
*/

 if (JQ("#telsexflash1")) {
  JQ('#telsexflash1').flash({
   swf:'assets/swf/1on1bellen.swf',
   width:'100%',
   height:'336',
   allowScriptAccess: 'always',
   allowFullScreen: 'true',
   scale: 'noscale',
   bgcolor:'#FFFFFF',
   flashVars:'',
   wmode:'opaque'
   }
  );
 }
 if (JQ("#telsexflash2")) {
  JQ('#telsexflash2').flash({
   swf:'assets/swf/1on1bellen2.swf',
   width:'100%',
   height:'236',
   allowScriptAccess: 'always',
   allowFullScreen: 'true',
   scale: 'noscale',
   bgcolor:'#FFFFFF',
   flashVars:'',
   wmode:'opaque'
   }
  );
 }

 // eerste keer check (als window ververst wordt en into view)
 if (JQ("#webcamvidholder") && !previewShown) {
  if (isScrolledIntoView(JQ("#webcamvidholder"))) showPreview();
//  if (isScrolledIntoView(JQ("#marquee1"))) showMarquee(1);
 }

showMarquee(1);

 if (JQ("#webcamvidholder")) {
/*
JQ.getScript('http://prerollads.nl/watch/pnpthumb/160x120/chicks%20voor%20geld.js?p=1363&pi=privecamnl&sort=rand&bc=BD0000&row=1&col=1&sp=6&bt=1', function(data, textStatus){
   console.log(data); //data returned
   console.log(textStatus); //success
   console.log('Load was performed.');
});
*/
// JQ("#porno-video-1").html("<script type='text/javascript' src='http://prerollads.nl/watch/pnpthumb/160x120/chicks%20voor%20geld.js?p=1363&amp;pi=privecamnl&amp;sort=rand&amp;bc=BD0000&amp;row=1&amp;col=1&amp;sp=6&amp;bt=1'></script>");

 }

/*
 JQ('a[rel*=lightbox]').attr("title", function(i, val) {
  return "&lt;a href=&quot;link.html&quot;&gt;my link&lt;/a&gt;" + val
 });
*/

 JQ('a[rel*=lightbox]').lightBox(); 

 JQ("a.blank").attr("target","_blank");

/*
 JQ("a.islive-movie").click(function() {
  alert('Handler for .click() called.');
  return false;
 });
*/

});

/*
$('a').each(function(el) {
 var str = el.get('href');
 el.set("target", "_blank");
});
*/


function getVid(linkje, vidid) {
// JQ("#"+vidid).html("<b>Pipo</b>");
  JQ("#"+vidid).flash({
   swf:'http://custom.islive.nl/_style20/privewebcam/swf/player.swf',
   width:'200',
   height:'150',
   allowScriptAccess: 'always',
   allowFullScreen: 'true',
   scale: 'noscale',
   bgcolor:'#FFFFFF',
   flashVars:'bufferlength=5&icons=true&controlbar=none&mute=false&autostart=true&file='+linkje.href+'&repeat=always&shuffle=false',
   wmode:'opaque'
   }
  );

 return false;
}

function goChatAdmin() {
 var naam = JQ("#msg").val();
 if (!naam) {
  alert("Je moet een chatnaam invullen!");
  return false;
 }
 var w = 231;
 var w = 253;
 var h = 600;
 var trans = "opaque";
 var ts = (new Date()).getTime();

 JQ("#chat").animate({
    height: 600
  }, 1000, function() {
    // Animation complete.
   JQ.post('vchat.php', { uname: naam, usex: "M" }, function(data) {
    // JQ("#chat").html(data);
    JQ("#chat").html("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\""+w+"\" height=\""+h+"\" id=\"vchat\" align=\"middle\"><param name=\"wmode\" value=\""+trans+"\" /><param name=\"allowScriptAccess\" value=\"sameDomain\" /><param name=\"movie\" value=\"http://www.livevideochat.nl/vchat/vchat.swf?nce=?"+ts+"\" /><param name=\"quality\" value=\"high\" /><param name=\"scale\" value=\"noscale\" /><param name=\"salign\" value=\"lt\" /><param name=\"bgcolor\" value=\"#ffffff\" /><embed src=\"http://www.livevideochat.nl/vchat/vchat.swf?nce=?"+ts+"\" quality=\"high\" scale=\"noscale\" salign=\"lt\" bgcolor=\"#ffffff\" width=\""+w+"\" height=\""+h+"\" name=\"ch14a_duch_800600_6a_en_try7c_pwin\" align=\"middle\" allowScriptAccess=\"sameDomain\" wmode='"+trans+"' type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></object>");
   });


  });
  return false;
}
function goChat() {
 goChatAdmin();
}

function startchat(cam, pid)
	{
		window.open('http://www.payswitch.com/payment/wallet/pay.php?m=' + cam + '&pi='+pid, 'wallet', 'height=705,width=860');
		return false;
	}


function zegiets(wie, nr) {
 window.open('talk.php?wie=' + wie + '&nr='+nr, 'talktalk', 'height=255,width=860');
 return false;
}




function bookmark(anchor){
            if(window.external){
              window.external.AddFavorite(anchor.href, anchor.title);
              return false;
            }
            return true;
}



function getTalk(wat) {
 var boxnr = wat.replace("lptalk", "");
 JQ("#"+wat).css("background-color", "#64AD02");
 JQ("#"+wat).css("background-image", "none");
 JQ("#"+wat).css("overflow", "auto");

 var xhr = JQ.get('gettalk.php', { id: boxnr }, function(data) {
  JQ("#"+wat).html(data);
 });
 xhr.success(function() { 
  JQ("#lpbox"+boxnr).animate({    height: 592  }, 1000 );
  JQ("#"+wat).animate({    height: 300  }, 1000 );

 JQ("#lpbox"+boxnr).mouseleave(function() {
  if (JQ("#"+wat).css("background-image") == "none") {
   JQ("#"+wat).css("height", "25px");
   JQ("#lpbox"+boxnr).css("height", "314px");
   JQ("#"+wat).css("background-image", "url(/assets/images/liveprive-box-talk.png)");
   JQ("#"+wat).css("overflow", "hidden");

  }
 });


 });

}

