/* TantraLogic JavaScript File */

// kludge for ownyourlovelife.com
if( document.location.href.toString().indexOf( "ownyourlovelife" ) != -1 && 
	document.location.href.toString().indexOf( ".com/o" ) == -1 ) // own or order
{
	document.location.href = "/own-your-lovelife.html";	
}

var prck = "~prompted~";

// statcounter variables
sc_project=3599162;
sc_invisible=1;
sc_partition=41;
sc_security="5449f0b9";

// Contact form validation
function validsubmit(mailform)
{
	// Make sure the name is given
	if(mailform.v1_Firstname.value.length <= 0)
	{
		alert( "We need your name to stay in touch." );
		mailform.v1_Firstname.focus();
	}
	// Make sure the email looks correct
	else if((mailform.email.value.length <= 0) || (mailform.email.value.indexOf("@") <= 0))
	{
		alert( "We need a valid email to stay in touch." );
		mailform.email.focus();
	}
	// Get the client date and submit
	else
	{
		mailform.v2_Date.value = new Date().toUTCString();
		mailform.submit();
	}
}

function cancelform(mailform)
{
	mailform.reset();
	document.location='index.html';
}

function contactus(subj)
{
	var contact="info";
	var domain="tantralogic.com";
	var subject="<<TantraLogic>> Contact: Other";
	if(subj != null)
	{
	    subject="<<Tantralogic>> Contact: " + subj;
	}
	document.location.href="mailto:"+contact+"@"+domain+"?subject="+subject;
}

function showprivacy()
{
    window.open("policies.html#privacy","popup","width=850,height=400,menubar=no,toolbar=no,scrollbars=yes,resizable=yes");
}

function clearstatus()
{
    window.status='';
    return true;
}

function noprompt()
{
	document.cookie = prck;
}

function isprompted()
{
	return document.cookie.indexOf(prck) != -1;
}

function menuover(itemname)
{
	itemname.backgroundImage="img/buttonover.gif";
}

function menuout(itemname)
{
	itemname.background="img/button.gif";	
}

function getqueryvar(varname)
{
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for(var i=0;i<vars.length;i++)
	{    
		var pair = vars[i].split("=");
		if(pair[0] == varname)
		{
			return unescape(pair[1]);
		}
	}
	return "";
}

function makequeryvar(varname,varvalue)
{
	return escape(varname) + "=" + escape(varvalue);	
}

function openquery(loc, varnames, varvals)
{
	var newloc = loc + "?";
	var names = varnames.split("@");
	var values = varvals.split("@");
	for(var i=0;i<names.length;i++)
	{
		newloc += makequeryvar(names[i],values[i]) + "&";
	}
	window.location.href = newloc;
}

function openCenteredWindow(url, winname) 
{
    var width = 600;
    var height = 400;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",toolbar=no,status=no,menubar=no,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
    newwin = window.open(url, winname, windowFeatures);
}
