var check_stop = 0;
var the_navi_box = $("#subnavi_box");
var close = 0;
var vh = '';
var gomulti = 2;
var newElement = "";
var active_galleryPic =0;

  
function ajax_checkUsername(val){
	$.post('ajax/template.php',{'u':val}, function(response) {	
		alert(response);
	});
}

$('#socialNets').children("a").hover(
		function(){
			$(this).children("img").attr("src","design/images/"+$(this).children("img").attr("alt")+"_.png");
		},
		function(){
			$(this).children("img").attr("src","design/images/"+$(this).children("img").attr("alt")+".png");
		}		
);

$('#socialNets').children("span").hover(
		function(){
			$(this).children("img").attr("src","design/images/"+$(this).children("img").attr("alt")+"_.png");
		},
		function(){
			$(this).children("img").attr("src","design/images/"+$(this).children("img").attr("alt")+".png");
		}		
);

$('.seating_place').hover(
		function(){$(this).stop().animate({"height":30,"width":30});},
		function(){$(this).stop().animate({"height":30,"width":30});}
);
function centerThis(){

	//alert( parseFloat($('body').scrollTop())+"  "+(parseFloat($(window).height())/2)+"  "+(parseFloat($('.centerMe').height())/2));
	var center = parseFloat($('body').scrollLeft()) + (parseFloat($(window).width())/2) - (parseFloat($('.centerMe').width())/2);
	
	var middle = parseFloat($('body').scrollTop()) + (parseFloat($(window).height())/2) - (parseFloat($('.centerMe').height())/2);

	$('.centerMe').stop().animate({"left":center+"px" ,"top":middle+"px"},'slow');
	
	
}

function centerFirst(){

	
	var center = parseFloat($('body').scrollLeft()) + (parseFloat($(window).width())/2) - (parseFloat($('.centerMe').width())/2);
	
	var middle = parseFloat($('body').scrollTop()) + (parseFloat($(window).height())/2) - (parseFloat($('.centerMe').height())/2);

	$('.centerMe').animate({"left":center+"px" ,"top":middle+"px"},'slow');
	
	
}

$(window).resize(function(){
	centerThis();
});
$(window).scroll(function(){
	centerThis();
});

function startUp(){

	$('.isGalleryPic').each(function(){
		if($(this).width() >= $(this).height()){
			
			var Galleryframe_Padding = (($(this).width() - $(this).height())/2)+"px "+(($(this).width() - $(this).height())/2)+"px 0px 0px";
			var Galleryframe_Size = $(this).width()-(($(this).width() - $(this).height())/2) +2;
		}else{
			
			var Galleryframe_Padding = "0px 0px "+(($(this).height() - $(this).width())/2)+"px "+(($(this).height() - $(this).width())/2)+"px";
			var Galleryframe_Size = $(this).height()-(($(this).height() - $(this).width())/2) +2;
		}
		$(this).wrap("<div class='galleryPicMouseOver ui-widget-header' style=\"height:"+Galleryframe_Size+"px;width:"+Galleryframe_Size+"px;padding:"+Galleryframe_Padding+";\"></div>");
		$(this).clone().removeClass("isGalleryPic").addClass("isGalleryPicClone").addClass("dropshadow_dark").css({
			"position":"absolute",
			"height":$(this).height(),
			"width":$(this).width(),
			"left":($(this).position().left),
			"top":($(this).position().top),
			"zIndex":7000,
			"cursor":"pointer",
			"display":"none"
			}).appendTo($(this).parent());
		
		});
		$('.galleryPicMouseOver').corner("7px");
	
$('.galleryPicMouseOver .isGalleryPic').bind("mouseenter",
	function(){
		if($(this).hasClass('isGalleryPic') == true && $(this).parent().children('.isGalleryPicClone').is(':visible') == false){
			if(active_galleryPic !==0){
			active_galleryPic.stop().animate({		"height":active_galleryPic.parent().children('.isGalleryPic').height(),
															"width":active_galleryPic.parent().children('.isGalleryPic').width(),
															"marginLeft":0,
															"marginTop":0
														},'fast','',function(){$(this).hide();$(this).unbind("mouseleave");});
			}
			active_galleryPic = $(this).parent().children('.isGalleryPicClone');
			$(this).parent().children('.isGalleryPicClone').show().stop().animate({	"height":$(this).height()*1.5,
															"width":$(this).width()*1.5,
															"marginLeft":-((($(this).width()*1.5)-($(this).width()))/2),
															"marginTop":-((($(this).height()*1.5)-($(this).height()))/2)
														},'fast','');
			
				$('.galleryPicMouseOver .isGalleryPicClone').bind("click",function(){window.location="index.php?mod=picgallery&action=show&step=2&file=/"+$(this).attr("alt");});
				
				$('.galleryPicMouseOver .isGalleryPicClone').bind("mouseleave",
					function(){
						if($(this).hasClass('isGalleryPicClone') == true){
							$(this).stop().animate({		"height":$(this).parent().children('.isGalleryPic').height(),
															"width":$(this).parent().children('.isGalleryPic').width(),
															"marginLeft":0,
															"marginTop":0
														},'fast','',function(){$(this).hide();$(this).unbind("mouseleave");});
							
						}
					}
				
				);			
			
			
		}
	}

);






}



