function ChanGE(a,b){
	//alert(a+', '+b);
	if(b==false){	
	    document.getElementById(a).innerHTML='отметьте, чтобы отображать страницу';	
	} else {
		document.getElementById(a).innerHTML='снимите отметку, чтобы скрыть страницу';
	}
	
	
}

function ialert(a){
	alert(a);
}

// JavaScript Document
function getList(a,b){
	
	var sql = "id="+a+"&answer="+b;
	getGet(sql);
	
}

var req;
function createRequestObject()
{
    if (window.XMLHttpRequest) {
        try {
            req = new XMLHttpRequest();
        } catch (e){}
    } else if (window.ActiveXObject) {
        try {
            req = new ActiveXObject('Msxml2.XMLHTTP');
        } catch (e){
          try {
              req = new ActiveXObject('Microsoft.XMLHTTP');
          } catch (e){}
        }
    }
    return req;
}


function getGet(a){
	
	//alert(a); exit;
	var req = createRequestObject();
	if (req) {  
	  
	  var url = encodeURI('http://'+document.domain+'/ajax.php?'+a+'&rand='+Math.random());
	  req.onreadystatechange = ReReload;  
	  req.open("GET", url, true);
	  req.send(null);	
		
   }
	
}

function getPost(a){
	
	var req = createRequestObject();
	if (req) {  
	  
		var url = encodeURI('http://'+document.domain+'/ajax.php');
		req.onreadystatechange = ReReload;  
		req.open("POST", url, true);
		req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
		req.send(a);	
		
   }
	
}

function ReReload(){
	
    abort = window.setTimeout("req.abort();", 5000);  
	if (req.readyState == 4) { 
	
		//alert(req.responseText); exit;
		clearTimeout(abort);
		if (req.status == 200) {
			
		      var text = req.responseText;
			  var str = /||/g
			  var result = str.test(text);
			  
			  if(result==true){
			  
				  var flo = text.split("||");
				  var content=flo[0];
				  var id=flo[1];
			  
			  }
			  
		      if(id && content) {
				  
				  if(id!='akb_uid'){
				  
				if(document.getElementById(id).style.display=='none') document.getElementById(id).style.display='';
				if(content=='none') document.getElementById(id).style.display='none';
				document.getElementById(id).innerHTML = content;
				
				  } else document.getElementById(id).value = content;
				  
			  } else {
				
				if(text!='') {
					
					//alert(text);
					str = /http/g
			        result = str.test(text);
					
					if(result==true){
						
						document.location.href=text;
						
					} else {
						
					   alert(req.responseText);
					
					}
				}
				
			  }
		
		}
	  
	}
	
}


function wopen(url,name,w,h){
  var w=window.open(url,name,"width="+w+",height="+h);
}

var http = createRequestObject();
function searchPre(a) {
	
  searchq = encodeURI(a);
  nocache = Math.random();
  http.open('get', 'http://'+document.domain+'/ajax.php?id=search&word='+searchq+'&nocache = '+nocache);
  http.onreadystatechange =  searchNameqReply;
  http.send(null);

}

function searchNameqReply() {

  if(http.readyState == 4){
  
  if(http.responseText!=""){
  
	var answer = document.getElementById('search_result');
	if(answer.style.display=='none') answer.style.display='';
	var response = http.responseText;
	answer.innerHTML = response;
	
  }
  
  }

}

function AddInput(a,b,c,d,e){
	
	//alert(d+'\n'+e); exit;
	document.getElementById(a).value = b;
	document.getElementById(c).style.display='none';
	if(d!='' && e!=''){
		
		var idd = d.split("|");
		var valuee = e.split("|");
		for(var i=0;i<idd.length;i++) document.getElementById(idd[i]).value = valuee[i];
		document.getElementById('reload').style.display = '';
		
	}
	
	
}

function goo(a){
	document.location.href='http://'+document.domain+'/'+a+'.html';
}

