﻿// JScript File
// Original Author: hoangnx.fpt@gmail.com
// Granted DNN360.net for use 
//-----------------------------------------------
function FindObjectByID(idName)
{
	return document.getElementById(idName);
}

//-----------------------------------------------
function SetBlockWebClient(strName,intTabLength, intStart,unselect_class,select_class,isAjaxTab,module_url)
{
    try
    {
        //var strDivName = strName.substring(0,strName.length-2);
		var strDivName = strName.substring(0,strName.indexOf("_"));
		//alert(strDivName1 );
		var stri = strDivName;
        for (var i = 1; i <= intTabLength; i++)
        {
            
            var temp = i + intStart;
            if (temp < 10) 
                stri = strDivName+'_'+temp;
            else 
                stri = strDivName+'_'+temp;
            FindObjectByID(stri).className = unselect_class;
            FindObjectByID(FindObjectByID(stri).headers).style.display = "none";
        }
        FindObjectByID(strName).className = select_class;
		
		//--------------------now change the content------------------------------
		if (isAjaxTab=="1")
		{
		var path=module_url;
		var url = "RequestHandler.aspx?Divname=" + strName;
		//alert(strName);
		FindObjectByID(FindObjectByID(strName).headers).style.display = "block";
		var contentdiv="myAjaxDiv_"+strName;
		document.getElementById(contentdiv).innerHTML =contentdiv;
		postRequest(path,url,contentdiv);	
		}
        else 
		FindObjectByID(FindObjectByID(strName).headers).style.display = "block";
    }
    catch(ex){}
}
//------------------------------------------------------------------
//this function from http://www.peej.co.uk/articles/rich-user-experience.html
				function getHTTPObject() {
				if (typeof XMLHttpRequest != 'undefined') { 
				return new XMLHttpRequest(); 
				} 
				try {
				return new ActiveXObject("Msxml2.XMLHTTP"); 
				} catch (e) { 
				   try { 
				   return new ActiveXObject("Microsoft.XMLHTTP"); 
				   } catch (e) {}
				} 
				return false; 
				}
				/*
					Creates a XMLHTTP async-call to an ASP.NET async handler
				*/
				function postRequest(path,url,whichdiv)
				{
				var xmlhttp=getHTTPObject();
				xmlhttp.open("GET", path+url, true);
				// Register a callback for the call
					xmlhttp.onreadystatechange = 
						function ()
						{
				 	 	if (xmlhttp.readyState == 4)
							{
								var response = xmlhttp.responseText;
								document.getElementById(whichdiv).innerHTML = response ;
								if(xmlhttp.status == 200)
									return true;
									else
									document.getElementById(whichdiv).innerHTML = "Error retrieving XML data..!";
							}
							else
							{
							    document.getElementById(whichdiv).innerHTML = '<div align="center"><font size="1">Loading...</font></br><img alt="" src="'+path+'/spinner4.gif" vspace="10" /></div>';
							}
  						}
					
					// Send the actual request
					xmlhttp.send(null);
					
				}
				
				/*
					Clears the response div
				*/
				function clearResponse()
				{
					divResponse.innerHTML = "";
				}
			//-->
 