var selectLanguageStat = 'up';

function switchLangAction(){
	if(selectLanguageStat == 'up'){
		//selectLanguage.src = '/wp-content/themes/default/images/language_select_up.gif';
		document.getElementById('selectLanguage').src = '/wp-content/themes/default/images/language_select_up.gif';
		document.getElementById('langdrop').className = 'selectlanguage-up';
		showDiv('avaliblelanguage-right');
		showDiv('avaliblelanguage-left');
		selectLanguageStat = 'down';
	}else{
		//selectLanguage.src = '/wp-content/themes/default/images/language_select_dn.gif';
		document.getElementById('selectLanguage').src = '/wp-content/themes/default/images/language_select_dn.gif';
		document.getElementById('langdrop').className = 'selectlanguage-down';
		hideDiv('avaliblelanguage-right');
		hideDiv('avaliblelanguage-left');
		selectLanguageStat = 'up';

	}
}

function hideDiv(pass) {
	//alert('hide div = '+pass);
	var divs = document.getElementsByTagName('td'); 
	for(i=0;i<divs.length;i++){ 
		if(divs[i].id.match(pass)){//if they are 'see' divs 
			if (document.getElementById){ // DOM3 = IE5, NS6 
				divs[i].style.visibility="hidden";// show/hide 
			}else{
				if (document.layers){ // Netscape 4 
					document.layers[divs[i]].display = 'hidden'; 
				}else{ // IE 4 
					document.all.hideShow.divs[i].visibility = 'hidden';
				}
			} 
		}
	}
}

function showDiv(pass) { 
	//alert('show div = '+pass);
	var divs = document.getElementsByTagName('td'); 
	for(i=0;i<divs.length;i++){ 
		if(divs[i].id.match(pass)){ 
			if (document.getElementById){
				divs[i].style.visibility="visible"; 
			}else{
				if (document.layers){ // Netscape 4 
					document.layers[divs[i]].display = 'visible'; 
				}else{ // IE 4 
					document.all.hideShow.divs[i].visibility = 'visible';
				}
			} 
		}
	}
} 

function hideElement ( ElementsHide, ElementShow, MenuItem){
    document.getElementById(ElementShow).style.display = "block";
    for( var i in ElementsHide){
        document.getElementById(ElementsHide[i]).style.display = "none";
    }
}


function changeStyle ( elementStyle, AllMenu ){
    Navigation = document.getElementById(AllMenu);
    myBodyElements = Navigation.getElementsByTagName("li");
    count = 0;
    for ( var i in myBodyElements )
    {
        
        if ( isNaN(myBodyElements[i]) ){
           // alert( myBodyElements[i] );
            count++;
        }
        //myBodyElements[i].setAttribute("class", "");
        
    } 
    if (navigator.appName != "Microsoft Internet Explorer"){
        count = count -2;
    }
    //alert(count);
    for(i=0; i<count; i++){
        if( myBodyElements[i].style.setAttribute ) {
            myBodyElements[i].setAttribute("className", "");
        }else{
            myBodyElements[i].setAttribute("class", "");
        }
    }
    
    if( elementStyle.style.setAttribute ) {
        elementStyle.setAttribute("className", "active"); 
    }else {
        elementStyle.setAttribute("class", "active");
    }  
}

function toggle(obj) 
{   
    var el = document.getElementById(obj);
	el.style.display = (el.style.display != 'none' ? 'none' : 'block' );
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
  	window.onload = func;
  } else {
  	window.onload = function () {
		oldonload();
		func();
	}
  }
}

addLoadEvent(prepareToggle)
function prepareToggle() {
if (!document.getElementsByTagName) return false;
	var links = document.getElementsByTagName("a");
	for (var i=0; i<links.length; i++) {
	if (links[i].className.match("toggle")) {
			links[i].onclick = function() {
			toggleElement(this);
			return false;
			}
		}
	}
}

