var hover_array = new Array();
var moving_div_id = '';
var tempX = 0;
var tempY = 0;
var first_time = true;
var timerid = null;

function getElement(id) {
	if (document.getElementById) {
		return document.getElementById(id);
	} else if (document.all) {
		return document.all[id];
	} else if (document.layers) {
 		return document.layers[id];
	}
}

function start_move_div(id) {
	var arr = hover_array[id];
	if (arr[1] == 1 || arr[1] == 2) {
		arr[1] = 0;
		moving_div_id = id;
		tp = arr[0].style.top.split("p");
		arr[2] = tempY - tp[0];
		tp = arr[0].style.left.split("p");
		arr[3] = tempX - tp[0];
		timerid = setTimeout('moving_div_id="";arr[1] = 1;',1000);
	} else {
		clearTimeout(timerid);
		timerid = null;
		arr[1] = 1;
		moving_div_id = '';
	}
}



function move_div(e) {
	if (document.all) {
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
	} else {
		tempX = e.pageX;
		tempY = e.pageY;
	}

offset = 0;
		if (window.pageYOffset) {
			offset = window.pageYOffset;
		} else {
			offset = 0;
		}

		if ((tempY - offset) < 20 && first_time && ( 10 + tempX - document.body.clientWidth) < 0) {
			makePop_special(10,10,'exit_pop','<form method="post" action="" name="the_form" id="the_form"><table align="center" width="100%" height="100%" border="0" class="fourborders"><tr height="2%"><td colspan="2"><center><span style="color: #C03C3A; font-size: 24px; font-weight: bold; line-height: 25px;">WAIT!!!&nbsp;</span> <span style="line-height: 25px; font-size: 24px; font-weight: bold;">We Need Your Advice.</span></center><br /></td></tr><tr><td width="5%" valign="top"><img src="/images/wait.png" alt="" width="114" height="155" /></td><td><br />What&rsquo;s the <strong>Single Biggest Reason</strong> you are leaving us without giving Boxer Dog Secrets a fair try?<br /><br />We appreciate your feedback to help make our services better in the future.<br /><br />Please type your answers in the comments box below and then click the &quot;Here&lsquo;s My Feedback &gt;&gt;&quot; button.<br /><br /></td></tr><tr><td valign="top"><table border="0"><tr><td><center><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0" width=1 height=1 align="absmiddle"><param name=movie value="/mp3ss5f.swf" /><param name=quality value=best /><param name=wmode value=transparent /><param name=bgcolor value=#FFFFFF /><param name=loop value=true /><embed src="/mp3ss5f.swf" quality=best wmode=transparent bgcolor=#FFFFFF loop=true width=1 height=1 type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" align="absmiddle"></embed></object><object id="myaudiocon" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0" width=70 height=30 align="absmiddle"><param name=movie value="/mp3ss55d.swf"><param name=quality value=best><param name=wmode value=transparent><param name=bgcolor value=#FFFFFF><param name=loop value=true><embed src="/mp3ss55d.swf" quality=best wmode=transparent bgcolor=#FFFFFF loop=true width=70 height=30 type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" align="absmiddle"></embed></object></center></td></tr><tr><td><br />Click on the triangle to listen to the rest of this important message</td></tr></table></td><td valign="top"><table cellspacing="0" cellpadding="1" border="0" align="center" width="100%"><tr><td class="smalltext" colspan="2" style="font-size: 14px;">MY MAIN REASON FOR LEAVING IS ...</td></tr><tr><td colspan="2"><table border="0" width="340px"><tr><td align="right" colspan="2"><textarea style="width: 340px; height: 50px; font-size:12px;" id="comment" name="comment"></textarea></td></tr><tr><td colspan="2">If you would like us to contact you about your comments, please fill in the detail below.</td></tr><tr><td width="32%" class="smalltext">Name</td><td width="68%"><input type="text" style="width: 150px;" size="10" value="<optional>" name="name" id="name" onFocus="focus_text(this);" onBlur="unfocus_text(this);" /></td></tr><tr><td class="smalltext">Email</td><td><input type="text" style="width: 150px;" size="10" value="<optional>" name="email" id="email" onFocus="focus_text(this);" onBlur="unfocus_text(this);" /></td></tr><tr><td class="smalltext">Security Image</td><td><img src="/captcha.php" width="120px" height="40px" alt="security code" /></td></tr><tr><td class="smalltext">Enter Code:</td><td><input type="text" name="code" maxlength="6" style="width:150px;" /></td></tr></table></td></tr></table></td></tr><tr id="pp"><td><font size="-3"><center>Our <a target="_blank" href="privacypolicy.php">Privacy Policy</a><br /> Protects You</center></font></td><td><center><input type="button" onClick="this.form.submit();" value="Here&lsquo;s My Feedback &gt;&gt;" class="navLink" /></center><input type="hidden" value="true" name="exit_poper" id="exit_poper" /></form></td></tr><tr><td colspan="2"></td></tr><tr><td colspan="2"><center><a href="javascript: ;" onclick="killoff_special(\'exit_pop\');" class="x">Close this window and return to the sales product page.</a></center></td></tr><tr><td>&nbsp;</td></tr></table>',490,490);

first_time = false;
}
	if (moving_div_id != '') {
		if (getElement(moving_div_id)) {
			arr = hover_array[moving_div_id];
			arr[0].style.top = (tempY - arr[2]) + 'px';
			arr[0].style.left = (tempX - arr[3]) + 'px';
		} else {
			moving_div_id = '';
		}
	}
}

