var vwidth = 1024;
var vheight = 821;
var Nav4 = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))
var dialogWin = new Object( );

function winPop(url)
{
	if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed))
	{
		// Initialize properties of the modal dialog object.
		dialogWin.url = url;
		dialogWin.width = vwidth;
		dialogWin.height = vheight;
		dialogWin.returnedValue = "";
		var attr = '';
		// Keep name unique.
		dialogWin.name = (new Date( )).getSeconds( ).toString( );
		// Assemble window attributes and try to center the dialog.
		if (window.screenX)
		{   // Navigator 4+
			// Center on the main window.
			dialogWin.left = window.screenX + ((window.outerWidth - dialogWin.width) / 2);
			dialogWin.top = window.screenY + ((window.outerHeight - dialogWin.height) / 2);
			attr = "screenX=" + dialogWin.left + ",screenY=" + dialogWin.top + ",resizable=no,width=" + dialogWin.width + ",height=" + dialogWin.height;
		}
		else if (window.screenLeft)
		{    // IE 5+/Windows 
			// Center (more or less) on the IE main window.
			// Start by estimating window size, 
			// taking IE6+ CSS compatibility mode into account
			var CSSCompat = (document.compatMode && document.compatMode != "BackCompat");
			window.outerWidth = (CSSCompat) ? document.body.parentElement.clientWidth : document.body.clientWidth;
			window.outerHeight = (CSSCompat) ? document.body.parentElement.clientHeight :  document.body.clientHeight;
			window.outerHeight -= 80;
			dialogWin.left = parseInt(window.screenLeft + ((window.outerWidth - dialogWin.width) / 2));
			dialogWin.top = parseInt(window.screenTop + ((window.outerHeight - dialogWin.height) / 2));
			attr = "left=" + dialogWin.left + ",top=" + dialogWin.top + ",resizable=no,width=" + dialogWin.width + ",height=" + dialogWin.height;
		}
		else
		{   // all the rest
			// The best we can do is center in screen.
			dialogWin.left = (screen.width - dialogWin.width) / 2;
			dialogWin.top = (screen.height - dialogWin.height) / 2;
			attr = "left=" + dialogWin.left + ",top=" + dialogWin.top + ",resizable=no,width=" + dialogWin.width + ",height=" + dialogWin.height;
		}
		// Generate the dialog and make sure it has focus.
		dialogWin.win=window.open(dialogWin.url, dialogWin.name, attr);
		dialogWin.win.focus( );
		
	}
	else
	{
		dialogWin.win.focus( );
	}
}

function getInsideWindowWidth()
{
	var intW = 0;
	if(self.innerWidth)
	{
		intW = window.innerWidth;
	} 
	else
	{
		if(document.documentElement && document.documentElement.clientWidth)
		{
			intW = document.documentElement.clientWidth;
		}
		else
		{
			if(document.body && document.body.clientWidth)
			{
				intW = document.body.clientWidth;
			}
		}
	}
	return intW;
}
function getInsideWindowHeight()
{
	var intH = 0;
	if(self.innerHeight)
	{
		intH = window.innerHeight;
	} 
	else
	{
		if(document.documentElement && document.documentElement.clientHeight)
		{
			intH = document.documentElement.clientHeight;
		}
		else
		{
			if(document.body && document.body.clientHeight)
			{
				intH = document.body.clientHeight;
			}
		}
	}
	return intH;
}
function dropPanel (idx, left, width)
{
	var legends = new Array('HOME', 'SOFTWARE', 'FREE TRIAL', 'BUY NOW');
	var targets = new Array('index.html', 'software.html', 'free_trial.html', 'buy_now.html');
	var startPos = 15+(getInsideWindowWidth()-627)/2;
	var d = $('dropPanel');
	var dp = d.style;
	dp.width = width+'px';
	dp.left = (left+15+(getInsideWindowWidth()-627)/2)+'px';
	dp.top='0';
	d.innerHTML = legends[idx];
	d.onclick = function() { location.href=targets[idx]; }
}
function hideDropPanel()
{
	var dp = $('dropPanel').style;
	dp.left='-99999px';
	dp.top='-99999px';
}
var bnw = 300;
var bnh = 100;
var bnb = 10;
function createBuyNowMessage()
{
	var bn = document.createElement('div');
	bn.setAttribute('id', 'buy_now_message');
	with(bn.style)
	{
		position = 'absolute';
		left = '-99999px';
		top = '-99999px';
		width = bnw+'px';
		height = bnh+'px';
		borderWidth = bnb+'px';
		borderStyle = 'solid';
		borderColor = '#555555';
		backgroundColor = '#fdfede';
		zIndex = 100;
	}
	document.body.appendChild(bn);
	bn.innerHTML = '<div style="width: ' + (bnw - 30) + 'px; margin: 0 auto; text-align: center;"><h2 style="margin: 20px 0 20px 0">You will be asked to register/login<\/h2><\/div>';
}
function buyNowToggle(id)
{
	if($(id))
	{
		var lp = $(id).offsetLeft;
		var bn = $(id).style;
		var ww = getInsideWindowWidth();
		var wh = getInsideWindowHeight();
		if(lp < 0)
		{
			bn.left = ((ww - bnw)/2) + 'px';
			bn.top = ((wh - bnh)/2) + 'px';
		}
		else
		{
			bn.left = '-99999px';
			bn.top = '-99999px';
		}
	}
}
function mouseHandler(evt)
{
	var pic;
	var picAlt = '';
	var picY = 0;
	var picX = 0;
	if(window.event && window.event.srcElement.tagName=='INPUT') { pic = window.event.srcElement; picAlt = pic.alt; }
	else if(evt && evt.target && evt.target.tagName=='INPUT') { pic = evt.target; picAlt = pic.alt; }
	if (picAlt === 'Buy Now')
	{
		buyNowToggle('buy_now_message');
	}
}
function videoClickHandler(evt)
{
	var span;
	var spanContent = '';
	if(window.event && window.event.srcElement.tagName=='SPAN') { span = window.event.srcElement; spanContent = span.innerHTML; }
	else if(evt && evt.target && evt.target.tagName=='SPAN') { span = evt.target; spanContent = span.innerHTML; }
	if(spanContent.indexOf('Video') !== -1)
	{
		var vloc = window.location.toString();
		var url = '';
		if(vloc.indexOf('plagiarism')!=-1) { url = 'anti-plagiarism'; }
		else if(vloc.indexOf('citation')!=-1) { url = 'citation'; }
		else if(vloc.indexOf('code_checker')!=-1) { url = 'code_checker'; }
		else if(vloc.indexOf('paraphrase')!=-1) { url = 'paraphrase'; }
		else { url = 'anti-plagiarism'; }
		if(url != '')
		{
			winPop(BASE_URL+'/video/'+url, '_blank');
		}
	}
}
//document.onmouseover = mouseHandler;
//document.onmouseout = mouseHandler;
//window.onload = createBuyNowMessage;
document.onclick = videoClickHandler;