function toggleElement(link) {
	var elementID = link.getAttribute("href").split("#")[1];
    toggle(elementID);
}
function popVideo_old(domain) {
	document.getElementById('fade').style.height=document.body.clientHeight+"px";
	document.getElementById('fade').style.width=document.body.clientWidth+"px";
	document.getElementById('fade').style.width="100%";	
	document.getElementById('light').style.left = document.body.clientWidth*0.5 - 456*0.5 +"px";
	document.getElementById('light').style.left="32%";	
	document.getElementById('light').style.display='block';
	document.getElementById('fade').style.display='block';
	r = document.getElementById('light');
	var aa;
	getData("/wp-content/themes/default/video_popup.php?"+id, "code="+id, aa, r);
	
}
function hideVideo() {	
	document.getElementById('light').style.display='none';
	document.getElementById('light').innerHTML = "";
	document.getElementById('fade').style.display='none';
}
function getData(requestUrl, requestPost, requestResult, replacement) {
	var xmlHttpReq = false;
	var self = this;
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
		}
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
	self.xmlHttpReq.open('POST', requestUrl, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			replacement.innerHTML = self.xmlHttpReq.responseText;
			if (requestResult) window.setTimeout(requestResult+'()', 0);
		}
		}
	self.xmlHttpReq.send(requestPost);
}
function popup_photo(PhotoPath, PhotoWidth, PhotoHeight) {
	Window = window.open("","Window","width="+PhotoWidth+",height="+PhotoHeight+",scrollbars=no");
	Window.document.open();
	Window.document.write('<html><head></head>');
	Window.document.write('<body style="margin:0px; padding:0px" onBlur="window.close()">');
	Window.document.write('<img src="'+PhotoPath+'" border="0" onClick="javascript:window.close();">');
	Window.document.write('</body></html>');
	Window.document.close();
	Window.focus();
	}

//video popup
function getPageScroll(){
	var xScroll, yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;
	}
	arrayPageScroll = new Array(xScroll,yScroll)
	return arrayPageScroll;
}
//video popup
function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

//video popup
function popVideo(id) {
	document.getElementById('fade').style.height=document.body.clientHeight+"px";
	document.getElementById('fade').style.width=document.body.clientWidth+"px";
	document.getElementById('fade').style.width="100%";
	document.getElementById('light').style.left = document.body.clientWidth*0.5 - 456*0.5 +"px";
	document.getElementById('light').style.left="32%";
	var arrayPageScroll = getPageScroll();
	var arrayPageSize = getPageSize();
	var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
	document.getElementById('light').style.top=lightboxTop+"px";
	//alert("LEFT: "+document.getElementById('light').style.left+"; WIDTH: "+document.body.clientWidth+"; %:"+document.getElementById('light').style.left/document.body.clientWidth);
	document.getElementById('light').style.display='block';
	document.getElementById('fade').style.display='block';
	r = document.getElementById('light');
	var aa;
	getData("/wp-content/themes/default/video_popup.php?"+id, "code="+id, aa, r);
}
//video popup
function hideVideo() {
	document.getElementById('light').style.display='none';
	document.getElementById('light').innerHTML = "";
	document.getElementById('fade').style.display='none';
}
function getData(requestUrl, requestPost, requestResult, replacement) {
	var xmlHttpReq = false;
	var self = this;
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
		}
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
	self.xmlHttpReq.open('POST', requestUrl, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			replacement.innerHTML = self.xmlHttpReq.responseText;
			if (requestResult) window.setTimeout(requestResult+'()', 0);
		}
		}
	self.xmlHttpReq.send(requestPost);
}

