var Epics = new Array();
function createArrays(lend)
{
for(var i = 0;i<lend;i++)
{
	 
		Epics[i] = new Array ;	
		
}
}

function selSearch()
{
	var id = self.document.location.hash.substring(1);
	
	var res = document.getElementById(id)
	res.innerHTML += '<div style="float:right; margin-right: 20;font-size:10">резултат от търсене</div>'
}
function relocate(newurl)
{
	
	 document.location.href = newurl;
	

   // document.location.href='/'+url;
}
function removePreview()

{

	var PreviewHolder = document.getElementById('preview');

	PreviewHolder.style.visibility = 'hidden';

	

	var flash_mc = document.getElementById('flashcontent1');

	if(flash_mc != null)flash_mc.style.visibility = 'visible';

}



//window.attachEvent('onresize', function () {setPositions();});



var crr = 0;
var current = 0 ;
var pcs = new Array();

var Ecrr = 0;
function RecordUrlE(url,ID)
{
  Epics[ID].push(url);

}

function NextP()

{

	//alert(pcs[crr][0]);

	crr++;

	if(crr == pcs.length)crr = 0;

	removePreview();

	Preview(pcs[crr][0], pcs[crr][1], pcs[crr][2], '', true);

}
function NextPE()

{


	crr++;
    
	if(crr == Epics[current].length)crr = 0;

	removePreview();

	Preview(Epics[current][crr], 500,500, '', true);

}
function PrevPE()

{

	//alert(pcs[crr][0]);

	crr--;

	if(crr == -1)crr = Epics[current].length-1;

	removePreview();

	Preview(Epics[current][crr], 500, 500, '', true);

}



function PrevP()

{

	crr--;

	//alert(pcs[crr][0]);

	if(crr == -1)crr = pcs.length-1;

	removePreview();

	Preview(pcs[crr][0], pcs[crr][1], pcs[crr][2], '', true);

}



function Preview(P, W, H, name, navig)

{

	
  
	var flash_mc = document.getElementById('flashcontent1');

	

	if(flash_mc != null)flash_mc.style.visibility = 'hidden';

	

	//var tblHld = document.getElementById('th');

var PreviewHolder = document.getElementById('preview');	

	PreviewHolder.style.width = '100%';

	PreviewHolder.style.height = document.body.scrollHeight;

	PreviewHolder.style.top = 0;

	PreviewHolder.style.left = 0;

	//alert(document.body.scrollTop);

	

	

	var navigation = '';

	

	if(navig)
	{
		if(document.getElementById('reklama'))
     {
		navigation += '<img src="i/prv.jpg" onClick="PrevPE()">&nbsp;';
     }else{navigation += '<img src="i/prv.jpg" onClick="PrevP()">&nbsp;';}
	}

			 navigation += name;

	if(navig)
	{
		if(document.getElementById('reklama'))
     {
		navigation += '&nbsp;<img src="i/nxt.jpg"  onClick="NextPE()">';
     }else{navigation += '&nbsp;<img src="i/nxt.jpg"  onClick="NextP()">';}	
	}

	

	



	

	var html_value = '';

	

	html_value += '<div id="event_disabler" style="position:absolute; filter: alpha(opacity = 60); -moz-opacity: 0.6;opacity: .6;background-color:#000000; width:100%; height:100%; top:0; left:0; z-index:1;">';  
    html_value += '</div>';
	

	

	html_value += '<div id="picture_holder" style="top:'+document.body.scrollTop+'; left:0; position:absolute; width:100%;margin-top:64px;height:90%;z-index:2;">';
	

	

	html_value += '<table cellspacing="0" width="100%" height="1px" cellpadding="0" border="0"><tr><td align="center">';

	html_value += '<div style="border:1px solid #132624;width:'+Number(W)+';background-color:#0c1b18;padding-left:3px;filter: alpha(opacity = 100);-moz-opacity: 1.0;padding-right:3px;padding-bottom:25px">';

	

	html_value += '<div style="text-align:right; background-color:#0c1b18;width:'+Number(W)+';height:35"><div>';

	html_value += '</div><div style="overflow:hidden"><div style="float:right;margin-top:5;margin-right:2"><img src="i/c.jpg" onClick="removePreview()"></div>';
    

	html_value += '<div style="float:left;margin-left:5"><font color="#c3c3c3" size="5">';	
	html_value += navigation;
    html_value += '</font></div></div></div>'
	

	

	

	html_value += '<div style=" width:'+W+';background-color:#0c1b18;"><img width="500px" src="'+P+'" border="0"></div>';

	html_value += '</div>';

	



	html_value += '</td>';

	html_value += '</tr></table></div>';

	

	

	

	PreviewHolder.innerHTML = html_value;

	//html_value;

	

	PreviewHolder.style.visibility = 'visible';

	//document.location = "#top";

}




