//Cufon Replace
Cufon.replace('.heading1, .heading2, .heading3, .heading4, .heading5, .heading6, .heading7, .heading8, .heading9, .heading10, .heading11, .heading12, .heading13, .heading14, .heading15, .home_selected, .usingcredit_selected, .last, #black_label_639, #video_title_bucket, .video_title_bucket, .hide, .home_selected, .last, #video_title, #video_title_bucket, .maintainingcredit_selected, .askanexpert, .creditbasic_selected, .check');

// JavaScript Document

// Removes leading whitespaces
function LTrim(testUrl)
{       
	  var re = /\s*((\S+\s*)*)/;
	  return testUrl.replace(re, "$1");         
}
// Removes ending whitespaces 
function RTrim(testUrl)
{       
	  var re = /((\s*\S+)*)\s*/;
	  return testUrl.replace(re, "$1");      
}
// Removes leading and ending whitespaces
function trim(testUrl)
{
      return LTrim(RTrim(testUrl));
}

/* Change the Color of the Text inside the Search Textbox in the ASK AN EXPERT page, when a user clicks in the TEXTBOX */

function namechange()

{
	document.getElementById("search_close").style.display = 'block';
	
	if (document.getElementById("search_textbox").value == 'Ask your question here...')

	{

		document.getElementById("search_textbox").value = '';
		document.getElementById("search_textbox").style.color = "#000";
	}

	if (document.getElementById("search_textbox").value != '' && document.getElementById("search_textbox").value != 'Ask your question here...')

	{
		document.getElementById("search_textbox").style.color = "#000";
	}

}



/* Change the Color of the Text inside the Search Textbox in the ASK AN EXPERT page, when a user clicks outside the TEXTBOX */

function namechangeinact()

{

	if (trim(document.getElementById("search_textbox").value) == '')

	{
		document.getElementById("search_close").style.display = 'none';
 		document.getElementById("search_textbox").style.color = "#7d7d7d";
 		document.getElementById("search_textbox").value = 'Ask your question here...';
 	}

	else if (trim(document.getElementById("search_textbox").value) == 'Ask your question here...')

	{
 		document.getElementById("search_textbox").style.color = "#7d7d7d";
  	}

}


/*****FONT REZISING*******/

/*****FONT REZISING*******/

var originalFontSize=8;

var fontIncrease=0;

var fontDecrease=0;

var fontSize = 0 ;

function increaseFontSize() {   

                //console.log($('.content_right').html());

                if($('.content_right').html() !== null){

                                

                                //console.log("in increase1: " + parseInt($('.content_right').css("font-size")));

                                fontSize = parseInt($('.content_right').css("font-size"));

                                if(fontSize >= 14 && fontSize < 16){

                                                originalFontSize=  parseInt($('.content_right,.lastline').css("font-size"))+1;

                                                //console.log('Apply to Increase:  '+originalFontSize);

                                                $('.content_right, .lastline, .content_right li li,.content_right_tit').css('font-size', originalFontSize);

                                }

                } else if($('.content_right_abt').html() !== null){

                                //console.log("in increase2: " + parseInt($('.content_right_abt').css("font-size")));

                                fontSize = parseInt($('.content_right_abt').css("font-size"));

                                if(fontSize >= 12 && fontSize < 14){

                                   originalFontSize=  parseInt($('.content_right_abt,.lastline,.content_right_tit').css("font-size"))+1;

                                  // console.log('Apply to Increase2:  '+originalFontSize);

                                   $('.content_right_abt,.lastline, .content_right li li,.content_right_tit').css('font-size', originalFontSize);

                                }

                } else {

                                //console.log("in increase3: " + parseInt($('#left_white_bg').css("font-size")));

                                fontSize = parseInt($('#left_white_bg').css("font-size"));

                                if(fontSize >= 14 && fontSize < 16){

                                   originalFontSize=  parseInt($('#left_white_bg,.lastline').css("font-size"))+1;

                                   $('#left_white_bg, .lastline, .content_right li li,.content_right_tit').css('font-size', originalFontSize);

                                }

                                

                }

}