var index=1;
function showtab(active, passive1, passive2, activeClass1, passiveClass2, passiveClass3) {
 document.getElementById(active).style.display='block';
 document.getElementById(passive1).style.display='none';
 document.getElementById(passive2).style.display='none';
 document.getElementById(activeClass1).className='sel'; 
 document.getElementById(passiveClass2).className='notsel';
 document.getElementById(passiveClass3).className='notsel';
 return false;
}
function next(type, classpath, blockpath){
 document.getElementById(blockpath+1).style.display='none';
 document.getElementById(blockpath+2).style.display='none';
 document.getElementById(blockpath+3).style.display='none';
 document.getElementById(classpath+1).className='notsel';
 document.getElementById(classpath+2).className='notsel';
 document.getElementById(classpath+3).className='notsel';
 if(index == 1){
  if(type=='next') index = 2
  else  index = 3;
  }
 else if(index == 2){
  if(type=='next') index = 3;
  else  index = 1;
  }
 else if(index == 3){
  if(type=='next') index = 1;
  else  index = 2;
  }
 document.getElementById(blockpath+index).style.display='block';
 document.getElementById(classpath+index).className='sel';
 return false;
} 
var rotate_delay = 5000; // delay in milliseconds (5000 = 5 secs)
current = 0;
//function nextas(title) {
//	if (document.slideform.slide[current+1]) {
//		document.images['show'].src = document.slideform.slide[current+1].value;
//		document.getElementById('thumb1').href = document.slideform.slide[current+1].value;
//		document.slideform.slide.selectedIndex = ++current;
//		}
//	else 
//		firstas(title);
//	}
//function previousas(title) {
//	if (current-1 >= 0) {
//		document.images['show'].src = document.slideform.slide[current-1].value;
//		document.getElementById('thumb1').href = document.slideform.slide[current-1].value;
//		document.slideform.slide.selectedIndex = --current;
//		}
//	else 
//		lastas(title);
//	}
//function firstas(title) {
//	current = 0;
//	document.images['show'].src = document.slideform.slide[0].value;
//	document.getElementById('thumb1').href = document.slideform.slide[0].value;
//	document.slideform.slide.selectedIndex = 0;
//	}
//function lastas(title) {
//	current = document.slideform.slide.length-1;
//	document.images['show'].src = document.slideform.slide[current].value;
//	document.getElementById('screenshot_image').href = document.slideform.slide[current].value;
//	document.getElementById('thumb1').href = document.slideform.slide[current].value;
//	document.slideform.slide.selectedIndex = current;
//	}
//function change() {
//	current = document.slideform.slide.selectedIndex;
//	document.images['show'].src = document.slideform.slide[current].value;
//	}
function nextas(title) {
	if (document.getElementById('slideshow').slide[current+1]) {
		document.images['show'].src = document.getElementById('slideshow').slide[current+1].value;
		document.getElementById('thumb1').href = document.getElementById('slideshow').slide[current+1].value;
		document.getElementById('slideshow').slide.selectedIndex = ++current;
		}
	else 
		firstas(title);
	}
function previousas(title) {
	if (current-1 >= 0) {
		document.images['show'].src = document.getElementById('slideshow').slide[current-1].value;
		document.getElementById('thumb1').href = document.getElementById('slideshow').slide[current-1].value;
		document.getElementById('slideshow').slide.selectedIndex = --current;
		}
	else 
		lastas(title);
	}
function firstas(title) {
	current = 0;
	document.images['show'].src = document.getElementById('slideshow').slide[0].value;
	document.getElementById('thumb1').href = document.getElementById('slideshow').slide[0].value;
	document.getElementById('slideshow').slide.selectedIndex = 0;
	}
function lastas(title) {
	current = document.slideform.slide.length-1;
	document.images['show'].src = document.getElementById('slideshow').slide[current].value;
	document.getElementById('screenshot_image').href = document.getElementById('slideshow').slide[current].value;
	document.getElementById('thumb1').href = document.getElementById('slideshow').slide[current].value;
	document.getElementById('slideshow').slide.selectedIndex = current;
	}
function change() {
	current = document.slideform.slide.selectedIndex;
	document.images['show'].src = document.getElementById('slideshow').slide[current].value;
	}