var theModelCarousel = null;
$(function(){
		Cufon('#menu ul li a', {hover:{color: '#F6DD2F'} });
	Cufon.replace('#menu ul li a, .earn_heading, .capital_heading, .important, .fiftyper, .more, .cash, .earn_wrapper h2, .earn_wrapper h1, .earn_wrapper h3,.earn_wrapper h2, .morebenefits h2,.morebenefits h1, .get_more h3, .re_cash h3, .cashback h3, .box .fltlft_cont h4, .redeem_content h2, #white_wrapper .odd_row1 div, ul#tabs li a h3, ul#tabs li a h2, #white_wrapper .even_row h5, #white_wrapper .odd_row h5, .have_MoreFun h3, #buzz_wrapper h2, .consumer, .consumer1, .F_columns h2, #popup_name h2, div.subheading, .numbers, .green_num, .redeem_content div.heading, .get_more div.sub_heading, .re_cash div.sub_heading, .cashback div.sub_heading, .box .fltlft_cont div.contheading, #cluetip .header_txt, .cont_earn_popup h2, .cont_earn_popup h3, .firstseccol h2, .firstseccol h3, .one, .per, .plus1, .fifty, .dollar, .hundred, .unlimited, .bonus_year, .onetime, #popup_capitalone h2, #popup_thecapital h2, .trademarks, .content_b, .circle_text, ul#output li p.posrel, .earn_wrapper p, .morebenefits p, .secondcol p,.compareCashTbl td ,#Comparecashrewardsnow,.compareCashTbl h3');
		$('a.poplight[href^=#]').click(function(e) {
    var popID = $(this).attr('rel'); //Get Popup Name
    var popURL = $(this).attr('href'); //Get Popup href to define size

    //Pull Query & Variables from href URL
    var query= popURL.split('?');
    var dim= query[1].split('&');
    var popWidth = dim[0].split('=')[1]; //Gets the first query string value

    //Fade in the Popup and add close button
    $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="images/close_onOverlay.png" class="btn_close" title="Close Window" alt="Close" /></a>');
	
	if(popID == "popup_video"){
		var carVideo=$("#mycarousel").html();
$("#mycarousel").html(carVideo);
		 jQuery('#mycarousel').jcarousel({
		 //initCallback: modelCarousel_initCallback,
			vertical: true,
			scroll: 1,
			start: 1
		});
		//clearModelCarousel();
	}

    //Define margin for scenter alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css
	
function modelCarousel_initCallback(carousel) {
theModelCarousel = carousel;
};
function clearModelCarousel() {
theModelCarousel.reset();
}
	var windowHeight = document.documentElement.clientHeight;
	var scrollTop = $(window).scrollTop();
	var scrollLeft =$(window).scrollLeft();
	var winWidht =$(window).width();;

var popMargTop = ($('#' + popID).height() + -windowHeight) / 2;	
    var popMargLeft = (winWidht-$('#' + popID).width() ) / 2;
//if(buzzClass=="poplight buzz_tag"){popMargTop =popMargTop -2700}

    //Apply Margin to Popup
    $('#' + popID).css({
        'top' : scrollTop+125,
        'left' : popMargLeft
        
    });
    

    //Fade in Background
    $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
    $('#fade').css({'filter' : 'alpha(opacity=80)','position':'fixed'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies 
loadVideoYou('oleLJTV7xB4');
    return false;
});

//Close Popups and Fade Layer
$('a.close').live('click', function() { //When clicking on the close or fade layer...
    $('#fade , .popup_block').fadeOut(function() {
        $('#fade, a.close').remove();  //fade them both out
		$('#youtubeVideoObj').remove();
    });
    return false;
});

/*$('#twitter').click(function(){
					 $('#fade , .popup_block').fadeOut(function() {
						$('#fade, a.close').remove();  //fade them both out
						
					});
				 });*/
	
});
function show_info()
{	
$('#cluetip').attr('style','display:none');
	for(i=7;i<=11;i++)
		{
			if(document.getElementById("comp_cash"+i).style.display=='none')
			{ 
			
			document.getElementById("comp_cash"+i).style.display='';
			//document.getElementById('ImgId').className = "collapse";
			//document.getElementById("showinfo").style.display='none';
			//document.getElementById("Collapse").style.display='block';
			document.getElementById('seemore').style.display='none';
			document.getElementById('collapse').style.display='';
			}
			else	
			{
				document.getElementById("comp_cash"+i).style.display='none';
				//document.getElementById('ImgId').className = "showmore";
				//document.getElementById("Collapse").style.display='none';
				//document.getElementById("showinfo").style.display='block';
				document.getElementById('seemore').style.display='';
				document.getElementById('collapse').style.display='none';
			}
		}
}
function copy2cb()
{
  var ta= document.getElementById ('caponecash');
  var d= document.getElementById ('urlbox');
  // Transfer the text from the DIV to the hidden textarea
  ta.innerText= d.innerText;
  // create the text range
  var t= ta.createTextRange ();
  // do this if you wanna remove the format of the text within
  t.execCommand('RemoveFormat');
  // Then execute the copy command
  t.execCommand('Copy');
  //If itâ€™s FireFox, then sets the
	// â€œsigned.applets.codebase_principal_supportâ€� to TRUE
if (navigator.userAgent.indexOf("Firefox")!=-1)
  user_pref("signed.applets.codebase_principal_support", true); 
} 
function copy2cbembed()
{
  var ta= document.getElementById ('flashcode');
  var d= document.getElementById ('embedcode');
  // Transfer the text from the DIV to the hidden textarea
  ta.innerText= d.innerText;
  // create the text range
  var t= ta.createTextRange ();
  // do this if you wanna remove the format of the text within
  t.execCommand('RemoveFormat');
  // Then execute the copy command
  t.execCommand('Copy');
    //If itâ€™s FireFox, then sets the
	// â€œsigned.applets.codebase_principal_supportâ€� to TRUE
if (navigator.userAgent.indexOf("Firefox")!=-1)
  user_pref("signed.applets.codebase_principal_support", true); 

} 

function changeColor(curr)
{
	$('#menu ul li').removeClass('CHactive');
	$(curr).parent('span').parent('li').addClass("CHactive");	
	var currId = curr.id;
	textColorChange(currId);
	/*Cufon.replace(currId,{color:'#F6DD2F'});*/
	
}
function chnageCCC(){
	$('#menu ul li').removeClass('CHactive');
	$('#nav2').parent('span').parent('li').addClass("CHactive");	
	}

function textColorChange(currId)
{
	for(var i=1;i<6;i++)
	{
		if(currId == 'nav'+i)
		{
			Cufon.replace('#'+currId,{color:'#F6DD2F'});
		}
		else
		{
			var ch = 'nav'+i;
			Cufon.replace('#'+ch,{color:'#FFFFFF'});
		}
	}
}
/*function deselectColor()
{
	
	Cufon.replace('#navTabs li a',{color:'#FFFFFF'});
	
	
}*/
function deselectColor(currElem)
{
	var currId = currElem.id;
	Cufon.replace(currId,{color:'#FFFFFF'});
	if(document.getElementById(currId).className != '')
	{
		if(document.getElementById(currId).className == 'active')
		{
			Cufon.replace(currId,{ color:'#F6DD2F'});
		}
	}
	if(document.getElementById(currId).className == '')
	{
		Cufon.replace(currId, { color:'#FFFFFF'});
	}
	
}

function changeColorMB(currId)
{
	Cufon.replace('ul#tabs li a h3', {color: '#5C5C5C'});
	for(var i=1;i<5;i++)
	{
		if(currId == 'mB'+i)
		{
			Cufon.replace('#'+currId,{color:'#bd2931'});
		}
		else
		{
			var ch = 'mB'+i;
			Cufon.replace('#'+ch,{color:'#5C5C5C'});
		}
	}
	
	
}
function changeHoverColorMB(currParId,currId)
{
	    if(document.getElementById(currParId).className == 'benefit_tag current selTab')
		{
			var arr = document.getElementById(currParId).getElementsByTagName('H2');
			
			var arrId = arr[0].id;
			Cufon.replace('#'+arrId,{color:'#bd2931'});
					
		}
		else
		{
			Cufon.replace('#'+currId,{color:'#bd2931'});
		}
}


function mouseOutColorMB(currParId,currId){
	 if(document.getElementById(currParId).className == 'benefit_tag current selTab')
		{

			var arr = document.getElementById(currParId).getElementsByTagName('H2');
			
			var arrId = arr[0].id;
			Cufon.replace('#'+arrId,{color:'#bd2931'});
			
		}
		else
		{
			Cufon.replace('#'+currId,{color:'#5C5C5C'});
		}
}
/*function openWindow(l,w,opt)
{
	window.open(l,w,opt);
	
	}*/
	function changeUrl(catNum)
{
	
		var axel = Math.random() + "";
	var a = axel * 10000000000000;
	var url = 'http://fls.doubleclick.net/activityi;src=3243857;type=cashc226;cat='+catNum+';ord=' + a + '?';
	var tempobj=document.all? document.all['cashCardLM'] : document.getElementById('cashCardLM');
	$('#FloodlightTagging').attr('src', url);	
		redirectTime();
}
function redirectTime()
{
	var setT=setTimeout("redirectPage()",1500);
}

function redirectPage(){

}
function loadVideoYou(obj){	
	
	 $('#youtubeVideoObj').remove();	 
	  var link='<object id="youtubeVideoObj" width="600" height="369"><param id="youtubePM name="movie" value="http://www.youtube.com/v/'+obj+'?version=3&rel=0&border=0&fs=1&autoplay=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed id="youtubeEM" src="http://www.youtube.com/v/'+obj+'?version=3&rel=0&border=0&fs=1&autoplay=1&amp;hl=en_US" type="application/x-shockwave-flash" width="600" height="369" allowscriptaccess="always" allowfullscreen="true"></embed></object>'
	  $('#playerContainer').html(link);
	  		
}
$(document).ready(function() {
	var delay=8000;	
	var ver = getInternetExplorerVersion();
	  if ( ver > -1 )
  {
    if ( ver == 7.0 ){ 
    delay=10000;
  }}  
  setTimeout("bannerWelcome()",delay);  
	if(/iPad/.test(navigator.userAgent)) {
		window.onscroll = function() {
			document.getElementById("header").style.position="absolute";
			document.getElementById("header").style.top = window.pageYOffset+'px';
		};
	}
  });
  function bannerWelcome(){	 
	$('#banner1').attr('style','display:none');
	 $('.page2').addClass('active'); 
	 $('.page1').removeClass('active');
	 $('#banner2').attr("style","display:block");
	}
	function getInternetExplorerVersion()
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

/*	Callback function for CUFON fonts	*/

function cufonCall() {
	Cufon('#menu ul li a', {hover:{color: '#F6DD2F'} });
	Cufon.replace('#menu ul li a, .capital_heading, .earn_heading, .important, .circle_2_value, #buzz_wrapper h2');
}
/*$('.earntag').click(function(){
	$('#cluetip').attr("style","display:none");	
	});*/	
