function choose_photog()
	{
	var parts=explode('(', $('autocomplete').value);
	$('autocomplete').value=parts[0];

	var email_parts=explode('LSW', parts[1]);

	var email=explode(')', email_parts[1]);

	new Ajax.Request('index.php', {
	evalScripts: true,
	method: 'POST',
	parameters: '?task=index&photog_email='+email[0]
	, onSuccess: function (t) { $('photog_email').value=t.responseText }
	});
	}

function explode (delimiter, string, limit) {
    // Splits a string on string separator and return array of components. If limit is positive only limit number of components is returned. If limit is negative all components except the last abs(limit) are returned.  
    // 
    // version: 1004.2314
    // discuss at: http://phpjs.org/functions/explode    // +     original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: kenneth
    // +     improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: d3x
    // +     bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)    // *     example 1: explode(' ', 'Kevin van Zonneveld');
    // *     returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'}
    // *     example 2: explode('=', 'a=bc=d', 2);
    // *     returns 2: ['a', 'bc=d']
     var emptyArray = { 0: '' };
    
    // third argument is not required
    if ( arguments.length < 2 ||
        typeof arguments[0] == 'undefined' ||        typeof arguments[1] == 'undefined' ) {
        return null;
    }
 
    if ( delimiter === '' ||        delimiter === false ||
        delimiter === null ) {
        return false;
    }
     if ( typeof delimiter == 'function' ||
        typeof delimiter == 'object' ||
        typeof string == 'function' ||
        typeof string == 'object' ) {
        return emptyArray;    }
 
    if ( delimiter === true ) {
        delimiter = '1';
    }    
    if (!limit) {
        return string.toString().split(delimiter.toString());
    } else {
        // support for limit argument        var splitted = string.toString().split(delimiter.toString());
        var partA = splitted.splice(0, limit - 1);
        var partB = splitted.join(delimiter.toString());
        partA.push(partB);
        return partA;    }
}



function delete_item(url, query, confirm_message)
	{
	if (confirm(confirm_message))
		{
		window.location=url+query;
		}

	return false;
	}

function pop_up(URL, popup_width, popup_height) 
	{

	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+popup_width+',height='+popup_height+'');");
	}

function toggle_photog_pref(use)
	{
	if ($F(use)=='use_my_own')
		{
		return $('use_my_own').show();
		}

	$('use_my_own').hide();
	}

function toggle_tattoo(use)
	{
	if ($F(use)=='Yes')
		{
		return $('tattoos').show();
		}

	$('tattoos').hide();
	}

function toggle_state()
	{
	if ($F($('country'))=='United States')
		{
		$('state').show();
		$('no_state').hide();
		}
	else
		{
		$('state').hide();
		$('no_state').show();
		}
	}

function toggle_lsw(use)
	{
	if ($F(use)=='Yes')
		{
		return $('which_lsw').show();
		}

	$('which_lsw').hide();
	}

function toggle_pairwphotog(use)
	{
	if ($F(use)=='No')
		{
		return $('pair_with_photog').show();
		}

	$('pair_with_photog').hide();
	}

function alert_18(use)
	{
	
	if (!use.checked)
		{
		alert('We do not accept entries for models who are under 18 years of age.');
		}
	}

function check_file_uploads()
	{
	if (!$('photo_1').value||!$('photo_2').value||!$('photo_3').value||!$('photo_4').value) 
		{ 
		alert('Please choose at least 4 images for upload to continue.'); 
		return false;
		}
	else { return true; }
	}
