var xmlRequest;
var targetForXmlRequest; 
var browserWmode = "window";
var target = "sizer";
var IE='\v'=='v';

if(IE){
	browserWmode = "opaque";
}
var minimumWidth = 900;
var minimumHeight = 500;
var windowWidth = 0;
var windowHeight = 0;
var fitsize = true;
var counted;

function countMe(){
	var divTag = document.createElement("div");
        
	divTag.id = "counter";
	divTag.className ="addContent";
	
	divTag.innerHTML = '<img src="http://counter.yadro.ru/hit?r'+escape(document.referrer)+((typeof(screen)=='undefined')?'':';s'+screen.width+'*'+screen.height+'*'+(screen.colorDepth?screen.colorDepth:screen.pixelDepth))+';u'+escape(document.URL)+';'+Math.random()+'" width=1 height=1 alt="">';
	
	document.body.appendChild(divTag);
	
	counted = true;
}

function checkSize(){
	
	var flashsite = document.getElementById("flashsite");
	
	if(!counted){
		countMe();
	}
	
	if(!flashsite){
		if(document.documentElement){  
			document.documentElement.scroll = "auto";
			document.documentElement.style.overflow = "auto";
		}
		if(document.body){  
			document.body.scroll = "auto";
			document.body.style.overflow = "auto";
        }
		if(typeof( window.innerHeight ) == 'number' ) {
			window.scrollbars.visibility = true;
		}
		return;
	}
	
	getWindowSize();
	targetResize();
	
	//if(IE && !fitsize){
	//	changeWindowSize();
	//}

}

function setTargetW(w) {
	if (document.all && !document.getElementById) {
		document.all[target].style.pixelWidth = w;
	} else {
		document.getElementById(target).style.width = w;
	}
}

function setTargetH(h) {
	if (document.all && !document.getElementById) {
		document.all[target].style.pixelHeight = h;
	} else {
		document.getElementById(target).style.height = h;
	}
}

function getWindowSize() {
	if( typeof( window.innerWidth ) == 'number' ) {
		windowWidth = window.innerWidth;
		windowHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
}

function targetResize(){

	if(windowHeight<minimumHeight || windowWidth<minimumWidth) {
		fitsize = false;
		
		if(windowWidth<minimumWidth){
			setTargetW(minimumWidth);
		}else{
			setTargetW(windowWidth);
		}	
		
		if(windowHeight<minimumHeight){
			setTargetH(minimumHeight);
		}else{
			setTargetH(windowHeight);
		}

		document.body.style.overflow = "auto";
	
	}else{
		
		setTargetH(windowHeight);
		setTargetW(windowWidth);
		
		document.body.style.overflow = "hidden";

	}
}


function createXMLRequest(){  
	var xmlhttp;
	try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	  try {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
		xmlhttp = false;
	  }
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	  xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}  
function loadAndSetContent(file, query, target){ 
	
	targetForXmlRequest = target;

	if(!xmlRequest){
		 xmlRequest = createXMLRequest();
	}
	
	xmlRequest.open('post', file , true ); 
	xmlRequest.onreadystatechange = setContent; 
	xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	xmlRequest.send(query);              
}  
function setContent(){ 
	if (xmlRequest.readyState == 4) {
		 if(xmlRequest.status == 200) {
		   //alert(xmlRequest.responseText);
		   targetForXmlRequest.innerHTML = xmlRequest.responseText;
		 }
	}
}

function openNewWindow(myURL, width, height){
	myNewWindow=window.open( myURL ,'newWindow','width='+(width)+',height='+(height)+',top='+((document.body.clientHeight/2)-height/3)+',left='+((document.body.clientWidth/2)-width/2));
	myNewWindow.document.write("<title>FOTO</title>\n<html>\n<body topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>\n<img src='"+myURL+"' border=0></body></html>");
}
function openNewFile(myURL, width, height){
	myNewWindow=window.open( myURL ,'_blank', 'scrollbars=yes, width='+(width+20)+',height='+(height+20)+',top='+((document.body.clientHeight/2)-height/3)+',left='+((document.body.clientWidth/2)-width/2));
}

function oopsPopup() {
    if((navigator.language && navigator.language.indexOf("ja") != -1) || (navigator.systemLanguage && navigator.systemLanguage.indexOf("ja") != -1) || (navigator.userLanguage && navigator.userLanguage.indexOf("ja") != -1)) {
        var URLtoOpen = "http://download.skype.com/share/skypebuttons/oops/oops_ja.html";
    } else {
        var URLtoOpen = "http://download.skype.com/share/skypebuttons/oops/oops.html";
    }
var windowName = "oops";
var popW = 540, popH = 305;
var scrollB = 'no';
w = screen.availWidth;
h = screen.availHeight;
var leftPos = (w-popW)/2, topPos = (h-popH)/2;
oopswindow = window.open(URLtoOpen, windowName,'width=' + popW + ',height=' + popH + ',scrollbars=' + scrollB + ',screenx=' +leftPos +',screeny=' +topPos +',top=' +topPos +',left=' +leftPos);
return false;
}

function skypeCheck() {
    if(CantDetect) {
        return true;
    } else if(!activex) {
        var skypeMime = navigator.mimeTypes["application/x-skype"];
        detected = true;
        if(typeof(skypeMime) == "object") {
            return true;
        } else {
            return oopsPopup();
        }
    } else {
        if(isSkypeInstalled()) {
            detected = true;
            return true;
        }
    }
    
    detected = true;
    return oopsPopup();
}
function skype(){
	if(skypeCheck()){
		window.opener =  window.open("skype:anbradio?call","_blank");
	}
}


