// Expand Collapse Function
var arrExpColl = new Array();

function expandCollapse() {
	for (var i=0; i<expandCollapse.arguments.length; i++) {
		var element = document.getElementById(expandCollapse.arguments[i]);
		element.style.display = (element.style.display == "none") ? "block" : "none";
		arrExpColl[expandCollapse.arguments[i]] = element.style.display;
	}
}


// Pop Up for Gallery
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features).focus();
}


var asianceScrollVar = new Array();
var asianceMenuStatus = new Array();
var myCookie = new CJL_CookieUtil("menuStatus_cookie",43200,"/"); 

//load the asianceMenuPrefVar array from cookie

function asianceScrollUpDown(divID)
{
   if (asianceScrollVar[divID]==1){
       new Effect.SwitchOff(divID,{duration:0.5});
       asianceScrollVar[divID]=0;
   } else {
       asianceScrollVar[divID]=1;
       new Effect.BlindDown(divID,{duration:0.2});
   }
}

function asianceMenuUpDown(divID)
{
   var hdivID;
   var sdivID;
   var mdivID;

   hdivID = divID + 'HeaderHide';
   sdivID = divID + 'HeaderShow';
   mdivID = divID + 'Full';
   //alert(asianceMenuStatus[divID]);
   if (asianceMenuStatus[divID]==1){
       new Effect.BlindDown(mdivID,{duration:0.2});
       asianceMenuStatus[divID]=0;
   } else {
       asianceMenuStatus[divID]=1;
       new Effect.BlindUp(mdivID,{duration:0.2});
   }
   expandCollapse(hdivID,sdivID);
   myCookie.setSubValue(divID,asianceMenuStatus[divID]);
//save the asianceScrollVar array into a cookie
}
//var test = myCookie.getSubValue("sexFull");

//alert(test);
function asianceMenuInit()
{
   if (myCookie.cookieExists()){
      asianceMenuStatus = myCookie.getArray();

      for (var i in asianceMenuStatus) {
         if (asianceMenuStatus[i]==1) {
            //asianceMenuUpDown(i);
            //alert("did:" + i);
            toggleDisplay(i+"Full");
            toggleDisplay(i+"HeaderShow");
            toggleDisplay(i+"HeaderHide");
            //asianceMenuStats[i] = tmpMenuStats[i]; 
         }
      }
      //alert (asianceMenuStats.length);
      //alert("testing");
      //alert(asianceMenuStats["entertainmentFull"]);
      //document.div["entertainmentFull"]
   }
   //alert("testingbla");
   asianceUpdateMarkedArticles(1);
}

function toggleDisplay(id){
	 /*check the element exists and can be accessed*/
	   if(document.getElementById && document.getElementById(id)){   
		   /*get hold of the element*/
		   var ele = document.getElementById(id);   
		   if(ele.style.display!="none"){   
			   ele.style.display="none";       
		   }else{
		   	   ele.style.display="block";     
		   }
	   }
	}

//asianceMenuInit();

function asianceMarkAsRead(id)
{
	 /*check the element exists and can be accessed*/
	   if(document.getElementById && document.getElementById(id)){   
		   /*get hold of the element*/
		   var ele = document.getElementById(id);   
      		//alert(id);
	           ele.style.background="url(/images/check_read.gif) no-repeat";       
	   }
}

function asianceUpdateMarkedArticles(id)
{
   //alert(id);
   var myAjax = new Ajax.Request('/_includes/control/updateMarkedArticles.php?id='+id,{onComplete:asianceRefreshToc});
}

function asianceClipArticle(nid,uid) {
   //alert('This article has been clipped.');
   var myAjax = new Ajax.Request('/clipArticle.php',{method:'post', postBody:'nid='+nid+'&uid='+uid, onSuccess:handlerFunc, onFailure:errFunc});
}

function asianceRemoveClippedArticle(id)
{
	 if (confirm("Are you sure you want to remove this clipped article?")) 
	 {
   		var myAjax = new Ajax.Request('/clipArticle.php',{method:'post', postBody:'action=remove&nid='+id});
   		var myEffect = new Effect.SwitchOff('clipped'+id);
	 }
}

var handlerFunc = function(t) {
    alert('This article has been clipped.');
}

var errFunc = function(t) {
    alert('Error ' + t.status + ' -- ' + t.statusText);
}



function asianceRefreshToc(response)
{
   var myMarkedArticles = response.responseText.split(',');
   for (i=0;i<myMarkedArticles.length;i++){
      asianceMarkAsRead(myMarkedArticles[i]);
   }
}

function bpotoggleDisplay(id){
	 /*check the element exists and can be accessed*/
	   if(document.getElementById && document.getElementById(id)){   
		   /*get hold of the element*/
		   var ele = document.getElementById(id);   
		   if(ele.style.display!="block"){   
			   ele.style.display="block";       
		   }else{
		   	   ele.style.display="none";     
		   }
	   }
	}