function getBrowserInfo()
{
 var t,v = undefined;
 if (window.opera) t = 'Opera';
 else if (document.all) {
  t = 'IE';
  var nv = navigator.appVersion;
  var s = nv.indexOf('MSIE')+5;
  v = nv.substring(s,s+1);
 }
 else if (navigator.appName) t = 'Netscape';
 return {type:t,version:v};
}

function bookmark(a)
{
 var url = window.document.location;
 var title = window.document.title;
 var b = getBrowserInfo();
 if (b.type == 'IE' && 7 > b.version && b.version >= 4) window.external.AddFavorite(url,title);
 else if (b.type == 'Opera') {
  a.href = url;
  a.rel = "sidebar";
  a.title = url+','+title;
  return true;
 }
 else if (b.type == "Netscape") window.sidebar.addPanel(title,url,"");
 else alert("Нажмите CTRL-D, чтобы добавить страницу в закладки.");
 return false;
}

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;

//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	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;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = xScroll;
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}







function showPopUp(link, width, height, resizable, scrollbars, toolbar)
{
    var centerX = (screen.width - width) / 2;
    var centerY = (screen.height - height) / 2;

    var params = 'directories=no,location=no,menubar=no,resizable=' + (resizable ? 'yes' : 'no') +
                 ',scrollbars=' + (scrollbars ? 'yes' : 'no') + ',status=no,toolbar=' + (toolbar ? 'yes' : 'no') + ',width=' + width +
                 ',height=' + height + ',left=' + centerX + ',top=' + centerY;
    window.open(link, '', params);
    return false
}

function showPopUpFullscreen(link, resizable, scrollbars, toolbar)
{
//    alert(screen.availHeight+"="+ screen.availWidth);
    var params = 'directories=no,location=no,menubar=no,resizable=' + (resizable ? 'yes' : 'no') +
                 ',scrollbars=' + (scrollbars ? 'yes' : 'no') + ',status=no,toolbar=' + (toolbar ? 'yes' : 'no') + ',width=' + screen.availWidth +
                 ',height=' + screen.availHeight + ',left=0,top=0';
    window.open(link, '', params);
    return false
}

function showHide(elementId, elId)
{
    element = document.getElementById(elementId);
    elementWide = document.getElementById('show_wide');
    element2 = document.getElementById(elId);
    node1 = document.createTextNode('Показать дополнительные параметры');
    if(element2)
    {
        if(element2.style.display == 'block')
        {
            element2.style.display = 'none';
            element2.style.visibility = 'hidden';
            elementWide.value='0';
        }else
        {
            element2.style.display = 'block';
            element2.style.visibility = 'visible';
            node1 = document.createTextNode('Скрыть дополнительные параметры');
            elementWide.value='1';
        }
    }

	element.removeChild(element.firstChild);
	element.appendChild(node1);

}

function voteComment(idA, vote)
{
    voteInput = document.getElementById('vvote');
    voteInput.value = vote;
    for(i=1;i<=5;i++)
    {
        a = document.getElementById('pph'+i);
        if(vote<i)
            a.src = '/css/tImages/zv1.gif';
        else
            a.src = '/css/tImages/zv.gif';

    }
    //alert(voteInput.value);
}

function showHideSubscribe(elementId)
{
    element = document.getElementById(elementId);
    if(element)
    {
        if(element.style.display == 'block')
        {
            element.style.display = 'none';
            element.style.visibility = 'hidden';
        }else
        {
            element.style.display = 'block';
            element.style.visibility = 'visible';
        }
    }
}
