
$(document).ready(function(){
	
	var getit= new Array();
	getit=document.location.pathname.split("/");
	var cur_lang = getit[1];
	if (!cur_lang) {
		cur_lang = "ua";
	};

	$('#logo').flash({ 
		src: '/flash/logo.swf', 
		width: 159,
		height: 54,
		flashvars: { lang: cur_lang }
		}, { expressInstall: true });
	
	//contentDictionary();	
	var toSM = $("#to_sub_menu").html();
	if( toSM ){
		$("#sub-menu").html(toSM);
	}
	
//	$('.image').lightBox({
//			overlayOpacity: 	0.9,
//			imageLoading:		'/img/lighbox/lightbox-ico-loading.gif',		
//			imageBtnPrev:		'/img/lighbox/lightbox-btn-prev.gif',			
//			imageBtnNext:		'/img/lighbox/lightbox-btn-next.gif',			
//			imageBtnClose:		'/img/lighbox/lightbox-btn-close.gif',		
//			imageBlank:			'/img/lighbox/lightbox-blank.gif'
//	});
	
	$('.image').fancybox({
		'frameWidth' : 700,
		'frameHeight' : 500,
		'hideOnContentClick' : false,
		'overlayShow' : true,
		'centerOnScroll' : false,
		'overlayOpacity' : 0.9,
		'zoomSpeedIn' : 600,
		'zoomSpeedOut' : 500,
		'easingIn' : 'easeOutBack',
		'easingOut' : 'easeInBack',
		'callbackOnShow' : function(){
			
			
			$("#fancy_outer").ready(function(){
				$("#fancy_outer").animate( { height: $("#work_content").innerHeight() + 30}, 500 )
			});
		}
	
	});
	
});


function contentDictionary(){
	
	//alert( $("#content").text() );
	
	var str = $("#content").html();
	var reg=/<+.[^>]+>.(outsourcing|90|h1).<\/+.[^>]+>/g
	//var reg=/([^<]\d>\d)*(outsourcing|90|h1)/g
	var result=str.replace(reg, "<a href=\"dictionary?p=\$1\" onmouseover=\"dicTip(this)\">\$2</a>");
//	alert(result)
	$("#content").html(result)
	
}

function dicTip(o){
	//alert( $(o).text() );
}


arg = false;
function addCommentForm(){
	if(arg == false){
		arg = "show";
	}else{
		arg = "hide";
	}
	
	switch(arg){
	case "show":
		document.getElementById("coment_form").style.display = 'inline';
		break;
	
	case "hide":
		document.getElementById("coment_form").style.display = 'none';
		arg = false;
		break;
		
	}
}

function random_color(){
	var COLORS = Array("#fff2e1","#ffe1e1","#e1ffe2","#e1ffff","#e3e1ff","#ffe1f1","#ffe1e1");
	//alert(Math.floor(Math.random()*COLORS.length+1))
	var rand = Math.floor(Math.random()*COLORS.length);
	return COLORS[rand];
}


function submitComment(){
 
		re=/^[\w\.\-]+\@[\w\.\-]+/;
		if(document.comm.comment_name.value == "" || document.comm.comment_text.value == "")
		{
			alert("Ну написать то что-то нужно то!");
			return false;
		}

		document.comm.action="/misc/add_comment.php";
		document.comm.submit();
}

function toMenu(el)
{
	document.getElementById("submenu").innerHTML = document.getElementById(el).innerHTML;
}


function setSelectedValue(srcListName, value) {
	//var srcList = document.all[srcListName];
	var srcList = document.getElementById(srcListName);
	if (srcList) {
		var srcLen = srcList.length;

		for (var i=0; i<srcLen; i++) 
		{
			srcList.options[i].selected = false;
			if (srcList.options[i].value == value) 
			{
				srcList.options[i].selected = true;
			}
		}
	}
}
