// global functions.

function loadframe(location,module,page,id) {
  
   eraseCookie('frame'); // delete saved javascript cookie modules.
   eraseCookie('page');  // delete any saved javascript cookie page.
   
   var location = location + module + "/" + page;
   parent.main.location=location; // redirection
   
   markup(id);
   createCookie('frame',module,1);
   createCookie('page',page,1);
   createCookie('menuid',id,1);
   
   
}
 // create a javascript cookie.

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

 // read cookies.

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

// delete cookies.

function eraseCookie(name) {
	createCookie(name,"",-1);
}

// ************************************************************************************************************************
// Main menu frame loading;



 // load from frame.



    // change main menu stylesheet.

	function markup(T) {

		i = 0;
        while (document.getElementById("topmenu" + i) != null) {
			document.getElementById("topmenu" + i).className = "menu";
			i++;
		}
		document.getElementById("topmenu" + T).className = "mm";
		}
		
		// change main menu stylesheel from frame.
		
	function markupFrame(T) {

		i = 0;
        while (frames["topFrame"].document.getElementById("topmenu" + i) != null) {
			frames["topFrame"].document.getElementById("topmenu" + i).className = "menu";
			i++;
		}
		frames["topFrame"].document.getElementById("topmenu" + T).className = "mm";
	}
	
	function markupInside(T) {
         i = 0;
        while (window.parent.frames['topFrame'].document.getElementById("topmenu" + i) != null) {
			window.parent.frames['topFrame'].document.getElementById("topmenu" + i).className = "menu";
			i++;
		}
		window.parent.frames['topFrame'].document.getElementById("topmenu" + T).className = "mm";		
	}
			
		
		
		// show Tabs.
		
	function ShowTab(T) {

		i = 0;

		while (document.getElementById("tab" + i) != null) {
			document.getElementById("div" + i).style.display = "none";
			document.getElementById("tab" + i).className = "";
			i++;
		}

		document.getElementById("div" + T).style.display = "block";
		document.getElementById("tab" + T).className = "active";
		document.getElementById("currentTab").value = T;
		}	
		
		// function change style.
		function changeStyle(cid,id,style) {
			
			var b =$("#"+cid);
			if (b.is(":checked")) {
				$("#"+id).addClass(style);
			} else {
				$("#"+id).removeClass(style);
			}
		}
		
		function checkAll(id) {
			
			var b =$("#"+id);
			
			if (b.is(":checked")) {
			$(':checkbox').attr('checked',true); 
			$("#myTable tr").removeClass("odd");
			$("#myTable tr").addClass("css");			

			} else {
			$(':checkbox').attr('checked',false);	
			$("#myTable tr").removeClass("css");
			$("#myTable tr:even").addClass("odd");
			}
		
		}
		
		function showLoad() {
window.onload = function(){
  var loadingMsg = document.getElementById("loading");
  if(loadingMsg)loadingMsg.style.display = "";
}
		}
		
	function loadnow() {
		document.getElementById('loading').style.display = "block";	
		}	
		
		function unloadnow() {
			document.getElementById('loading').style.display = "none";
		}






function tStyle(p,style) {
	p.className = style;
}

function reloadFrm() {
	parent.frames["main"].location.reload()
}


function hideNotice(id) {
 document.getElementById(id).style.display='none';	
}

