// JavaScript Document

var cookieFound;


function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
	    { 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
				return unescape(document.cookie.substring(c_start,c_end));
	   } 
  	}
	return "";
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function setOpacity( value ) {
	document.getElementById("styled_popup").style.opacity = value / 10;
	document.getElementById("styled_popup").style.filter = 'alpha(opacity=' + value * 10 + ')';
}

function fadeInMyPopup() {
	for( var i = 0 ; i <= 100 ; i++ )
		setTimeout( 'setOpacity(' + (i / 10) + ')' , 8 * i );
}

function fadeOutMyPopup() {
	for( var i = 0 ; i <= 100 ; i++ ) {
		setTimeout( 'setOpacity(' + (10 - i / 10) + ')' , 8 * i );
	}

	setTimeout('closeMyPopup()', 800 );
}

function closeMyPopup() {
	document.getElementById("styled_popup").style.display = "none"
}

function fireMyPopup() {
	setOpacity( 0 );
	document.getElementById("styled_popup").style.display = "block";
	fadeInMyPopup();
}

/* Modified to support Opera */
function bookmarksite(){
	var title = document.title;
	var url = location.href;
	
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

function showWarning(warning_text){
document.writeln('<html><head></head><body>');
document.writeln('<div id="styled_popup" name="styled_popup" style="width: 400px; height: 350px; display:none; position: absolute; top: 350px; left: 350px; zoom: 1; background: #fff; z-index:999999999">');
document.writeln('<table width="380" cellpadding="5" cellspacing="5" border="0">');
document.writeln('<tr><td><img src="http://clickwatcher.co.uk/cw/images/cw_warning_head.jpg"></td>');
document.writeln('<td align=right><a href="javascript:fadeOutMyPopup();"><img height="23" width="24" src="http://clickwatcher.co.uk/cw/images/x11_close.gif" border="0"></a></td>');
document.writeln('</tr><tr><td colspan="2" style="background: url(\"http://clickwatcher.co.uk/cw/images/x11_body.gif\") no-repeat top left; width: 380px; height: 277px;">');
document.writeln(unescape(warning_text) + '<a href=\"javascript:bookmarksite()\"><font color=\"#0000FF\" face=\"Arial\">Bookmark Page !</font></a>');
document.writeln('</td></tr></table></div><body onload=\"fireMyPopup()\"></body></body></html>');
}


function LPMSaveInfo(lpid, user_id, debug)
{
	var currUrl = escape(document.location);
	var referrer = escape(document.referrer);
	cookieValue_lpid=getCookie('lpid');
	
	if (cookieValue_lpid!=null && cookieValue_lpid!="")
	{
		cookieFound=1;
		setCookie('lpid',lpid,365);
	}
	else
	{
		cookieFound=0;
 		setCookie('lpid',lpid,365);
	}
	
//	debug=1;
	
	if(debug==0)
		document.writeln('<iframe id="frm_lpm" height="0" width="0" src="http://clickwatcher.co.uk/cw/track.php?lpid=' + lpid + '&user_id=' + user_id + '&currurl='+currUrl+'&referrer='+referrer+'&debug=0"></iframe>');
		//document.writeln('<iframe id="frm_lpm" height="0" width="0" src="http://localhost/landingpage/track.php?lpid=' + lpid + '&user_id=' + user_id + '&currurl='+currUrl+'&referrer='+referrer+'&debug=0"></iframe>');
	else
		document.writeln('<iframe id="frm_lpm" height="500" width="500" src="http://clickwatcher.co.uk/cw/track.php?lpid=' + lpid + '&user_id=' + user_id + '&currurl='+currUrl+'&referrer='+referrer+'&debug=1"></iframe>');
		//document.writeln('<iframe id="frm_lpm" height="500" width="500" src="http://localhost/landingpage/track.php?lpid=' + lpid + '&user_id=' + user_id + '&currurl='+currUrl+'&referrer='+referrer+'&debug=1"></iframe>');
	
	document.writeln('<script language="javascript" src="http://clickwatcher.co.uk/cw/sw.php?lpid=' + lpid + '&user_id=' + user_id + '&currurl='+currUrl+'&referrer='+referrer+'&debug=1"></script>');
}



