$.bgimg = {}
var resizeTimer = null;

$(document).ready(function()
{
	ScrollUtils.init();
	
	processBGimage();	
		
	/*coding for the h2 tag replace at video page*/
	$('div.contentHolder h2').each(function(i){
 	 $(this).replaceWith("<h1>" + $(this).html() + "<\/h1>");
	});
	/*end*/
	
	$('.contentHolder div:first').show();
	
});

$(window).bind('resize', function()
{
    if (resizeTimer)
    	clearTimeout(resizeTimer);
    resizeTimer = setTimeout(processBGimage, 100);
});

$(window).resize(function() {
	processBGimage();
});

function processBGimage()
{
    var winwidth = $(window).width();
    var winheight = $(window).height();
    
	var imgwidth = $('#fullBG').width();
    var imgheight = $('#fullBG').height();
    
    // if any case, image can't come with width and height
    if(imgwidth == 0 || imgheight == 0)
    {
    	$('#fullBG').css({
            width: winwidth+'px',
            height: winheight+'px'
          });    	
    	
    	imgwidth = $('#fullBG').width();
        imgheight = $('#fullBG').height();    	
    }

    var widthratio = (winwidth / imgwidth);
    var heightratio = (winheight / imgheight);
    
    var widthdiff = (heightratio * imgwidth);
    var heightdiff = (widthratio * imgheight);

    if(heightdiff>winheight) 
    {
    	$('#fullBG').css({
        width: winwidth+'px',
        height: heightdiff+'px'
      });
    } 
    else 
    {
    	$('#fullBG').css({
        width: widthdiff+'px',
        height: winheight+'px'
      });		
    }
}

function topicShowDetails(obj, productId)
{
	var destinationId = '#' + productId;
	var $thisDiv = $(destinationId);

	if ($thisDiv.siblings(':visible').length)
	{
		$thisDiv.siblings(':visible').fadeOut('fast', function()
		{
			$thisDiv.show();
		});
	}
	return false;
}