function CheckBoxAll(a,b){
	//alert(document.getElementById('allCheckbox').checked);
	var array = b.split(',');
	for(i=0;i<array.length;i++){
		
	   var op = document.getElementById(a+array[i]);
	   if(op){
		   
	      if(document.getElementById('allCheckbox').checked==false) {
			  op.checked = false;
		  } else op.checked = true;
		  
	   }
	
	}
	
}

function CheckBoxAllCatalog(a){
	//alert(a);
	var array = a.split(',');
	for(i=0;i<array.length;i++){
		
	   var op = document.getElementById(array[i]);
	   if(op){
		   
	      if(document.getElementById('allCheckbox').checked==false) {
			  op.checked = false;
		  } else op.checked = true;
		  
	   }
	
	}
	
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function Open(a){
	
	var div = document.getElementById(a);
	if(div.style.display=='none') {
	
		div.style.display=''; 
	
	} else { 
	
		div.style.display='none'; 
	
	}
	
}


function Ope(a,b,c){
	
	var div = document.getElementById(a);
	if(div.style.display=='none') {
	
		div.style.display=''; 
		var sql = 'id=menu&return='+a;
		if(b) sql += '&a='+b;
		if(c) sql += '&get='+c;
		getGet(sql);
	
	} else { 
	
		div.style.display='none'; 
		div.innerHTML='';
	
	}
	
}

function getPreGet(a){
	
	var idd = 'id,return,content';
	var arr = idd.split(',');
	var arrr = a.split(',');
	var opl='';
	for(i=0;i<arrr.length;i++){
		
	   if(i>0) opl += '&';
	   opl += arr[i]+'='+arrr[i];
	   //alert(arr[i]);
	
	}
	//alert(opl);
	getGet(opl);
	
}

// включен ли флеш





function get_el(id){return d.getElementById(id);}

function flash_getversion() {
 var f=0, fz=0, n=navigator;

 if (n.platform=='Win32' && !window.opera && window.ActiveXObject)
 {
 for (var i=3;i<10;i++)
 { 
 if (eval('new ActiveXObject("ShockwaveFlash.ShockwaveFlash.'+i+'")')) f=i;
 } 
 } 

 if (n.plugins)
 { 
 for (var i=0;i<n.plugins.length;i++)
 {
 if (n.plugins[i].name.indexOf('Flash') > -1)
 {
 fz=parseInt(n.plugins[i].description.charAt(16));
 if (fz>f) f=fz;
 }
 }
 }
 return f;
}



function showFlash(f,w,h,t,i,href)
{
  var fv = flashOn();
  
  //document.write('<strong>' + fv + '</strong>');
  
  if (fv)
  {
	document.write('<object id="banner" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'+w+'" height="'+h+'" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" align="middle" wmode="opaque" style="z-index : 1;"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="flash/'+f+'" /> <param name="quality" value="high" /> <param name="bgcolor" value="#fff" /> <embed type="application/x-shockwave-flash" width="'+w+'" height="'+h+'" src="flash/'+f+'" quality="high" wmode="opaque" bgcolor="#fff" name="'+t+'" allowscriptaccess="sameDomain" pluginspage="http://www.macromedia.com/go/getflashplayer" align="middle"></embed> </object>');
  }
  else
  {
	document.write('<a href="'+href+'" title="'+t+'" target="_blank">'+
	'<img src="http://www.4akb.ru/flash/'+i+'" width="'+w+'" height="'+h+'" alt="'+t+'" title="'+t+'">'+
	'</a>');
  }
}




////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// это кусок кода для определения того, включен ли флеш




// initialize global variables
var detectableWithVB = false;
var pluginFound = false;


function goURL(daURL) {
    // if the browser can do it, use replace to preserve back button
    if(javascriptVersion1_1) {
	window.location.replace(daURL);
    } else {
	window.location = daURL;
    }
    return;
}

function redirectCheck(pluginFound, redirectURL, redirectIfFound) {
    // check for redirection
    if( redirectURL && ((pluginFound && redirectIfFound) ||
	(!pluginFound && !redirectIfFound)) ) {
	// go away
	goURL(redirectURL);
	return pluginFound;
    } else {
	// stay here and return result of plugin detection
	return pluginFound;
    }
}

function canDetectPlugins() {
    if( detectableWithVB || (navigator.plugins && navigator.plugins.length > 0) ) {
	return true;
    } else {
	return false;
    }
}

function detectFlash(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Shockwave','Flash');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
    }
    // check for redirection
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectDirector(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Shockwave','Director');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl('SWCtl.SWCtl.1');
    }
    // check for redirection
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectQuickTime(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('QuickTime');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectQuickTimeActiveXControl();
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectReal(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('RealPlayer');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = (detectActiveXControl('rmocx.RealPlayer G2 Control') ||
		       detectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)') ||
		       detectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)'));
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectWindowsMedia(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Windows Media');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl('MediaPlayer.MediaPlayer.1');
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectPlugin() {
    // allow for multiple checks in a single pass
    var daPlugins = detectPlugin.arguments;
    // consider pluginFound to be false until proven true
    var pluginFound = false;
    // if plugins array is there and not fake
    if (navigator.plugins && navigator.plugins.length > 0) {
	var pluginsArrayLength = navigator.plugins.length;
	// for each plugin...
	for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
	    // loop through all desired names and check each against the current plugin name
	    var numFound = 0;
	    for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
		// if desired plugin name is found in either plugin name or description
		if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) ||
		    (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
		    // this name was found
		    numFound++;
		}
	    }
	    // now that we have checked all the required names against this one plugin,
	    // if the number we found matches the total number provided then we were successful
	    if(numFound == daPlugins.length) {
		pluginFound = true;
		// if we've found the plugin, we can stop looking through at the rest of the plugins
		break;
	    }
	}
    }
    return pluginFound;
} // detectPlugin


