jQuery(document).ready(function() {

	jQuery("a[href='/autoversicherung/kfz_rechner.php']").click(function(event) {
		event.preventDefault();
		changehref(this, '200'); 
		}
	)
	jQuery("a[href='/kfz-versicherungsvergleich.php']").click(function(event) {
		event.preventDefault();
		changehref(this, '200'); 
		}
	)

});

function changehref(t,pid) {

		var u = jQuery(t).attr("href");
		bwwindow(u);
		
		self.location.href="http://www.versicherungsvergleich.de/index_werbung.php?productID="+pid;
}	

function bwwindow(url){

	newwin = window.open("http://www.versicherungsvergleich.de" + url,'','width='+ getWindowWidth()+' ,resizable=yes, scrollbars=yes');
	newwin.focus();

}

  
function getWindowWidth() {
	if(screen.availWidth)
	{
		return screen.availWidth;
	}
	else if (window.innerWidth) {
		return window.innerWidth;
	} 
	else if (document.body && document.body.offsetWidth) {
		return document.body.offsetWidth;
	} else {
		return 0;
	}
		
}

function getWindowHeight() {
	if( screen.availHeight)
	{
	  return screen.availHeight;
	}
	else if (window.innerHeight) {
		return window.innerHeight;
	} 
	else if (document.body && document.body.offsetHeight) {
		return document.body.offsetHeight;
	}
	else {
	return 0;
	}
}


function get_url_param( name )
{
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");

	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );

	if ( results == null )
		return "";
	else
		return results[1];
}

function SetCookie(cookieName,cookieValue,nDays) {
 
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}
function ReadCookie(cookieName) {
 var theCookie=" "+document.cookie;
 var ind=theCookie.indexOf(" "+cookieName+"=");
 if (ind==-1) ind=theCookie.indexOf(";"+cookieName+"=");
 if (ind==-1 || cookieName=="") return "";
 var ind1=theCookie.indexOf(";",ind+1);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+2,ind1));
}
