/* please try to not use, use /js/webmaster.js instead, thank you */

var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (!document.getElementById) {
	if (document.all)
		document.getElementById = function() {
			if(typeof document.all[arguments[0]]!="undefined")
				return document.all[arguments[0]]
			else
				return null
		} // end function
	else if (document.layers)
		document.getElementById = function() {
			if (typeof document[arguments[0]]!="undefined")
				return document[arguments[0]]
			else
				return null
			} // end function
} // end if

function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
} // end function

function changemenu(thediv) {
	var menutag = document.getElementById(thediv);
	if (hasClass(menutag,'menuon')) {
		addClass(menutag,'menuoff');
		removeClass(menutag,'menuon');
	} else {
		addClass(menutag,'menuon');
		removeClass(menutag,'menuoff');		
	} // end if
} // end function

function setmenu(thediv) {
	var menutag = document.getElementById(thediv);
	menutag.setAttribute('class', 'menuoff');	
	if (checkIt('msie')) menutag.innerHTML = '<div class="menuoff">'+menutag.innerHTML+'</div>';
} // end function

function setminmaxsize(thediv,minw,maxw) {
	if (checkIt('msie')) {		
		var divtag = document.getElementById(thediv);
		if(maxw > 0 && divtag.offsetWidth > maxw) divtag.style.width=maxw+'px';
		if(minw > 0 && divtag.offsetWidth < minw) divtag.style.width=minw+'px';
	} // end if
} // end function

function setminmaxhsize(thediv,minw,maxw) {
	if (checkIt('msie')) {		
		var divtag = document.getElementById(thediv);
		if(maxw > 0 && divtag.offsetHeight > maxw) divtag.style.height=maxw+'px';
		if(minw > 0 && divtag.offsetHeight < minw) divtag.style.height=minw+'px';
	} // end if
} // end function

function blogcomment(thepage) {
	var winl = 50;
	var wint = 50;
	ablogcomment=window.open(thepage, "blogcommentPopup", "toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=400,height=450");
	ablogcomment.focus();	
} // end function

function guestcomment(thepage) {
	var winl = 50;
	var wint = 50;
	aguestcomment=window.open(thepage, "guestcommentPopup", "toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=520,height=460");
	aguestcomment.focus();	
} // end function

function maillist(thepage) {
	var winl = 50;
	var wint = 50;
	amaillist=window.open(thepage, "mailistPopup", "toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=445,height=260");
	amaillist.focus();	
} // end function

function openflyer(thepage) {
	var winl = 50;
	var wint = 50;
	aflyer=window.open(thepage, "openflyer", "toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=400,height=450");
	aflyer.focus();	
} // end function

function resizeflyer(thediv) {
	winHeight=document.getElementById(thediv).offsetHeight+50; 
	winWidth=document.getElementById(thediv).offsetWidth+30;
	if (screen.width-110 < winWidth) winWidth = screen.width-110;
	if (screen.height-110 < winHeight) winHeight = screen.height-110; 
	window.resizeTo(winWidth,winHeight);
} // end function

function imageswap(image1,image2,theid) {
	theimage = document.getElementById(theid);
	if (theimage.src.indexOf(image1) > -1) theimage.src = image2;
	else theimage.src = image1;
	return false;
} // end function

arcnmap='';
function rcnmap(page) {
	if (arcnmap && !arcnmap.closed) arcnmap.close();	
	w = 444;
	h = screen.height-110;
	if (h > 565) h = 565; 
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - 115 - h) / 2;
	
	arcnmap=window.open(page, "rbmap", "width="+w+",height="+h+",top="+wint+",left="+winl+',status=no,scrollbars=yes,resize=yes,menubar=no');
	arcnmap.focus();
} // end function editComment

function hasClass(ele,cls) {
	return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
function addClass(ele,cls) {
	if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}
function removeClass(ele,cls) {
	if (hasClass(ele,cls)) {
		var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
		ele.className=ele.className.replace(reg,' ');
	}
}