var path = '/static/i/';

function styleimages_get() {
		var images = document.getElementsByTagName( 'img' );
		for( var i =0;i<images.length;i++ ) {
			var img = images[i];
			if( img.className == 'pl-img-style-unten' ) {
				styleimage_replace1( img );
			}			
			if( img.className == 'pl-img-style-ecken' ) {
				styleimage_replace2( img );
			}
			if( img.className == 'pl-img-style-oval' ) {
				styleimage_replace3( img );
			}
			if (img.className == 'imageFrame' || img.className == 'imageFrameRight' || img.className == 'imageFrameLeft') {
				styleimage_replace4( img, img.className );
			}		
		}
}

function styleimage_replace2( img ) {
	var pl_outter = document.createElement( 'div' );
	link_check(img, pl_outter);
	pl_outter.className = 'pl-img-style2';
	pl_outter.style.height = img.height+5;
	pl_outter.style.width = img.width;
	
	var pl_left = document.createElement( 'div' );
	pl_left.className = 'pl-img-style2-left';
	pl_left.style.height = img.height;

	var pl_right = document.createElement( 'div' );
	pl_right.className = 'pl-img-style2-right';
	pl_right.style.height = img.height;

	var pl_top = document.createElement( 'div' );
	pl_top.className = 'pl-img-style2-top';

	var pl_bottom = document.createElement( 'div' );
	pl_bottom.className = 'pl-img-style2-bottom';

	var pl_tl = document.createElement( 'img' );
	pl_tl.className = 'pl-img-style2-tl';
	pl_tl.src = path + 'pl-img-style2-tl.gif';
	
	var pl_tr = document.createElement( 'img' );
	pl_tr.className = 'pl-img-style2-tr';
	pl_tr.src = path + 'pl-img-style2-tr.gif';	

	var pl_bl = document.createElement( 'img' );
	pl_bl.className = 'pl-img-style2-bl';
	pl_bl.src = path + 'pl-img-style2-bl.gif';
		
	var pl_br = document.createElement( 'img' );
	pl_br.className = 'pl-img-style2-br';
	pl_br.src = path + 'pl-img-style2-br.gif';
	
	img.parentNode.insertBefore(pl_outter,img.nextSibling);	
	pl_outter.appendChild( img );
	pl_outter.appendChild( pl_left );
	pl_outter.appendChild( pl_right );
	pl_outter.appendChild( pl_top );
	pl_outter.appendChild( pl_bottom );
	pl_outter.appendChild( pl_tl );
	pl_outter.appendChild( pl_tr );
	pl_outter.appendChild( pl_bl );
	pl_outter.appendChild( pl_br );
	
}



function styleimage_replace4( img, className ) {
	var pl_outter = document.createElement( 'div' );
	link_check(img, pl_outter);
	pl_outter.className = className;
	pl_outter.style.width = img.width;
	pl_outter.style.height = img.height;

	img.setAttribute("width", img.width);
	img.setAttribute("height", img.height);
	//img.removeAttribute('class');
	img.className = "";

	img.parentNode.insertBefore(pl_outter,img.nextSibling);	
	pl_outter.appendChild( img );	
}

function styleimage_replace1( img ) {
	var pl_outter = document.createElement( 'div' );
	link_check(img, pl_outter);
	pl_outter.className = 'pl-img-style1';
	if (navigator.userAgent.toLowerCase().indexOf('msie') !=-1) {
		pl_outter.style.height = img.height+33;
	}
	img.parentNode.insertBefore(pl_outter,img.nextSibling);
	pl_outter.appendChild( img );	
}

function styleimage_replace3( img ) {
	var pl_outter = document.createElement( 'div' );
	link_check(img, pl_outter);
	pl_outter.className = 'pl-img-style3';
	img.parentNode.insertBefore(pl_outter,img.nextSibling);

	var pl_overlay = document.createElement( 'img' );
	pl_overlay.className = 'pl-img-style3-overlay';
	if (navigator.userAgent.toLowerCase().indexOf('msie') ==-1) {
		pl_overlay.src = path + 'pl-img-style3.png';
	} else {
		pl_overlay.src = path + '1px.gif';
	}
	pl_overlay.style.width = img.width;
	pl_overlay.style.height = img.height;
		
	pl_outter.appendChild( img );
	pl_outter.appendChild( pl_overlay );			
}

function link_check( img, divbox ) {
	if ( typeof img.parentNode.href == 'undefined' ) return;
	img.parentNode.className = 'no_icon';
	if ( navigator.userAgent.toLowerCase( ).indexOf( 'msie' ) !=-1 ) {
		divbox.oldlink = img.parentNode;
		divbox.onclick = link_click;
		divbox.style.cursor = 'hand';		
	}
}

function link_click() {
	this.oldlink.click();
}