Cufon.replace('.hb',{ fontFamily: 'HelveticaBlack' });
Cufon.replace('.hv',{ fontFamily: 'Helvetica' });
Cufon.replace('.salto',{ fontFamily: 'Salto' });

 $(document).ready(function() {
   	$('#videogirl_nav .vg').bind("mouseenter",function(){
		$('#' + this.id + ' .vg_nav_over').removeClass('hidden');	
		$('#' + this.id + ' .vg_nav').addClass('hidden');
	})
	.bind("mouseleave",function(){
		$('#' + this.id + ' .vg_nav').removeClass('hidden');	
		$('#' + this.id + ' .vg_nav_over').addClass('hidden');
		//Cufon.refresh();
	})
	.bind("click",function(){
		window.location.href = $('#' + this.id + ' a').attr('href');
		//Cufon.refresh();
	});
	
	findimg();
 });
 
 
 
 
 function trackClick(tracking_var,type){
	 MATTEL.tracker.Tracker.enableShortCuts();
	Tracker.name = tracking_var;
	Tracker.campaign = CAMPAIGN.VIDEOGIRL;
	Tracker.channel = CHANNEL.FRIENDS;
	if (type == '' || type == null){
		Tracker.contenttype = CONTENTTYPE.BUTTON;
		Tracker.action = ACTION.CLICK;
		//alert('button');
	}
	if (type == 'download'){
		Tracker.contenttype = CONTENTTYPE.DOWNLOAD;
		Tracker.action = ACTION.CLICK;
		//alert('download');
	}
	if(type == 'findonline')
	{
		Tracker.action = ACTION.SEETOYS;
		Tracker.contenttype = CONTENTTYPE.BUTTON;
	}
	//Tracker.action = ACTION.CLICK;
	Tracker.track();
 }
 
 
 function trackView(tracking_var,type){
	 MATTEL.tracker.Tracker.enableShortCuts();
	Tracker.name = tracking_var;
	Tracker.campaign = CAMPAIGN.VIDEOGIRL;
	Tracker.channel = CHANNEL.FRIENDS;
	if (type == "" || type == null){
		Tracker.contenttype = CONTENTTYPE.LANDINGPAGE;
	}
	if (type == 'demo'){
		//alert('demo');
		Tracker.contenttype = CONTENTTYPE.PRODUCTDEMO;
	}
	Tracker.action = ACTION.VIEW;
	Tracker.track();
 }
 
 
 
 function findimg()
{
 var imgs,i;
// loop through all images of the document
 imgs=document.getElementsByTagName('img');
 for(i=0;i<imgs.length;i++)
 {
// test if the class 'roll' exists
  if(/roll/.test(imgs[i].className))
  {
// add the function roll to the image onmouseover and onmouseout and send
// the image itself as an object
   imgs[i].onmouseover=function(){roll(this);};
   imgs[i].onmouseout=function(){roll(this);};
  }
 }
}


function roll(o){
 var src,ftype,newsrc;
 // get the src of the image, and find out the file extension
 

	 src = o.src;
	 ftype = src.substring(src.lastIndexOf('.'), src.length);
	 // check if the src already has an _on and delete it, if that is the case 
	 if(/_ro/.test(src)){
	  newsrc = src.replace('_ro','');
	  $(o).removeClass('on');
	  }else{
	  // else, add the _on to the src 
	  newsrc = src.replace(ftype, '_ro'+ftype);
	  $(o).addClass('on');
	  }
	 o.src=newsrc;
}



//additional properties for jQuery object
var y_pos = 0;

$(document).ready(function(){
   //align element in the middle of the screen

   $.fn.alignCenter = function() {
      //get margin left
      var marginLeft = Math.max(40, parseInt($(window).width()/2 - $(this).width()/2));
      //get margin top

		var marginTop = Math.max(40, parseInt($(window).height()/2 - $(this).height()/2));
	
	if (marginTop <= 0){
		marginTop = 30;
	}
	  //return updated element
	  //alert('Aligning!' + marginLeft + ' ' + marginTop);
      //return $(this).css({'margin-left':marginLeft + 'px', 'margin-top':marginTop + 'px'});
	  if($.browser.msie && $.browser.version=="6.0"){
		 return $(this).css({'left':marginLeft + 'px', 'top':marginTop + 40 + 'px','position':'absolute'}); 
	  }
	  else {
	  	return $(this).css({'left':marginLeft + 'px', 'top':marginTop + 'px'});
	  }
   };


});

function popupClose(id, fade)
{
   if (fade == undefined) fade = 'fade';
   $('#' + fade).addClass('hidden').removeAttr('style');
   $('#' + id).addClass('hidden');

   return false;
}

function popupCloseAlt(id, fade)
{
   if (fade == undefined) fade = 'fade';
   $('#' + id).addClass('hidden');
   return false;
}

function popupHide(id) {
   $('#' + id).addClass('hidden');
};

function fadeIn(fade) {
	if (fade == undefined) fade = 'fade';
	   if ($.browser.msie) $('#' + fade).height($(document).height()).removeClass('hidden');
	   else $('#' + fade).height($(document).height()).removeClass('hidden').fadeTo('slow', 0.7);
}

function popupShow(id, fade)
{
   
 	//alert(id);
   
   if (fade == undefined) fade = 'fade';
   if ($.browser.msie) $('#' + fade).height($(document).height()).removeClass('hidden');
   else $('#' + fade).height($(document).height()).removeClass('hidden').fadeTo('slow', 0.7);
   $(document).bind('keyup', function(e)
   {
      e = e || event;
      if (e.keyCode == 27) popupClose(id, fade);
   });   
   $('#' + id).alignCenter().removeClass('hidden');
   $('#' + fade).click(function(){
		popupClose(id, fade);						
   });

  
   return false;
}

