function delimiter(actNum, claName){
	rnd=Math.random(); act=1;
	document.write("<span id='me_"+rnd+"'></span>");
	divs=document.getElementById("me_"+rnd).parentNode.getElementsByTagName("div");
	for(i=0; i<divs.length; i++){if(act==actNum){act=1; divs[i].className+=claName;}else{act++;}}
}
function css_opacity(obj, k){if(obj && k){
	obj.style.opacity=k;
	obj.style.filter="alpha(opacity:"+k*100+")";
}}
function OddEvenTable(tables){
	tables=jQuery(tables);
	for(i=0; i<tables.length; i++){
		trs=tables[i].getElementsByTagName("tr");
		tf=true;
		for(j=0; j<trs.length; j++){
			if(j!=0){bgcolor="#e7f7ff";}else{bgcolor="#c3e9ff";}
			if(tf){jQuery(trs[j]).children("td").css("background-color", bgcolor); tf=false;}else{tf=true;} // jQuery used //
		}
	}
}
function cutText(symNum, contentBlock, opacityDeep, symStep){
	// Some parametrs can be set when calling function
	if(!symStep)symStep=4;
	if(!opacityDeep)opacityDeep=5;
	for(i=0; i<$(contentBlock).length; i++){
		text=$(contentBlock).get(i).innerHTML;
		if(text.length>symNum){
			text=text.substr(0, symNum);
			ss=symNum;
			var s=Array();
			for(j=10-opacityDeep; j<10; j++){
				if(j==10-opacityDeep){tt4="…";}else{tt4="";}
				ss-=symStep;
				s[j]="<span class='op"+j+"'>"+text.substr(ss, symStep)+tt4+"</span>";
			}
			s=s.reverse().join("");
			// Get link info
			objLink=$(contentBlock).get(i).parentNode.getElementsByTagName("a")[0];
			objLinkHref=objLink.href;
			objLinkTitle=objLink.title;
			// Making outgoing text
			text=text.substr(0, symNum-symStep*opacityDeep)+"<a href='"+objLinkHref+"' title='"+objLinkTitle+"' class='cutTextLink'>"+s+"&nbsp;&nbsp;<span class='op6 finalizing'>>>></span></a>";
			$(contentBlock).get(i).innerHTML=text+"</p>";
		}
	}
	for(i=0; i<10; i++){$(".op"+i).css("opacity", "0."+i);}
}

// Print //
if(document.location.hash!='#print') setPrintCSS(false);
if(document.location.hash=='#print') {setPrintCSS(true); print_func();}
function print_func() {setTimeout('print()', 5000);}
function setPrintCSS(isPrint) {
    if(document.getElementsByTagName){x=document.getElementsByTagName('link');}
    else if(document.all){x=document.all.tags('link');}else{alert('Простите, этот скрипт не работает в вашем броузере'); return;}
    for (var i=0;i<x.length;i++) {
        if(x[i].title == 'printview'){x[i].disabled = !isPrint;}
        if(x[i].title == 'screenview'){x[i].disabled = isPrint;}
    }
}
// Inits //
$(document).ready(function(){
	// Scrollers
	$("#chosen").scrollable({size:scrollNum()});
	// Pretty Photo
	$("a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook', allow_resize: false, overlay_gallery: false});
	// Tables odd/even
	OddEvenTable($(".oe"));
	// Make anons from content
	cutText(550, $(".s_descr"));
	// ReWidth main blocks
	if($(".v_menu").children().length<1){$(".v_menu").css("width","1%"); $(".content").css("width","96%"); $(".reklama").css("width","25%");}
});

//$(window).resize(function(){alert("dd"); $("#chosen").scrollable({size:scrollNum(), loop:true});});

// Custom funcs //
function scrollNum(){
	W=$(window).width();
	if(W>1024){S=6;}else{S=5;}
	if(W>1280){S=7;}
	return S;
}
function ie_link(obj){document.location.href=obj.parentNode.parentNode.parentNode.parentNode.parentNode.href;}
function paintLeftMenu(){
	items=$(".v_menu .lvl_1");
	colors=Array("#c3e9ff", "#70f395", "#7df74e");
	for(i=0; i<items.length; i++){items.get(i).style.backgroundColor=colors[i];}
}
