// JavaScript Document

function swap(element,value) {
	var element;
	var value;
	document.getElementById(element).innerHTML=value;
}

function swapval(element,value) {
	var element;
	var value;
	document.getElementById(element).value=value;
}

function hide(element) {
	var element;
	document.getElementById(element).style.display='none';
}

function show(element) {
	var element;
	document.getElementById(element).style.display='block';
}

function ca_expand(aid) {
	var aid;
	document.getElementById(aid).style.height='600px';
}

function articlepop(mid,width,height,scrolling,aid) {
	var mid;
	var aid;
	var source = "/media-fullview.php?mID=" + mid + "&aID=" + aid;
	var width;
	var height;
	var scrolling;
	var articleid;
	window.open(source,"spool","width=" + width + ",height=" + height + ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,left=100,top=100");
}


function ajaxUpdate(elemid, url, options) {
	var params = options.params || "";
	var meth = options.meth || "post";
	var async = options.async;
	if(async == null) {
		async = true;
	}
	var startfunc = options.startfunc || "";
	var endfunc = options.endfunc || "";
	var errorfunc = options.errorfunc || "";
	var noauthfunc = options.noauthfunc || "";
	var req = false;
	if( window.XMLHttpRequest )
		req = new XMLHttpRequest();
	else if( window.ActiveXObject )
		req = new ActiveXObject( "Microsoft.XMLHTTP" );
	else
	{
		alert(  "Your browser cannot perform the requested action. "+
				"Either your security settings are too high or your "+
				"browser is outdated. Try the newest version of "+
				"Internet Explorer or Mozilla Firefox." );
		return false;
	}
	if( startfunc != "" )
		eval( startfunc );
	req.onreadystatechange =
		function() {
			if(req.readyState == 4) {
				if(req.status == 200 ) {
					if(elemid != '')
						document.getElementById(elemid).innerHTML = req.responseText;
					if(endfunc != "")
						eval( endfunc );
					return true;
				}
				else
				{
					if( req.status == 403 && noauthfunc != "" )
						eval( noauthfunc );
					else
					{
						if( endfunc != "" )
							eval( endfunc );
						if( errorfunc != "" )
							eval( errorfunc );
					}
					return false;
				}
			}
		};
	if( meth == "get" )
	{
		req.open( meth, url+( params != "" ? "?"+params : "" ), async );
		req.send(null);
	}
	else
	{
		req.open( meth, url, async );
		req.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
		req.send( params );
	}
}

function thumbview(viewtype,chapterid) {
    var viewtype;
    var chapterid;
	ajaxUpdate("chapter-displayarea", "/content-ajax/ajax-thumbnail-views.php", {
		params:"chapterid=" + chapterid + "&viewtype=" + viewtype + "",
		meth:"post",
		async:true
        }
	);	
}

function wkjump(imageid,articleid) {
    var imageid;
    var articleid;
	ajaxUpdate("workshop-box", "/content-ajax/ajax-workshop-slides.php", {
		params:"imageid=" + imageid + "&articleid=" + articleid + "&chg=2",
		meth:"post",
		async:true,
		startfunc:"show('workshop-loadbar')",
		endfunc:"show('workshop-loadbar'); hide('workshop-loadbar')"		
		
        }
	);	
}

function wkchg(articleid) {
	var imageid = "0";
	var articleid;
	var chg = 1;
	ajaxUpdate("workshop-box", "/content-ajax/ajax-workshop-slides.php", {
		params:"imageid=" + imageid + "&articleid=" + articleid + "&chg=1",
		meth:"post",
		async:true,
		startfunc:"show('workshop-loadbar')",
		endfunc:"show('workshop-loadbar'); hide('workshop-loadbar')"		
		
        }
	);		
}


function popA(artid) {
	var artid;
	show('blackout');
	ajaxUpdate("blackout", "/content-ajax/ajax-display-item.php", {
		params:"artid=" + artid + "",
		meth:"post",
		async:true
        }
	);		
}

function popBlank() {
	hide('blackout');
	swap('blackout','');
}

function lchg(typeid) {
	var typeid;	
	ajaxUpdate("rbox", "/content-ajax/ajax-rich-content-boxes.php", {
		params:"typeid=" + typeid + "",
		meth:"post",
		async:true
        }
	);		
}


