// JavaScript Document
// JavaScript Document
function hidenText(obj)
{
	obj.value='';
}
function showText(obj)
{
	var text=obj.value;
	var text_temp=jQuery('#tt-temp').html();
	//alert(text);
	if(!text)
		obj.value=text_temp;
}

//add class li-first and li-final at area-menu
function removePadding(id)
{
	var id_1=jQuery(id);
	if(id_1)
	{
		var all_li_1=id_1.find('a');
		//alert(all_li_1);
		all_li_1.first().css('padding-left','15px');
	}
}
function setFullWidth(id,parent_id)
{
	if(jQuery(id))
	{
		var text_col_2=jQuery(id).find('div').first();
		if(text_col_2.text() == ''){
			jQuery(id).css({'display':'none'});
			jQuery(parent_id).css({'min-width':'984px','max-width':'984px'});
		}
	}
}
function insert_(id)
{
	if(jQuery(id)){
		var all_li=jQuery(id).find('a');
		all_li.each(function(index){
			jQuery(this).before("<span>-</span>");				 
		});
	}
}

function alginText()
{
	var p_first=jQuery('#tt-header-text').find('p').first();
	var css_top=p_first.css('font-size');
	//alert(parseInt(css_top));
	if(parseInt(css_top) == 58)
	{
		//alert('yes');
		jQuery('#tt-header-text').css({'top':'35px'});
	}
}

function setHeight()
{
	if(jQuery('#menutop_logo')){
		var _h=jQuery('#menutop_logo').css('height');
		var h_page=jQuery('#page').css('height');
		if(parseInt(_h) >= parseInt(h_page))
		{
			//alert('test');
			jQuery('#page').css({'height':parseInt(_h)+10+'px'});
			jQuery('#bg_star').css({'height':parseInt(_h)+10+'px'});
		}
	}
}

function hoverLi()
{
	var _ul=jQuery('#tt-menu-top').find('ul').first();
	var all_li=_ul.children();
	var all_ul=_ul.find('ul');
	//alert(all_ul.length);
	//var arr=new Array();
	//var i=0;
	
	all_li.each(function(index){
		var li_a=jQuery(this).find('a').first();
		var ul_first=jQuery(this).find('ul').first();
		
		/*if(ul_first.length == 0){
			jQuery(this).hover(function(){
				all_ul.each(function(){
					jQuery(this).hide('600',function(){
						jQuery(this).css({'display':'none'});
					});
				});
			});
		}*/
		
		if(ul_first.length > 0)
		{
			var display_ul=ul_first.css('display');
			
			if(display_ul == 'none'){
				//alert(all_ul.length);
				jQuery(this).hover(function(){
					all_ul.each(function(index){
						//alert(jQuery(all_ul[index]).text());
						//alert(jQuery(this).text());
						var curr=jQuery(this).hasClass('dsp_current');
						if(curr){
							//alert('test');
							jQuery(this).hide('600',function(){
								jQuery(this).css({'display':'none'});
								jQuery(this).removeClass('dsp_current');
							});
						}
					});
				});
				
				jQuery(this).hover(function(){
					ul_first.show('600',function(){
						ul_first.css({'display':'inline-block'});
						ul_first.addClass('dsp_current');
					});
				});
			}
			/*jQuery(this).mouseout(function(){
				alert('test');
			});*/
		}
	});
	
}

function createPopup(id_div,id_popup,id_close)
{
	var par_popup=jQuery('a.popup-tk');
	//alert('ys');
	if(par_popup)
	{
		//alert(par_popup.length);
		par_popup.each(function()
		{
			jQuery(this).click(function(){
				//alert('yes');
				jQuery(id_popup).css({'visibility':'visible'});
				jQuery(id_div).css({'visibility':'visible'});
				/*if(jQuery('#iframe')){
					//jQuery('#iframe').css({'width':'770px'}).delay(80000).css({'width':'370px'});
					//alert('yes');delay(800);alert('no');
					var auto_refresh = setInterval(
					function ()
					{
					jQuery('#iframe').load('?page_id=425').fadeIn("slow");
					},10000); // refresh every 10000 milliseconds
				}*/
			});	
		});
	}
	
	// active button close
	jQuery(id_close).click(function(){
			jQuery(id_popup).css({'visibility':'hidden'});
			jQuery(id_div).css({'visibility':'hidden'});
		});
	// click on parent popup will hiden
	jQuery(id_div).click(function(){
			jQuery(id_popup).css({'visibility':'hidden'});
			jQuery(id_div).css({'visibility':'hidden'});
		});
}

jQuery(document).ready(function(){
	/*removePadding('#menu-menu-top');
	setFullWidth('#tt-widgets-right','#tt-page-content');
	insert_('.widget_recent_entries');
	insert_('.widget_categories');
	insert_('.widget_archive');
	setFullWidth('#tt-widgets-bottom','#tt-widgets-bottom');*/
	//alginText();
	//hideHome();
	//hoverLi();
	//setHeight();
	//alert('yes');
	createPopup('#bg-parent-popup','#parent-popup','#close-popup');
});