function makePop_special(topPos,leftPos,id,content,width,height) {
	if (!nopop) {
		if (!getElement(id + '_blanker')) {
			var div = document.createElement('div');
			var div_start = "<div name=\""+id+"_blanker\" id=\""+id+"_blanker\" style=\"filter:alpha(opacity=70);-moz-opacity:.7;opacity:.7; background-color: black; z-index: 2; padding: 0px; border: 0px; position: absolute; top:0px; left: 0px; width: 100%; height: " + document.body.offsetHeight + "px\">";
			div.innerHTML = div_start + "</div>";
			document.body.appendChild(div.firstChild);
			hover_array[id + '_blanker'] = new Array(getElement(id),1,0,0);
		}

		if (!getElement(id)) {
			offset = 0;
			if (window.pageYOffset) {
				offset = window.pageYOffset;
			} else {
				offset = document.body.scrollTop;
			}
			if (offset == 0 && document.documentElement.scrollTop > 0) {
				offset = document.documentElement.scrollTop;
			}
			var topP = 10 + offset; //(screen.availHeight / 3) + (screen.height - screen.availHeight) - (height / 2) + 
			var leftP = (screen.availWidth / 2) - (width / 2);
			var div = document.createElement('div');
			var div_start = "<div id=\""+id+"\" style=\"background-color: white; z-index: 3; padding: 0px; border: 0px; position: absolute; top: " + topP + "px; left: " + leftP + "px;\">";
			div_start += '<table style="border: 1px solid;"><tr><td style="background: #1c71ff; " align="right" id="'+id+'_inner" name="'+id+'_inner" height="22px"><a href="javascript: ;" onclick=" killoff_special(\''+id+'\',true);" class="x"><img src="/images/x.png" border="0" width="22px" height="22px" /></a></td></tr><tr><td><div style="overflow: auto; width: ' + width + 'px; id="' + id + '_text" name="' + id + '_text">';
			div.innerHTML = div_start + content +  "</div></td></tr></table></div>";
			document.body.appendChild(div.firstChild);

			title_id = id+'_inner';
			title = getElement(title_id);
			title.onmousedown = function() {start_move_div(id);};
			title.onmouseup = function() {start_move_div(id);};

			hover_array[id] = new Array(getElement(id),1,0,0);
		}
	}
}

function makePop(topPos,leftPos,id,content,width,height) {
	var div = document.createElement('div');
	var div_start = "<div id=\""+id+"\" style=\"background-color: white; z-index: 2; padding: 0px; border: 2px solid blank; position: absolute; top: " + topPos + "px; left: " + leftPos + "px;\">";
	div_start += '<table style="border: 1px solid;"><tr><td style="background: #1c71ff; " align="right" id="'+id+'_inner" name="'+id+'_inner" height="22px"><a href="javascript: ;" onclick="killoff(\''+id+'\',true);" class="x"><img src="/images/x.png" border="0" width="22px" height="22px" /></a></td></tr><tr><td><div style="overflow: auto; width: ' + width + 'px; height: ' + height + 'px;" id="' + id + '_text" name="' + id + '_text">';
	div.innerHTML = div_start + content + "</div></td></tr></table></div>";
	if (!getElement(id)) {
		document.body.appendChild(div.firstChild);

		title_id = id+'_inner';
		title = getElement(title_id);
		title.onmousedown = function() {start_move_div(id);};
		title.onmouseup = function() {start_move_div(id);};

		hover_array[id] = new Array(getElement(id),1,0,0);
	}
}

function isactive(id) {
	var tmp = hover_array[id];
	tmp[1] = 2;
}

function preview(id,content,topPos,leftPos,width,height) {
	var width = (width == null) ? 660 : width ;
	var height = (height == null) ? 400 : height ;
	var topPos = (topPos == null) ? (document.body.clientHeight / 2) - (height / 2) : topPos ;
	var leftPos = (leftPos == null) ? (document.body.clientWidth / 2) - (width / 2) : leftPos ;

	makePop(topPos,leftPos,id,content,width,height);
}


function killoff_special(id) {
        
        document.getElementById(id).innerHTML = '';
	document.body.removeChild(getElement(id));
	hover_array[id] = null;
	if (moving_div_id == id) {
		moving_div_id = '';
	}
	document.body.removeChild(getElement(id+'_blanker'));
}

function killoff(id,other) {
	var tmp = hover_array[id];
	if (tmp[1] == 0 || other == true) {
		document.body.removeChild(getElement(id));
		title_id = id+'_inner';
		title = getElement(title_id);
		if (title) {
			title.onmousedown = function() {};
			title.onmouseup = function() {};
		}
		hover_array[id] = null;
		if (moving_div_id == id) {
			moving_div_id = '';
		}
	}
}


function allow_popups() {
document.onmousemove = move_div;
}
setTimeout('activate_popups()',200);

function activate_popups() {
	}

function focus_text(elm) {
	if (elm.value == '<optional>') {
		elm.value = '';
	}
}

function unfocus_text(elm) {
	if (elm.value == '') {
		elm.value = '<optional>';
	}
}

var nopop = false;

function toggle_exitpop(num,max) {
	var pp = 3;
	for (i=1;i <= max; i++) {
		if (getElement('reason' + i)) {
			if (i == num) {
				getElement('reason' + num).checked = true;
				getElement('reason' + num + '_inner').style.display = '';
			} else {
				getElement('reason' + i + '_inner').style.display = 'none';
			}
		}
	}
	if (pp == num) {
		getElement('pp').style.display = '';
	} else {
		getElement('pp').style.display = 'none';
	}
}