/*
JavaScript Document
Created: May 01, 2010
Author: M Haris Munir
Author Email: haris.multi@gmail.com
Author WebSite: http://opensource.harishse.com/js

Example:
	hr_pageblock.load(); // in head tag
	hr_pageblock.apply();	// on click
Stylesheet class
.hr_pageblock{position:absolute;left:0px;top:0px;filter:alpha(opacity=60);opacity:0.6;background-color:#333;z-index:99;}

*/
var hr_pageblock = {
	areaId: 'hr_pageblock',
	iew: false,
	pageload: false,
	//resizepost: '',
	load: function (){
		hr_pageblock.init();
		return false;
		var onload = window.onload;
		if(typeof window.onload == 'function'){
			window.onload = function(){
				onload();
				hr_pageblock.init();
			}
		}else{
			window.onload = function (){
				hr_pageblock.init();
			}
		}
	},
	init: function (){
		if(typeof this.setTimeout == 'function'){
			window.setTimeout(function (){
				hr_pageblock.setTimeout();
			},(this.timeout*1000));
		}
		this.pageload = true;
		var obj = this.createArea();
		var getSize = this.getSize(true);
		obj.style.width = getSize[0] + 'px';
		obj.style.height = getSize[1] + 'px';
		var onresize = window.onresize;
		if(typeof window.onresize == 'function'){
			window.onresize = function(){
				onresize();
				hr_pageblock.onresize();
			}
		}else{
			window.onresize = function (){
				hr_pageblock.onresize();
			}
		}
	},
	onresize: function (){
		var obj = document.getElementById(this.areaId);
		var getSize = this.getSize();
		obj.style.width = getSize[0] + 'px';
		obj.style.height = getSize[1] + 'px';
		if(typeof this.resizepost == 'function') this.resizepost(getSize);
	},
	apply: function (func){
		var obj = document.getElementById(this.areaId);
		if(typeof func == 'function'){
			func(obj);
			return;
		}
		obj.style.display = 'block';
	},
	hide: function (){
		var obj = document.getElementById(this.areaId);
		obj.style.display = 'none';
	},
	getSize: function (f){
		var size = new Array();
		var ObjBody = document.getElementsByTagName('body').item(0);
		//var ObjBody = window.document.;
		if(ObjBody.offsetWidth >= ObjBody.scrollWidth || f){
			var width = ObjBody.scrollWidth
		}else{
			var width = ObjBody.offsetWidth;
		}
		
		//alert('1 ' + ObjBody.scrollHeight)
		//alert('2 ' + document.documentElement.clientHeight) // M I
		/*alert('3 ' + window.outerHeight)
		alert('4 ' + document.height)
		alert('5 ' + document.body.offsetHeight)
		alert('6 ' + window.screen.availHeight)
		alert('7 ' + window.screen.height)*/
		
		if(!this.iew) this.iew = ObjBody.offsetWidth - document.body.scrollWidth;
		if(document.all){ // if IE
			size[0] = (ObjBody.offsetWidth - ((this.iew)?this.iew:0));
			var ieheight = ObjBody.scrollHeight;
			if(document.documentElement){
				if(document.documentElement.clientHeight > ieheight)
					ieheight = document.documentElement.clientHeight;
			}
			size[1] =  ieheight;
		}else{
			size[0] = width;
			size[1] = document.documentElement.clientHeight;
		}
		
		
	
		return size;
	},
	getclientHeight: function (){
		return document.documentElement.clientHeight;
	},
	createArea: function (){
		var obj = document.createElement('div');
		obj.style.display = 'none';
		if(!document.all) obj.style.position = 'fixed';
		obj.className = 'hr_pageblock';
		this.areaId = "hr_pageblock" + Math.ceil(Math.random()*99);
		obj.id = this.areaId;
		var ebody = document.getElementsByTagName('body').item(0);
		ebody.insertBefore(obj,ebody.firstChild);
		return obj;
	},
	
	resizepost : function (popup_id){
		var getsize = hr_pageblock.getSize();
		var Objzimg = document.getElementById(popup_id);
		var midPoint = Math.ceil(getsize[0]/2) - (Objzimg.offsetWidth/2);
		var midPointV  = hr_pageblock.getclientHeight();
		midPointV = Math.ceil((midPointV)/2) - (Objzimg.offsetHeight/2);
		Objzimg.style.left = midPoint + 'px';
		Objzimg.style.top = midPointV + 'px';
	},
	
	// extras
	timeout: 0,
	setTimeout: false
}

// fade in out effect
var MC_v = 0;
var MC_va = 0;
var MC_Access = true;
var MC_break = 100;
function show_MC(MC_id,bpoint){
	if(MC_Access) MC_Access = false; else return false;
	var obj =  document.getElementById(MC_id);
	if(bpoint) MC_break = bpoint;
	if(obj.style.display == 'none'){
		obj.style.display = '';
		MC_v = 0;
		MC_va = 0;
		show_MCOnj(MC_id,true);
	}else{
		MC_v = MC_break;
		MC_va = 0;
		show_MCOnj(MC_id,false);
	}
}
function show_MCOnj(MC_id,MC_Action){
	var obj =  document.getElementById(MC_id);
	if(MC_Action){
		if(MC_v > MC_break){ MC_Access = true; return false; }
			MC_va = (MC_va + 2);
			MC_v = MC_v + MC_va;
	}else{
		if(MC_v < 0){ MC_Access = true; obj.style.display = 'none'; return false; }
			MC_va = (MC_va + 2);
			MC_v = MC_v - MC_va;
	}
	hr_slide_01_pOpacity_MC(document.getElementById(MC_id),MC_v);
	setTimeout("show_MCOnj('"+MC_id+"',"+MC_Action+")",10);
}
function hr_slide_01_pOpacity_MC(obj,value,getinfo){
	try{obj.filters.alpha.opacity = value; }catch(e){}
	try{obj.style.opacity=(value/100);}catch(e){}
}


// Last updated: November 11, 2009
var stillobj = {
	resttop: false,
	start: function (id){
		var obj = document.getElementById(id);
		var getrestdata = new Array();
		var position = new Array();
		position[0] = obj.style.top;
		position[1] = obj.style.left;
		
		getrestdata[0] = obj.offsetTop;
		getrestdata[1] = obj.offsetLeft;
		
		var ObjBody = document.getElementsByTagName('body').item(0);
		var getd = new Array();
		getd[0] = ObjBody.scrollTop; //document.body.scrollTop;
		getd[1] = ObjBody.scrollLeft; //document.body.scrollTop;
		
		if(!getd[0]){
			position[0] = this.resttop + 'px';
			return;
		}
		if(this.resttop){
			obj.style.top = (getd[0]+(this.resttop-0)) + 'px';
		}else{
			obj.style.top = (getd[0]+(getrestdata[0]-0)) + 'px';
			this.resttop = getrestdata[0];
		}
	}
}