function decreaseFontSize() {

                if($('.content_right').html() !== null){

                                //console.log("in decrease: " + parseInt($('.content_right').css("font-size")));

                                fontSize = parseInt($('.content_right').css("font-size"));

                                if(fontSize > 14 && fontSize <= 16){

                                                originalFontSize=  parseInt($('.content_right').css("font-size"))-1;

                                                //console.log('Apply to Decrease:  '+originalFontSize);

                                                $('.content_right,.lastline, .content_right li li,.content_right_tit').css('font-size', originalFontSize);

                                                

                                }

                

                } else if($('.content_right_abt').html() !== null){

                                //console.log("in decrease: " + parseInt($('.content_right').css("font-size")));

                                fontSize = parseInt($('.content_right_abt').css("font-size"));

                                if(fontSize > 12 && fontSize <= 14){

                                                originalFontSize=  parseInt($('.content_right_abt').css("font-size"))-1;

                                                //console.log('Apply to Decrease:  '+originalFontSize);

                                                $('.content_right_abt,.lastline, .content_right li li.content_right_tit').css('font-size', originalFontSize);

                                                

                                }

                                

                } else {

                                fontSize = parseInt($('#left_white_bg').css("font-size"));

                                if(fontSize > 14 && fontSize <= 16){

                                                originalFontSize=  parseInt($('#left_white_bg').css("font-size"))-1;

                                                //console.log('Apply to Decrease:  '+originalFontSize);

                                                $('#left_white_bg,.lastline, .content_right li li').css('font-size', originalFontSize);

                                                

                                }                              

                }

}

/*var originalFontSize=8;
var fontIncrease=0;
var fontDecrease=0;
function increaseFontSize() {  
   originalFontSize=  parseInt($('.content_right').css("font-size"))+1;
   if(fontIncrease==0 || fontIncrease==1){
       $('.content_right').css('font-size', originalFontSize);
    fontIncrease=fontIncrease+1;
   }
}
function decreaseFontSize() {
    originalFontSize=  parseInt($('.content_right').css("font-size"))-1;
      if(fontDecrease==0 || fontDecrease==1){
       $('.content_right').css('font-size', originalFontSize);
    fontDecrease=fontDecrease+1;
   }
}

var min=8;
var max=18;
function increaseFontSize() {
 
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
 
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
 
         var s = 12;
      }
      if(s!=max) {
 
         s += 1;
      }
      p[i].style.fontSize = s+"px"
 
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
 
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
 
         var s = 12;
      }
      if(s!=min) {
 
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
 
   }
}

*/




/**********CREDIT DICT POPUP STARTS HERE***********/
 $(function(){
 
   $('a.button_credit_dictonary[href^=#]').click(function() {
    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/credit_dict_close_btn.png"  title="Close Window" alt="Close" /></a>');
    //Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css
    var popMargTop = ($('#' + popID).height() + -50) / 2;
    var popMargLeft = ($('#' + popID).width() + 80) / 2;
    //Apply Margin to Popup
    $('#' + popID).css({
     'margin-top' : -popMargTop,
     'margin-left' : -popMargLeft
    });
    //Fade in Background
    $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
     $('body').css("overflow","hidden");
    $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies 
    return false;
   });
   //Close Popups and Fade Layer
   $('a.close').live('click', function() { //When clicking on the close or fade layer...
    $('body').css("overflow","auto");
    $('#fade , .popup_block').fadeOut(function() {
     $('#fade, a.close').remove();  //fade them both out
    });
    return false;
   });   
  });
  
  /** ********CREDIT DICT POPUP STARTS HERE********** */

$(function() {


$('a.button_textversion[href^=#]')

.click(

function() {

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/credit_dict_close_btn.png" title="Close Window" alt="Close" /></a>');

// Define margin for center alignment (vertical

// horizontal) - we add 80px to the height/width to

// accomodate for the padding and border width defined

// in the css

var popMargTop = ($('#' + popID).height() + -100) / 2;

var popMargLeft = ($('#' + popID).width() + 80) / 2;

// Apply Margin to Popup

$('#' + popID).css({

'margin-top' : -popMargTop,

'margin-left' : -popMargLeft

});

// Fade in Background

$('body').append('<div id="fade"></div>'); // Add the

// fade

// layer to

// bottom of

// the body

// tag.

$('body').css("overflow", "hidden");

$('#fade').css({

'filter' : 'alpha(opacity=40)'

}).fadeIn(); // Fade in the fade layer -

// .css({'filter' :

// 'alpha(opacity=80)'}) is used to fix

// the IE Bug on fading transparencies

return false;

});

// Close Popups and Fade Layer

$('a.close').live('click', function() { // When clicking on the close or

// fade layer...

$('body').css("overflow", "auto");

$('#fade , .popup_block').fadeOut(function() {

$('#fade, a.close').remove(); // fade them both out

});

return false;

});


});
  
  $(document).keydown(function(e) {
    // ESCAPE key pressed
    if (e.keyCode == 27) {
       var dis=($("#credit_dictinoary_main").css("display"));
       if(dis=="block"){
       $('body').css("overflow","auto");
       }
    }
});
  
function PopupCenter(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
/**********CREDIT DICT POPUP ENDS HERE***********/