$(document).ready(function() {
	


	$( "#profileDetails_tab" ).tabs({
		fx: { opacity: 'toggle' },
		cookie: { expires: 1 } 
	});

	$("#profileDetails_tab li a[href=#profileDetails_tab-30]").parent().addClass('ui-state-disabled').css('opacity',0.8);

	
	$('a[href=#profileDetails_tab-30]').html($('#profileDetails_tab-30').html());

	if(typeof tabToSelect != 'undefined'){
		$( "#profileDetails_tab" ).tabs("select",tabToSelect);
	}

	$('body').append('<div id="treeFrameMax" class="dropshadow ttreeBox" style="display:none;width:98%;height:90%;top:8%;left:1%;background:url(design/simple/images/i2010_headline_item.png);z-index:1004;position:fixed;">'+$('#treeFrame').html()+'</div>');

	$('.openTree').click(function(){
		$('.closeTree').show();
		$('.openTree').hide();
		$('#treeFrameMax').css({'opacity':0,'left':$('#treeFrame').offset().left,'top':parseFloat($('#treeFrame').offset().top)-parseFloat($('body').scrollTop()),'width':$('#treeFrame').width(),'height':$('#treeFrame').height()});
		$('#treeFrameMax').show();
		$('#treeFrameMax').animate({'height':($(window).height()-90),'width':$(window).width()-65,'top':47,'left':0,'opacity':1});
	});
	
	$('.closeTree').click(function(){
		$('.closeTree').hide();
		$('.openTree').show();		
		$('#treeFrameMax').animate({'opacity':0,'left':$('#treeFrame').offset().left,'top':parseFloat($('#treeFrame').offset().top)-parseFloat($('body').scrollTop()),'width':$('#treeFrame').width(),'height':$('#treeFrame').height()},function(){$('#treeFrameMax').hide();});			
	});	
	
	$('.matchBox').hover(
		function(){$(this).stop().animate({'opacity':'1'});},
		function(){$(this).stop().animate({'opacity':'0.6'});}
	);	
	
	//$('a[href=#profileDetails_tab-30]').click(function() { 
	//	return false;
	//})
	
	
	$('body').animate({'scrollTop':'0'},600);
	
	$(".dialogMe").dialog({ 
	autoOpen: false,
	 modal: true, 
	 show: "clip",
	 hide: "clip",
	 minWidth: 400,
	 minHeight: 100,
	 zIndex: 3000,
	 resizable: false,
	 buttons:{
		 'close':function(){$(this).dialog("close");}
	 }
	 
	   });
	
	$("#dsp_form1").validationEngine();		
	
	$('textarea.tinymce').tinymce({
		script_url : '../../../tiny_mce/tiny_mce.js',

		theme : "advanced",
		plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",

		theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,

		content_css : "../style.css",

		force_br_newlines : true,
        force_p_newlines : false,
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		
		template_replace_values : {
			username : "Some User",
			staffid : "991234"
		}
	});
	$('textarea.tinymce_small').tinymce({
		script_url : '../../../tiny_mce/tiny_mce.js',

		theme : "advanced",
		plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",

		theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,undo,redo,|,link,unlink,image|preview,|,forecolor,backcolor",
		theme_advanced_buttons3 : "sub,sup,|,charmap,emotions,iespell,media,image,advhr",
		theme_advanced_buttons4 : "cite,del,ins",
		theme_advanced_toolbar_location : "bottom",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : false,

		content_css : "../style.css",

		force_br_newlines : true,
        force_p_newlines : false,
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		
		template_replace_values : {
			username : "Some User",
			staffid : "991234"
		}
	});
});


function showFAQ(id){
	if($('#faQ_txt_'+id).height()>1){
		$('#faQ_txt_'+id).stop().animate({"height":0}).css({"borderTop":"0px solid #EB5605"});
	}else{
		$('#faQ_txt_'+id).stop().animate({"height":($('#faQ_txt_'+id).children("div").height()+40)}).css({"borderTop":"2px solid #EB5605"});
	}
}

