
//$$$$$$$$$$$$$$$$$$$
var KMAXHEIGHT = 100;
var KOPENNING = 2;
var KCLOSING = 1;
var KNONE = 0;
var iStatus=0;
var KTIMEOUT = 1;
var KCHANGINGHEIGHT = 2;

function OpenTab(id){

iCloseTabChecker=1;
if(iStatus==KCLOSING)
	return;

     var strUrl = "";
     var strDivId;
 
 switch(id){
    case 1:
     //objContainer.style.backgroundColor="#ff0000";
     strUrl  = "/getlocalblock.aspx?app=documents&page=document&docParId=11964&docId=11968";
     strDivId = "divMainScrolling";
     document.getElementById("divMainScrolling2").style.display = "none";
     break;
    case 4:
     //objContainer.style.backgroundColor="#333333";
     strUrl  = "/getlocalblock.aspx?app=documents&page=document&docParId=11964&docId=11972";
     strDivId = "divMainScrolling";
     document.getElementById("divMainScrolling2").style.display = "none";
     break;
    case 3:
     //objContainer.style.backgroundColor="#0000ff";
     strUrl  = "/getlocalblock.aspx?app=documents&page=document&docParId=11964&docId=11969";
     strDivId = "divMainScrolling";
     document.getElementById("divMainScrolling2").style.display = "none";
     break;
    case 5:
     //objContainer.style.backgroundColor="#000000";
     strUrl  = "/getlocalblock.aspx?app=documents&page=document&docParId=11964&docId=11973";
     strDivId = "divMainScrolling2";
     document.getElementById("divMainScrolling").style.display = "none";
     break;
    case 2:
     //objContainer.style.backgroundColor="#00ff00";
     strUrl  = "/getlocalblock.aspx?app=documents&page=document&docParId=11964&docId=11970";
     strDivId = "divMainScrolling2";
     document.getElementById("divMainScrolling").style.display = "none";
     break;
    case 6:
     //objContainer.style.backgroundColor="#efefef";
     strUrl  = "/getlocalblock.aspx?app=documents&page=document&docParId=11964&docId=11971";
     strDivId = "divMainScrolling2";
     document.getElementById("divMainScrolling").style.display = "none";
     break;
  }

     document.getElementById(strDivId).style.display = "block";
     CheckIsTabOpened(strDivId);
     LoadPage(strUrl,strDivId);
}

function CloseTab(){
    if(iStatus==KNONE){
	var objContainer = document.getElementById("divMainScrolling");
	TapCloserAPI(objContainer.id);

	var objContainer2 = document.getElementById("divMainScrolling2");
	TapCloserAPI(objContainer2.id);
    }
}

function CheckIsTabOpened(divId){
    var objContainer = document.getElementById(divId);
    if(iStatus==KNONE && objContainer.style.display!="block"){
	TapOpenerAPI(divId);
    }
}

var iFade=100;
function TapCloserAPI(divId){
  var objContainer = document.getElementById(divId);

   var iCurrentHeight = objContainer.style.height.replace("px","") - 0;
   objContainer.innerHTML = "";
   if(iCurrentHeight > 0){
	objContainer.style.height = iCurrentHeight - KCHANGINGHEIGHT;
	if(iCurrentHeight==KCHANGINGHEIGHT){
	    objContainer.style.display = "none";
	}
	iStatus = KCLOSING;
	setTimeout("TapCloserAPI('"+divId+"')",KTIMEOUT);
   }else{
	iStatus = KNONE;
   }
}

function TapOpenerAPI(divId){
   var objContainer = document.getElementById(divId);

   var iCurrentHeight = objContainer.style.height.replace("px","") - 0;
   if(iCurrentHeight < KMAXHEIGHT){
	objContainer.style.height = iCurrentHeight + KCHANGINGHEIGHT;
	KCHANGINGHEIGHT++;
	objContainer.style.display = "block";
	iStatus = KOPENNING;
	setTimeout("TapOpenerAPI('"+divId+"')",KTIMEOUT);
   }else{
	KCHANGINGHEIGHT = 1;
	iStatus = KNONE;
   }
}

var iCloseTabChecker=1;
function LogOutTab(){
	if(iCloseTabChecker==0){
		CloseTab();
		iCloseTabChecker = 1;
	}
	setTimeout("LogOutTab()",2000);
}
LogOutTab();

///-----------------------------------------------------\\\
///							\\\
///			MAIN TABS			\\\
///							\\\
///-----------------------------------------------------\\\


function SwitchClickableTab(tabId){
	document.getElementById("tabClickable1").className = "tab-headerdown";
	document.getElementById("tabClickable2").className = "tab-headerdown";
	//document.getElementById("tabClickable3").className = "tab-headerdown";
	//document.getElementById("tabClickable4").className = "tab-headerdown";

	document.getElementById("tabClickable"+tabId).className = "tab-headerup";

	var strUrl = "";
 	switch(tabId){
  	  case 1:
  	   strUrl = "/getlocalblock.aspx?app=documents&page=document&docParId=11964&docId=11974";
  	   break;
  	  case 2:
  	   strUrl = "/getlocalblock.aspx?app=documents&page=document&docParId=11964&docId=11975";
  	   break;
  	  case 3:
  	   strUrl = "/getlocalblock.aspx?app=documents&page=document&docParId=11964&docId=11976";
  	   break;
  	  case 4:
   	  strUrl = "/getlocalblock.aspx?app=documents&page=document&docParId=11964&docId=11977";
   	  break;
  	}
	LoadPage(strUrl,"divTabClickingContent");
} 

function LoadLastArticle(){
	LoadPage("http://portal.tpo.ir/tabs/lastArt.html","divLastArticle");

}

function OnLoadInits(){
	SwitchClickableTab(1);
	LoadLastArticle();
}

function LoadLargeImage(src){
	var strDivId = "divPopUpMessage";
	//document.getElementById(strDivId).className = "BackMain";
	document.getElementById(strDivId).innerHTML = "<img style='border:3px solid #ffffff' src='"+src+"'>";
	ShowPopUp(strDivId);
}

function UnLoadLargeImage(){
	var strDivId = "divPopUpMessage";
	HidePopUp(strDivId);
}
