
$(document).ready(function(){
	
	var getit= new Array();
	getit=document.location.pathname.split("/");
	var cur_lang = getit[1];
	if (!cur_lang) {
		cur_lang = "ua";
	};
	$("#ptext_1").show().fadeTo(1, 0)
	$("#ptext_2").show().fadeTo(1, 0)
/*	$('#logo').flash({ 
		src: '/flash/logo.swf', 
		width: 159,
		height: 54,
		flashvars: { lang: cur_lang }
		}, { expressInstall: true });
*/	

		// initialize scrollable 
		$("#travernet-carusel").scrollable({
			size: 1,
			items: '#carusel-items',  
			hoverClass: 'hover',
			interval: 10000,
			loop: true,
			onBeforeSeek: function() { 
				var cur = this.getPageIndex();
				$("#ptext_"+cur).fadeTo(300, 0);
				//_trace("Old is " + cur)
			},
			onSeek: function() { 
				//this.getItems().fadeTo(300, 1); 
				var cur = this.getPageIndex();
				$("#ptext_"+cur).fadeTo(300, 1);
//				_trace("New is " + cur)
			}
		});	

});


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;
			}
		}
	}
}
var trace_index = 1;
function _trace(val){
	if(!$ || !jQuery){
		alert("_trace need jQuery")
	}
	if(!$("#trace_holder").attr("id")){
		var tr = document.createElement("div");
		tr.id = "trace_holder";
		with(tr.style){
			width = "50%";
			padding = "10px";
			border = "solid 1px grey";
			position = "absolute";
			top = "10px";
			left = "10px";
			backgroundColor = "#f4f4f4";
			opacity = "0.5";
			color = "red";
			textAlign = "left";
		}
		document.body.appendChild(tr) 
	}
	//$("#trace_holder").append(val + "<hr/>");
	$("#trace_holder").html("<b>"+trace_index++ + ": </b>"+ val + "<hr />" + $("#trace_holder").html())
}
