var agt = navigator.userAgent.toLowerCase();
var is_ie = agt.indexOf("msie") != -1;

try {// gecko
	window.addEventListener("load", C4_init, false);
} catch (e) {}
try {// IE
	window.attachEvent("onload", C4_init);
} catch (e) {}

function C4_init(e) {
	if (!document.getElementsByTagName) return true;

	var domain = document.domain;
	var a = document.getElementsByTagName("a");
	for (var i=0; i<a.length; i++) {
		if (a[i].className == "pasts") {
			a[i].href = "mailto:";
			a[i].href += a[i].childNodes[0].firstChild.nodeValue;
			a[i].href += "%40";
			a[i].href += a[i].childNodes[2].firstChild.nodeValue;
		} else if (a[i].className == "jImgPopup") {
			if (a[i].target == "" || a[i].target == null) {
				a[i].target = "_jimgpopup";// _blank, if each link in new window
			}
			a[i].onclick = C4_popJImg;
		} else if (a[i].hostname != domain) {
			a[i].target = "_blank";
		}
	}
	return true;
}

function C4_popJImg(e) {
	var img = new Image();
	img.hspace = 0;
	img.vspace = 0;

	var win = window.open(this.href, this.target, 'toolbar=no,location=no,directories=no,status=yes,menubar=no,copyhistory=no');

	img.onerror = function() {
		win.close();
		win = window.open(this.href, this.target);
	}

	img.onabort = function() {
		win.close();
	}

	img.onload = function() {
		var w = 0;
		var hpos = 0;
		if (this.width < screen.width - 40) {
			if (is_ie) {
				w = this.width + 50;
			} else {
				w = this.width + 35;
			}
			hpos = Math.round(screen.width / 2 - w / 2);
		} else {
			w = screen.width - 20;
		}

		var h = 0;
		var vpos = 0;
		if (this.height < screen.height - 30) {
			if (is_ie) {
				h = this.height + 85;
			} else {
				h = this.height + 77;
			}
			vpos = Math.round(screen.height / 2 - h / 2);
		} else {
			h = screen.height - 100;
		}

		win.moveTo(hpos, vpos);
		win.moveTo(hpos, vpos);// need to call 2x, firefox &^*&(%*...
		win.resizeTo(w, h);
	}

	img.src = this.href;

	return false;
}
 function img_cc() {
        var tt = document.getElementById('ttt_img').alt;
        var tts = document.getElementById('ttt_img').title;
        document.getElementById('gl_show').src = tt;
        document.getElementById('hhiden2').value = tts;
        var ppnum = document.getElementById('picnum').value;

        if ( ppnum == 1 ) {
          document.getElementById('m_slide').style.display = 'none';
        }
        //if ( ppnum <= 4 ) {
        //  document.getElementById('l_ar').style.display = 'none';
        //  document.getElementById('r_ar').style.display = 'none';
        //  document.getElementById('thumb_hold').style.width = '300px';
        //}
     }
     function galch(url) {
        document.getElementById('gl_show').src = url
     }
        var n = 0;
        var t;
     function mo_right() {
        var w_slide = document.getElementById('thumb_hold').offsetWidth;
        var w_imgs = document.getElementById('thumbs_t').offsetWidth;
        var m_mar = w_imgs - w_slide;
        var d2 = document.getElementById('thumbs');
        var c_mar = d2.style.marginLeft;
        if (n >= 1) {
             n = n-88;
             document.getElementById('thumbs').style.marginLeft = "-" + n + "px" ;
             //t = setTimeout('mo_left()', 15);
        }
     }
     function mo_left() {
        var w_slide = document.getElementById('thumb_hold').offsetWidth;
        var w_imgs = document.getElementById('thumbs_t').offsetWidth;
        var m_mar = w_imgs - w_slide;
        var d2 = document.getElementById('thumbs');
        var c_mar = d2.style.marginLeft;
        if (n < m_mar) {
             n = n+88;
             document.getElementById('thumbs').style.marginLeft = "-" + n + "px" ;
             //t = setTimeout('mo_right()', 15);
        }
     }
     function hhideset(ipp,iim) {
        if(document.getElementById('hhiden1') != null)
            document.getElementById('hhiden1').value = ipp;
        if(document.getElementById('hhiden2') != null)
            document.getElementById('hhiden2').value = iim;
     }
     function gl_show_big() {
        var imglocp = document.getElementById('hhiden1').value
        var imgloci = document.getElementById('hhiden2').value
        var imgloc = imglocp + '/l/' + imgloci
        //var imgloc = document.getElementById('gl_show').src;
        //var imgh = document.getElementById('gl_show').offsetHeight;
        //var imgw = document.getElementById('gl_show').offsetWidth;
        //var imghr = imgh + 40;
        //var imgwr = imgw + 40; width=' + imgwr + ',height=' + imghr + ''
        window.open('' + imgloc + '', 'popup', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=850,height=650');
     }


     function gl_show_big2() {
        var imglocp = document.getElementById('hhiden1').value
        var imgloci = document.getElementById('hhiden2').value
        var imgloc = imglocp + '/l/' + imgloci
        //var imgloc = document.getElementById('gl_show').src;
        //var imgh = document.getElementById('gl_show').offsetHeight;
        //var imgw = document.getElementById('gl_show').offsetWidth;
        //var imghr = imgh + 40;
        //var imgwr = imgw + 40; width=' + imgwr + ',height=' + imghr + ''
        window.open('popup.html', 'popup', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=870,height=650');
     }


function openw(url, w, h) {
win = window.open(''+url+'', 'popup', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+w+',height='+h+'');
}