$('.isfaQItem').hover(
		function(){$(this).stop().animate({"color":"#EB5605"});$(this).children("div:last").stop().animate({"opacity":"1"});},
		function(){$(this).stop().animate({"color":"#444444"});$(this).children("div:last").stop().animate({"opacity":"0"});}
);

function naviDoScroll(id){
	$("#subnavi_box").stop().animate({'marginTop':(-46*(id-1))+'px'},'slow');
}

function switchMainNaviBg(id){
	
	$("#isMainNaviItemBg_"+id).stop().animate({"opacity":"1"},'slow');
}

function switchMainNaviBg_(id){
	$("#isMainNaviItemBg_"+id).stop().animate({"opacity":"0"},'slow');
}

$('#mainNaviParent').hover(
	function(){
		
		$('#mainNaviHoverGlow').fadeIn();
		$('#mainNaviParent').bind('mousemove',function(e){ 
			if((e.pageX) < $('#mainNaviParent').offset().left){
				$("#mainNaviHoverGlow").css({"left":-55});
				if($('#mainNaviHoverGlow').css('opacity')==1)
					$('#mainNaviHoverGlow').stop().fadeOut(function(){$('#mainNaviParent').unbind('mousemove');});
				
			}else if((e.pageX) > ($('#mainNaviParent').offset().left+parseInt($('#mainNaviParent').width()))-20){
				$("#mainNaviHoverGlow").css({"left":(parseInt($('#mainNaviParent').width())-70)});
				if($('#mainNaviHoverGlow').css('opacity')==1)
					$('#mainNaviHoverGlow').stop().fadeOut(function(){$('#mainNaviParent').unbind('mousemove');});
			}else{
				$("#mainNaviHoverGlow").css({"left":(e.pageX - $('#mainNaviParent').offset().left - 55)});
			}
		});
	},
	function(){
		$('#mainNaviParent').unbind('mousemove');
		$('#mainNaviHoverGlow').fadeOut();
	}
);

$('.admin_sidepanel_main').hover(
function(){
	$(this).stop().animate({"paddingLeft":20,"width":235},'slow');
	$(this).children("div").stop().animate({"opacity":1,"height":200});
	$(this).children("div").css("zIndex","2001");
	
	},
function(){
	$(this).children("div").stop().animate({"opacity":0,"height":1});
	$(this).stop().animate({"paddingLeft":0,"width":150},'slow');
	$(this).children("div").css("zIndex","2000");
		
	}
);

$('.headline_doDD_button__').mouseenter(
		function(){		
			$(this).parent().parent().css({"background":"url(design/simple/images/persBarOver.png)","borderBottom":"4px solid #f25f11"});
			$(this).parent().parent().children('div').css({'width':$(this).parent().parent().width()+30,'left':($(this).parent().parent().offset().left - $('#headline_bg_inner').offset().left)});
			
			$(this).parent().parent().children('div').stop().animate({'opacity':'1','height':$(this).parent().parent().children('div').children('ul').height()+10},'fast');
			
		});	

$('.headline_doDD_button').mouseenter(
		function(){		
			$(this).parent().css({"background":"url(design/simple/images/persBarOver.png)","borderBottom":"4px solid #f25f11"});
			$(this).parent().children('div').css({'width':$(this).parent().width()+30,'left':($(this).parent().offset().left - $('#headline_bg_inner').offset().left)});
			
			$(this).parent().children('div').stop().animate({'opacity':'1','height':$(this).parent().children('div').children('ul').height()+10},'fast');
			
		});		
$('.HeadlineboxBox').mouseleave(			
		function(){
			$(this).css("background","");
				$(this).children('div').stop().animate({'opacity':'0','height':'0'},400,function(){});			
		}
	
);


$('.headline_doDD_button').hover(
		function(){$(this).attr("src","design/simple/images/headline_buttons_DD_.png");},
		function(){$(this).attr("src","design/simple/images/headline_buttons_DD.png");}
);

$('.imgprewGallery').hover(
	function(){$(this).css("zIndex",1);},
	function(){$(this).css("zIndex",0);}

);


var customTitle;