function PrintThis(URL)

{

	

	//alert(URL);

	window.open(URL,"my_new_window","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=400, height=423");



	//window.print();

}


var past = 100;
var tmp = 0;
var c = 1;
var r = 1;
window.onload = function()
{
 
	
	if(document.getElementById('projects')){
    if(document.getElementById('reklama'))
     {
     	var tables = document.getElementsByTagName('table');
     	for(var p=0 ;p<tables.length;p++)
     	{
     		if(window.addEventListener){tables[p].setAttribute("class", "adver_table");tables[p].setAttribute("cellspacing", "0px");}else{tables[p].setAttribute("className", "adver_table");tables[p].setAttribute("cellSpacing", "0px");}
     		tables[p].setAttribute("cellpadding", "0px");
     		var columns = tables[p].getElementsByTagName('td');
     		c = 1;
            r = 1;
     		for(var b=0 ;b<columns.length;b++)
		     	{
		     		if(c==3){c = 1;r++};
		     		if(r==3){r = 1;};
		     		if(c==1){columns[b].style.textAlign = 'left';columns[b].style.paddingLeft = '5px';}
		     		if(c==2){columns[b].style.textAlign = 'right';columns[b].style.paddingRight = '5px';}
		     		if(r==1){columns[b].style.backgroundColor = '#c1ccc8';}
		     		if(r==2){columns[b].style.backgroundColor = '#b4c0bc';}
		     		c++;
		     	}
     	}
     	
     } 
	
 	var holders = new Array;

 	holders = getElementsByClassName(document, 'txt_holder')
	
 	for(var i=0;i<holders.length;i++)
	{
	holders[i].id = i;	
	
	if(window.addEventListener){
	
	
     	
	holders[i].addEventListener('mouseout',function() 
       {
   
        this.style.cursor = 'default'; 
    
       },false)
	holders[i].addEventListener('mouseover',function() 
       {
   
        this.style.cursor = 'pointer'; 
    
       },false)
	holders[i].addEventListener('click',function() 
       {
         
        holders[current].style.height = 35 + 'px'; 
        this.style.cursor = 'pointer'; 
     	this.style.height = '';
         
        current = this.id
        crr = 0;
       
       },false)
	
       	
	}else
	
	
	{
		holders[i].attachEvent('onmouseleave',function(e) 
       {
   
        e.srcElement.style.cursor = 'default'; 
        
       })
	holders[i].attachEvent('onmouseenter',function(e) 
       {
         past = current;
         tmp =  e.srcElement.id;
       	e.srcElement.style.cursor = 'pointer'; 
    
       })
	holders[i].attachEvent('onclick',function(e) 
       {
         
       current = tmp;
       crr = 0;	
       if(past == current){holders[current].style.height =  ''; }
       	else{
        holders[current].style.height =  ''; 
        holders[past].style.height = 35 + 'px'; 
       	}
       
       
       })
	
		
		
	}
	
  }
  
}
if(document.getElementById('projects_sub')){selSearch();}
}



function getElementsByClassName(node, classname)
{
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}
function change_cont(id)
{
	
	var holder = document.getElementById('cont_holder');
	holder.innerHTML = document.getElementById(id).innerHTML;
}

var r = 0;
function switchRss(dir,lent)
{
	
	if(dir==0){if(r<lent-1)r++;}
	else{if(r>0)r--;}
	var rsshold = document.getElementById('rss_view')
	var linkhold = document.getElementById('link_holder')
rsshold.innerHTML = document.getElementById(r).innerHTML	
linkhold.innerHTML = document.getElementById('link_'+r).innerHTML

}