// Here we write out the VBScript block for MSIE Windows


if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
    document.writeln('<script language="VBscript">');

    document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
    document.writeln('detectableWithVB = False');
    document.writeln('If ScriptEngineMajorVersion >= 2 then');
    document.writeln('  detectableWithVB = True');
    document.writeln('End If');

    document.writeln('\'this next function will detect most plugins');
    document.writeln('Function detectActiveXControl(activeXControlName)');
    document.writeln('  on error resume next');
    document.writeln('  detectActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('\'and the following function handles QuickTime');
    document.writeln('Function detectQuickTimeActiveXControl()');
    document.writeln('  on error resume next');
    document.writeln('  detectQuickTimeActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('    detectQuickTimeActiveXControl = False');
    document.writeln('    hasQuickTimeChecker = false');
    document.writeln('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
    document.writeln('    If IsObject(hasQuickTimeChecker) Then');
    document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
    document.writeln('        detectQuickTimeActiveXControl = True');
    document.writeln('      End If');
    document.writeln('    End If');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('</scr' + 'ipt>');
}




function flashOn(){
var res = false;
if(canDetectPlugins()) {
    //document.write('Плагины обнаружены - Урра!!');
	/*document.write('<b>Supports Shockwave for Director:</b> ' + detectDirector() + '<br>' +
		   '<b>Supports Shockwave Flash:</b> ' + detectFlash() + '<br>' +
		   '<b>Supports QuickTime:</b> ' + detectQuickTime() + '<br>' +
		   '<b>Supports RealPlayer:</b> ' + detectReal() + '<br>' +
		   '<b>Supports Windows Media Player:</b> ' + detectWindowsMedia());*/

		   if (detectFlash())
		   //document.write('/nФлеш включен');
			res = true;
		   //else
		   //document.write('/nФлеш вЫключен');
}
//else
//{
//	document.write('Плагины не обнаружены =(');
//}
return res;

}