$(function() {
	
	$('.imgprewGallery').draggable();
	
	
	

	$('.transMe').css('opacity','0.7');
	if(isIE_ != 1){
		$('div.Buttons a').corner("3px");
		
		$('.HeadlineboxBox_DD').corner("br bl 7px");
		$('.roundMe').corner("3px");
		$('.roundMe_more').corner("7px");
		$('.Button').corner("3px");
		$('.table_search').corner("5px");
		
		
		$('.admin_sidepanel_main').corner("20px tr bl");
		$('#tam_total').corner("10px tr br");
		$('#tam_switch').corner("10px tr br");
		
		$('.hideMe').css({"display":"block","opacity":"0"});
		}
	
	
	$('*').bind({
		'mouseenter':function(){
			if($(this).attr('title') != "" && typeof $(this).attr('title') != "undefined"){
				customTitle = $(this).attr('title');
				$(this).attr('title','');
				$('body').append("<div id='isCustomTitle' class='dropShadow'>"+customTitle+"</div>");
				if(isIE_ != 1) {$('#isCustomTitle').corner("5px");}
				$('#isCustomTitle').css('opacity','0.8');
				
					$(document).bind('mousemove',function(e){ 
					    $("#isCustomTitle").css({"top":(e.pageY+15)+"px","left":(e.pageX+15)+"px"}); 
					});
				return true;
			}	
		}
	});
	
	$('*').bind({
		'mouseleave':function(){
		if(customTitle != ""){
			$(this).attr('title',customTitle);
			customTitle = "";
			$('#isCustomTitle').remove();		
			$(document).unbind('mousemove');
			return true;
		}}
	});
	
	$('.sideBoxes_background_lock').hover(function(){
		
		$(this).css('backgroundImage','url(design/simple/images/sideMenuBox_item_.png)').stop().animate({'color':'#EB5605','borderColor':'#000','paddingLeft':'15px','width':'180px'}, 100 );
		
	},function(){
		$(this).stop().animate({'color':'#555555','borderColor':'#000','paddingLeft':'10px','width':'185px'}, 600 ).css('backgroundImage','url(design/simple/images/sideMenuBox_item.png)');
		
	}
	);

});


$('.Help').click(function(){
	if($(this).parent().parent().parent().children(".BoxContent").children("div").children("li").children("div").is(':visible') == true){
		$(this).parent().parent().parent().children(".BoxContent").children("div").children("li").children("div").hide();
		$(this).parent().parent().parent().children(".BoxContent").stop().animate({'height':0},400);
	}else{		
		$(this).parent().parent().parent().children(".BoxContent").stop().animate({'height':$(this).parent().parent().parent().children(".BoxContent").children().height()},400,function(){
			$(this).children("div").children("li").children("div").fadeIn();
		});
	}
});





$('.navi_admin_menu').mouseenter(function(){
	$(this).children("div").stop().show().animate({'width':'300'},'fast');		
});

$('.navi_admin_menu').mouseleave(function(){
	$(this).children("div").stop().animate({'width':'0'},'fast').hide();		
});

$('#tam_switch').click(function(){	
	if(parseFloat($(this).parent().css("marginLeft"))< 0)
		$(this).parent().stop().animate({'marginLeft':'0'},'slow');	
	else	
		$(this).parent().stop().animate({'marginLeft':'-300'},'slow');	
});


	
$(document).ready(function() {
	return false;
	if(1==2){
		$('#toggleTwitterBox').click(function(){
			if($("#twitterBoxOuter").height() > 0 ){
				$("#twitterBoxOuter").animate({'top':'-10px','height':'0px'});
			}else{
				$("#twitterBoxOuter").animate({'top':'5px','height':'400px'});	
			}
		});
	
		$("#twitterBox").nTwitter({
			userName: "netproject_ev",
			tick: true,
			displayUsername: false,
			tickDelay: 5,
			numTweets: 15,
			tickHeight: 240,
			prefix: 'netproject',						
			lang: {	
				reply:'<img src="https://si0.twimg.com/images/dev/cms/intents/icons/reply_hover.png" style="margin-bottom:-4px;" alt=""/>', 
				retweet:'<img src="https://si0.twimg.com/images/dev/cms/intents/icons/retweet_hover.png" style="margin-bottom:-4px;" alt=""/>', 
				favorite:'<img src="https://si0.twimg.com/images/dev/cms/intents/icons/favorite_hover.png" style="margin-bottom:-4px;" alt=""/>', 
				noData:'This User does not have any Tweets',
				less_than_a_minute_ago:'less than a minute ago',
				a_minute_ago:'about a minute ago',
				X_minutes_ago:'%%X%% minutes ago',
				a_hour_ago:'about an hour ago',
				X_hours_ago:'%%X%% hours ago',
				a_day_ago:'yesterday',
				X_days_ago:'%%X%% days ago'
				} 
		});
		}
});



