var compatible = (document.getElementById);

function init()
{
    allimages = new Array();
	images = document.getElementsByName('thumbnails');
	stat = 'img';

    for (i=0; i<images.length; i++){

        //get all objects for these functions
       	allimages[i] = document.getElementById(images[i].id);

        // open and see but also closs
        allimages[i].onclick = function () {

	        if (!compatible) {
	        		return false;
	        	} else {
	        		image = this.getAttribute('src');
				newSrc = image.replace('_tmb','');
				if (stat == 'img') {
					document.getElementById('enlarged').src = newSrc;
				} else {
					hateeemel = '<img id="enlarged" class="mag" src="'+  newSrc + '" alt="">';
					document.getElementById('movimg_container').innerHTML = hateeemel;
				}
				stat = 'img';
				return false;
	        }
        }

    }

	movies = document.getElementsByName('movie');

	if (movies.length > 0){
		movie = movies[0];
   		movie.onclick = function () {
			swf = this.getAttribute('src');
			// replace content_img for content_mov
			swf = swf.replace ('img', 'mov');
			// replace img_tmb.jpg for img.jpg
			swf = swf.replace ('_tmb', '');
			// then replace jpg or png for swf
			swf = swf.replace ('jpg', 'swf');
			swf = swf.replace ('png', 'swf');

			title = this.getAttribute('alt');
			title = title.replace(' ', '_');

   			hatheeemel = '<object ';
			hatheeemel += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
			hatheeemel += 'codebase="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW" ';
			hatheeemel += 'width="567" ';
			hatheeemel += 'height="425" ';
			hatheeemel += 'id="'+ title +'" ';
			hatheeemel += 'align="middle"> ';
			hatheeemel += '<param name="allowScriptAccess" value="sameDomain" /> ';
			hatheeemel += '<param name="movie" value="'+ swf + '" /> ';
			hatheeemel += '<param name="quality" value="high" /> ';
			hatheeemel += '<param name="bgcolor" value="#ffffff" /> ';
			hatheeemel += '<embed src="' + swf + '" ';
			hatheeemel += '	quality="high" ';
			hatheeemel += '	bgcolor="#ffffff" ';
			hatheeemel += '	width="567" ';
			hatheeemel += '	height="425"';
			hatheeemel += '	name="'+ title +'" ';
			hatheeemel += '	align="middle" ';
			hatheeemel += '	allowScriptAccess="sameDomain" ';
			hatheeemel += '	type="application/x-shockwave-flash"';
			hatheeemel += '	pluginspage="http://www.macromedia.com/go/getflashplayer" />';
			hatheeemel += '</object>';
			document.getElementById('movimg_container').innerHTML = hatheeemel;
			stat = 'mov';

   		}
   	}
}

window.onload = function () { init(); }
