var loadedobjects=""
var rootdomain="http://"+window.location.hostname
function ajaxpage(url, containerid, times, img){

	var page_request = false
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE
	try {
		page_request = new ActiveXObject("Msxml2.XMLHTTP")
	} 
	catch (e){
	try{
		page_request = new ActiveXObject("Microsoft.XMLHTTP")
	}
	catch (e){}
	}
	}
	else
	return false
	page_request.onreadystatechange=function(){

	//divcreate()
	pr=page_request;
	co=containerid;
	document.getElementById(containerid).innerHTML="<center><img src='"+img+"' align='middle' /></center>"
	setTimeout('loadpage(pr, co)', times);	
	//setTimeout('clsdiv()', times);
	//loadpage(page_request, containerid)
	}
	page_request.open('GET', url, true)
	page_request.send(null)
}

function ajaxframe(url, containerid, times, img){
	
	divcreate()
	document.getElementById(containerid).innerHTML="<center><img src='"+img+"' align='middle' /></center>"	
	purl=url
	co=containerid;	
	setTimeout('loadiframe(purl, co)', times);	
	setTimeout('clsdiv()', times);
}

function loadiframe(pageurl, contentdivid){
	
	//defaultIframe='<iframe src="about:blank" name="ddajaxtabsiframe" marginwidth="0" marginheight="0" frameborder="1" vspace="0" hspace="0" scrolling="no" style="width:100%; height:80px;"></iframe>'
	//document.getElementById(contentdivid).innerHTML=defaultIframe;
	window.frames["ddajaxtabsiframe"].location.replace(pageurl)
	document.getElementById(contentdivid).innerHTML="";
}

function divcreate(){

	dh=window.screen.availHeight+'px'
	var x = document.createElement('div');
	x.id = 'div1';  
	x.style.display='block';
	x.style.position = 'absolute';  
	x.style.top ='0px';
	x.style.left ='0px';
	x.style.width = '100%'; 
	x.style.height = dh;  
	//x.style.backgroundColor = '#ffffff'; 
	x.style.color = '#fff'; 
	x.style.zIndex = 5000;
	x.style.opacity=.1;
	x.style.filter = 'progid:DXImageTransform.Microsoft.-moz-opacity=0.1';
	x.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=10)';
	window.document.body.appendChild(x);
	
	//prepareIE ('100%', 'hidden');
	getScroll();
	setScroll(0, 0);	
	hideSelects('hidden');
	
}

function clsdiv(){
	var parent = document.getElementById('div1');
	parent.parentNode.removeChild(parent);	
	
	//prepareIE ("auto", "auto");
	setScroll(0,this.yPos);
	hideSelects("visible");
}

function setScroll(x, y){
	window.scrollTo(x, y); 
}

function getScroll(){
	if (self.pageYOffset) {
		this.yPos = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){
		this.yPos = document.documentElement.scrollTop; 
	} else if (document.body) {
		this.yPos = document.body.scrollTop;
	}
}

function prepareIE (height, overflow){
	bod = document.getElementsByTagName('body')[0];
	bod.style.height = height;
	bod.style.overflow = overflow;
	//bod.style.overflow-x= "hidden";
	//bod.style.overflow-y= "scroll";
	
	htm = document.getElementsByTagName('html')[0];
	htm.style.height = height;
	htm.style.overflow = overflow; 
}

function hideSelects(visibility){
	selects = document.getElementsByTagName('select');
	for(i = 0; i < selects.length; i++) {
		selects[i].style.visibility = visibility;
	}
}

function hideChecks(visibility){
	alert(visibility)
	checks = document.getElementsByTagName("input");
	for(j = 0; j < checks.length; j++) {
		checks[j].disabled=visibility;
		//checks[i].style.visibility = visibility;
	}
}


function loadpage(page_request, containerid){

if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))

	document.getElementById(containerid).innerHTML=page_request.responseText
	
}


function ajaxpopup(url, containerid, times, img, evnt){
	x=evnt.clientX
	y=evnt.clientY
	var page_requests = false
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_requests = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE
	try {
		page_requests = new ActiveXObject("Msxml2.XMLHTTP")
	} 
	catch (e){
	try{
		page_requests = new ActiveXObject("Microsoft.XMLHTTP")
	}
	catch (e){}
	}
	}
	else
	return false
	page_requests.onreadystatechange=function(){
	
	popupdivcreate(x,y)
	pr=page_requests;
	co=containerid;
	//document.getElementById(containerid).innerHTML="<center><img src='images/"+img+"' align='middle' /></center>"
	//setTimeout('loadpage(pr, co)', times);	
	loadpage(pr, co)
	}
	page_requests.open('GET', url, true)
	page_requests.send(null)
}

function popupdivcreate(xp,yp){
	cyp=parseInt(yp)+parseInt(5)
	cxp=parseInt(xp)-parseInt(200)
	dh=window.screen.availHeight+'px'
	var x = document.createElement('div');
	x.id = 'dp';  
	x.style.display='block';
	x.style.position = 'absolute';  
	x.style.top =cyp+'px';
	x.style.left =cxp+'px';
	x.style.width = '200px'; 
	x.style.height = 'auto';  
	x.style.float = 'right'; 
	//x.style.paddingTop='100px';
	
	/*x.style.backgroundColor = '#000'; 
	x.style.color = '#fff'; 
	x.style.zIndex = 5000;
	x.style.opacity=.1;
	x.style.filter = 'progid:DXImageTransform.Microsoft.-moz-opacity=0.1';
	x.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=10)';*/
	window.document.body.appendChild(x);
	
	//getScroll();
	setScroll(0, 0);	
	hideSelects('hidden');
	//hideChecks('true');
}

function clsdivp(){
	//hideChecks("false");	
	var parent = document.getElementById('dp');
	parent.parentNode.removeChild(parent);	
		
	setScroll(0,this.yPos);
	hideSelects("visible");
	
}


function loadmsg(containerid){
	document.getElementById(containerid).innerHTML="loading..."
}

function loadobjs(){
	if (!document.getElementById)
	return
	for (i=0; i<arguments.length; i++){
	var file=arguments[i]
	var fileref=""
	if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
	if (file.indexOf(".js")!=-1){ //If object is a js file
		fileref=document.createElement('script')
		fileref.setAttribute("type","text/javascript");
		fileref.setAttribute("src", file);
	}
	else if (file.indexOf(".css")!=-1){ //If object is a css file
		fileref=document.createElement("link")
		fileref.setAttribute("rel", "stylesheet");
		fileref.setAttribute("type", "text/css");
		fileref.setAttribute("href", file);
	}
	}
	if (fileref!=""){
		document.getElementsByTagName("head").item(0).appendChild(fileref)
		loadedobjects+=file+" " //Remember this object as being already added to page
	}
	}
}