jQuery(window).load(function () {

	serverRoot = window.location.host;
	documentRoot = document.location.href;

	// check if user has seen page popup on start site
	if (jQuery.cookie('baseSite') == null) {
			// call popup-animation after timeout if cookie has not been set
			setTimeout(showPopUp, 1000);

			// set cookie of baseSite
			jQuery.cookie('baseSite', 'true');
		}

	// set cookie if on produkt site zahnzusatz and popup has not been seen by user
	if (documentRoot.indexOf("zahnzusatzversicherung") >= 0) {
		if (jQuery.cookie('zahnzusatz') == null) {
					// call popup-animation after timeout if cookie has not been set
					setTimeout(showPopUp, 1000);

					// set cookie
					jQuery.cookie('zahnzusatz', 'true');
				}
	}


	// get document height
	documentHeight = jQuery(document).height();

	boxWidth = jQuery('#white_content .content').width();
	minWidth = '400';

	// check dimensions of popup
	if (boxWidth < minWidth) {
		boxWidth = minWidth;
	}

	// set width
	jQuery('#white_content').width(boxWidth);

	function showPopUp() {
		// show semitransparent overlay
		jQuery('#black_overlay').animate({
			height:documentHeight
		}, 200, function () {
			jQuery('#black_overlay').slideDown(200);
		});

		// show popup content
		jQuery('#white_content').slideDown(200);


		// general popup close function -------  */
		jQuery('.closeicon, #black_overlay').click(function () {
			// hide popup
			jQuery('#white_content').slideUp(300);
			jQuery('#black_overlay').slideUp(400);
		});
	}

	// call to acton button
	 jQuery('.container-content').click(function(e) {
		e.preventDefault();
		linkurl = jQuery('.button input', this).attr('data');
		window.location.href = linkurl;
	});

})
