global_site_path = "http://www.affiliate-marketing.de/rating/";

function open_window(iframe_src) {

	var IE6=navigator.appVersion.indexOf("MSIE 6")!=-1;
	var IE7=navigator.appVersion.indexOf("MSIE 7")!=-1;

	// build "link" tag for css
	var css_link = document.createElement("link");
	css_link.id = "css_link_aff_mark";
	css_link.rel = "stylesheet";
	css_link.type = "text/css";
	css_link.href = global_site_path + "css/style.css";

	//------------------------------------------

	var css_link_created = document.getElementById('css_link_aff_mark');
	if (!css_link_created)
	{
		document.getElementsByTagName('head')[0].appendChild(css_link);
	}

	//build a form
	var center_div = document.createElement("div");
	center_div.id = 'center_widget_aff_mark';
	center_div.style.display = 'none';

	var link_close = document.createElement("a");
	link_close.className = "link_close_aff_mark";
	link_close.href = '#';
	link_close.innerHTML = '[Fenster schliessen]';
	link_close.onclick=function() {
		hide_form();
		return false;
	}

	var img = document.createElement("img");
	img.src = global_site_path + "media/widget/logo.jpg";
	img.alt = "Logo";

	var br = document.createElement("br");


	var iframe = document.createElement("iframe");
	iframe.src = "http://www.affiliate-marketing.de/rate." + iframe_src;
	//iframe.src = global_site_path + "test_frame.html";
	//iframe.src = "http://hotel/test_frame.html";
	iframe.frameBorder = '0';
	iframe.id = 'aff_mark_frame';
	iframe.align = 'center';
	iframe.scrolling = 'auto';

	center_div.appendChild(link_close);
	center_div.appendChild(img);
	center_div.appendChild(br);
	center_div.appendChild(iframe);

	//document.getElementById('affiliate_marketing_main_widget_container').parentNode.appendChild(center_div);
	window.document.body.appendChild(center_div);
	//------------------------------

	//build a block div
	var block_div = document.createElement("div");
	block_div.id = 'block_content_aff_mark';
	block_div.className = '';
	block_div.style.height = '';

	//check if block_div isset
	var block_div_created = document.getElementById('block_content_aff_mark');
	if (!block_div_created)
	{
		window.document.body.appendChild(block_div);
	}

	/*if ((!IE6) && (!IE7)) {
		iframe.onload = function () {
			//var ifr_height = document.getElementById("aff_mark_frame").contentWindow.document.body.scrollHeight;
			//document.getElementById("aff_mark_frame").style.height = ifr_height + "px";
		}
	} else {
		alert('IE');
	}*/

	//------------------------------
	show_form();
	return false;
}

function show_form() {

	var IE6=navigator.appVersion.indexOf("MSIE 6")!=-1;
	var IE7=navigator.appVersion.indexOf("MSIE 7")!=-1;

	//block access to content of page
	document.getElementById('block_content_aff_mark').className = 'block_content_aff_mark';
	document.getElementById('center_widget_aff_mark').style.display = 'block';
	scroll(0,0);
}

function hide_form() {
	//unblock access to content of page
	document.getElementById('block_content_aff_mark').className = '';
	//document.getElementById('center_widget_aff_mark').style.display = 'none';
	document.getElementById('center_widget_aff_mark').parentNode.removeChild(document.getElementById('center_widget_aff_mark'));
}

//we call this function from outside - in the body of frame;
function set_frame_height(frame_height) {
	//alert(frame_height);
	//document.getElementById("aff_mark_frame").style.height = frame_height + "px";
}