﻿// JScript File
function SearchTrixsy() 
{
  if (document.getElementById('QueryBox'))
  {
    var query = document.getElementById('QueryBox').value;
    var searchtype = checkSelected();
    
    if (searchtype == 'images')
        location.href = 'search.aspx?q=' + escape(query) + '&sf=ctid:1';
    else if (searchtype == 'videos')
        location.href = 'search.aspx?q=' + escape(query) + '&sf=ctid:2';
    else
        location.href = 'search.aspx?q=' + escape(query);
  }
} 

function checkSelected()
{
    var temp;
    for (i=0; i<document.TrixsySearchForm.mediabtns.length; i++) 
    {
	    if (document.TrixsySearchForm.mediabtns[i].checked) 
	    {
		    temp = document.TrixsySearchForm.mediabtns[i].value;
	    }
	}
	return temp;
}

function setExplicit(explicit)
{
    if (explicit == 'yes')
    {
        setCookie('TrixsyAccess', explicit, 9999, '/', '');
        location.href = location.href;
    }
    else
        location.href = "http://www.pixsy.com";
}

function setCookie(name, value, expires, path, domain) 
{
	var expires_date = new Date();
	if (expires) 
	{
		expires = 1000 * 60 * 60 * 24; //cookie expires 24 hours from now
	}
	expires_date.setTime(expires_date.getTime() + expires);
	document.cookie = name + '=' + escape(value) + ';expires=' + expires_date.toGMTString() + ';path=' + path;
}

function moveDivs(source,target)
{
    if (document.getElementById(source) && document.getElementById(target))
    {
        var sourceDiv = document.getElementById(source);
        var targetDiv = document.getElementById(target);
        targetDiv.innerHTML = sourceDiv.innerHTML;
        sourceDiv.innerHTML = "";
    }
}