function callExternalInterface(aid) {
    thisMovie("b").close(aid);
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}

function flash_go_next(id){
	document.getElementById('Window').innerHTML='';
	callExternalInterface(id);

}

function clear_and_close_div(id,idtext,x,y){
	document.getElementById('Window').innerHTML='';
	document.getElementById('Window').style.display='none';
//	alert(id);
//	listik(id,idtext,x,y);
}


function uploader_init () {
        uploader = new clUploadData('/upl.php');
}

function uploader_go (id) {
		
        uploader.upload(id);
}

var uploader;

function clUploadData ( thesrc ) {
	this.src = thesrc;
	this.src += "?";
	this.type = "text/javascript";
	this.oldScript  = document.createElement("SCRIPT");
	this.oldScript.type = this.type;
	this.callId = 0;
	document.body.appendChild(this.oldScript);
	this.upload = function ( theparams ) {
		var tParams = theparams || "";
		var newScript = document.createElement("SCRIPT");
		newScript.type = this.type;
		this.callId += 1;
		var randnumber=Math.floor(Math.random()*100000);
		newScript.src  = this.src + "callid=" + String(this.callId) + "&randnumber=" + randnumber + "&" + tParams;
		document.body.replaceChild(newScript,this.oldScript);
		this.oldScript = newScript;
	}
}
var frame_actual=0;
var frame_width=240	;
var frame_total=0;

var margin_target=0;
var margin_dest=0;
var margin_actual=0;
var frames_ppage=2;

function slidefr(n)
{
 var l = document.getElementById("tg1").getElementsByTagName("td");
 frame_total=l.length-1;

 margin_from=frame_actual*frame_width;

 if (n==1 && frame_actual!=0) // влево
  {
   margin_dest=frame_actual*frame_width;
   margin_actual=margin_dest;

   margin_target=frame_actual*frame_width-frame_width;
   frame_actual=frame_actual-1;
   
   frame_go(n);
  };

 if (n==2 && (frame_actual+frames_ppage)<=frame_total) // вправо
  {

   margin_dest=frame_actual*frame_width;
   margin_actual=margin_dest;
   margin_target=frame_actual*frame_width+frame_width;
   frame_actual=frame_actual+1;
   frame_go(n);
  };
};

function frame_go(n)
{
 dif=Math.abs(margin_target-margin_actual);
 speed=Math.round(dif/2);
 if (dif>10)
  {
   if (n==1) 
    {
     margin_actual=margin_actual-speed;
     document.getElementById("tg1").style.marginLeft="-"+margin_actual+"px";
    }
     else
    {
     margin_actual=margin_actual+speed;
     document.getElementById("tg1").style.marginLeft="-"+margin_actual+"px";
    };
   setTimeout("frame_go("+n+")",1);
  }
   else
  {
   if (frame_actual==(frame_total+1-frames_ppage)) change_frame_nav(2); // доехали до правого края
   if (frame_actual==0) change_frame_nav(1) // доехали до левого края
   if (frame_actual!=0 && (frame_actual!=(frame_total+1-frames_ppage))) change_frame_nav(0) // гдето по середине
   margin_actual=margin_target;
   document.getElementById("tg1").style.marginLeft="-"+margin_actual+"px";
  };
};
function change_frame_nav(direct){
	document.getElementById("prvpic").src="/i/arrBack"+(direct==1 ? "_" : "" )+".gif";
	document.getElementById("nxtpic").src="/i/arrForward"+(direct==2 ? "_" : "" )+".gif";
}
function change_back_go(v,ob){
	if(v==2){
		ob.style.backgroundColor='';
	}
	else{
		ob.style.backgroundColor='#fff';
	}
}

function flashisloaded(){
	if(location.hash!=''){
		var hh=location.hash;
		if(hh=='#classa'){
			callExternalInterface(2);
		}
		else if(hh=='#classb'){
			callExternalInterface(3);
		}
		else if(hh=="#all"){
			callExternalInterface(0);
		}
		else if(hh=="#free"){
			callExternalInterface(4);
		}
	}
}
