$(document).ready(function(){
	
	//if($.browser.msie)
	//{
		//if(Number(jQuery.browser.version)<8)
		//{
			
			//Cufon.replace('h2');
		
			Cufon.replace('#nav a');
			//Cufon.replace('#nav span');
			//Cufon.replace('#nav li');
			
			Cufon.replace('#home-title span');
			Cufon.replace('.imgtxt span');
			Cufon.replace('.box .title');
			Cufon.replace('.home .box .content span');
			Cufon.replace('#breadcrum span');
			Cufon.replace('#image_list span');
			Cufon.replace('h3');
			//Cufon.replace('#release-news p');
		
			//Cufon.replace('.box .content .imgtxt span');
			//Cufon.replace('#subnav li a');
		//}
	//}
	
	//png fix;
    $(document).pngFix();
	
	//intit submenu;
	initMenus();
	
	//target '_blank';
	$("a[rel='external']").click(function(){return !window.open(this.href);});

	$(".win-pop").click(function(){								 
		windowPop($(this).attr("href"));
		return false;
	});
	
	
	//image rotator
	 $('.header_img_bg').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		speed:2000,
		timeout:8000
	});
	 
	//Q & A animation;
	$('.question h4').click(function() {
		var answer_div =  $(this).parent().children(".answer");
		if (answer_div.is(":hidden")) {
		  answer_div.slideDown("slow");
		} else {
		  answer_div.slideUp();
		}
	});
	
	//set up font resize;
	 text_resize_scope = "body";
     text_resize_minimum = "15";
     text_resize_maximum = "25";
     text_resize_line_height_allow = 0;
     text_resize_line_height_min = "15";
     text_resize_line_height_max = "34";
	 
	 inputPrompt('#search-str','Search');
	 
	 base_folder = '/'+'scripts/js/jquery.lightbox-0.5';
     $('#image_list a.img').lightBox();
	 
	$('.contact').click(function() {
			$.modal.close();
			$('.popup').modal({
			opacity:80,
			overlayCss: {backgroundColor:"#000"}
			});
			
			$('#bodyshell, #wrapper,#content,.col,#video , #mediaspace ').attr( 'z-index', '-999' )
			return false;
													  
				});
	
	$('.b-roll').click(function() {
			$.modal.close();
			$('.popup-download').modal({
			opacity:80,
			overlayCss: {backgroundColor:"#000"}
			});
			
			return false;
													  
				});
	
	$('.popup_btn').click(function() {
	
		$.modal.close();
		//alert($(this).attr('href'));
		$($(this).attr('href')).modal({
		opacity:80,
		overlayCss: {backgroundColor:"#000"}
		});
		//return false;
											  
			});
	
	//traget the link by anchor;
	anchorNav();
});


function anchorNav()
{
	var myFile = document.location.toString();
	if (myFile.match('#')) { // the URL contains an anchor
		myAnchor = '#' + myFile.split('#')[1];
		$('a[href="' + myAnchor + '"]').click();
	} 
	
	
}

function inputPrompt(selector, str)
{
	$(selector).val(str);
	$(selector).focus(function() {
		if($(this).val()==str)
		{
	  		$(this).val('');
		}
	});
	$(selector).blur(function() {
		if($(this).val()=='')
		{
		  $(this).val(str);
		}
	});
}


function initMenus() 
{
	//$('ul.menu ul').hide();
	$('ul.nice-menu ul').hide();
	
	var parentTag = $('ul.nice-menu .active').parent("li").children("ul");
	$(parentTag).addClass("animate-active");
	$('ul.nice-menu .active').parents("ul").parents("li").children('a').addClass("active");
	
	// $(".block-nice_menus_single  .menuparent .menuparent").hide();
	 //$(".block-nice_menus_single .menuparent").children("ul").hide();  

		
	  if($(parentTag).hasClass('animate-active'))
	  {
		  $('ul.nice-menu .active').parents("ul").show();
		  $('ul.nice-menu .animate-active').slideDown(900);
		  //$('ul.nice-menu .animate-active').fadeIn('slow');
	  }else{
	  $('ul.nice-menu .active').parents("ul").show();
		  
	}

	

}

function popUp(id)
{
	$.modal.close();
	$(id).modal({
	opacity:80,
	overlayCss: {backgroundColor:"#000"}
	});
	
	return false;
	
}


function windowPop(url)
{
	window.open(url,"Window1","menubar=no,width=530,height=600,toolbar=no,scrollbars=yes");
	
}




