// JavaScript Document

function byname_onchange() {
	document.search_form.state.options[0].selected = true;
	document.search_form.region.options[0].selected = true;
	document.search_form.pclass.options[0].selected = true;
}
function clear_state() {
	document.search_form.state.options[0].selected = true; 
}
function clear_region() {
	document.search_form.region.options[0].selected = true;
}
function clear_byname() {
	document.search_form.byname.value = "";
}


// Google Analytics Code

// NOTE: these domain names MUST be lower case
    var account_part_by_domain = {
        // final part of the Google Analytics account id
		'accountingschools.org'			: '24161709-10',
		'actingschools.com'	   			: '24161709-11',
		'acupunctureschools.com'   		: '24161709-12',
		'advertisingschools.com'   		: '24161709-2',
		'applytoschools.com'			: '24161709-13',
		'architectureschools.com'   	: '24161709-3',
        'artschools.com'            	: '13077554-1',
        'atlantaeducation.com'      	: '13077554-24',
		'auditingschools.com'			: '24161709-14',
        'austineducation.com'  			: '13077554-52',
        'automotiveschools.com'     	: '13077554-46',
		'aviationschools.com'			: '24161709-15',
		'bachelorsdegrees.net'			: '24161709-16',
        'bostoneducation.org'       	: '13077554-6',
        'broadcastingschools.com'   	: '13077554-47',
		'burnabyeducation.com'			: '25149415-14',
        'businessschools.com'       	: '13077554-3',
		'careertraining.org'			: '25149415-15',
		'charlotteeducation.com'		: '24161709-17',
        'chicagoeducation.com'      	: '13077554-4',
		'cincinnatieducation.com'		: '24161709-18',
		'clevelandeducation.com'		: '24161709-19',
		'collegesusa.com'				: '25149415-16',
        'computerschools.com'       	: '13077554-8',
		'coninuinged.org'				: '25149415-17',
        'cookingschools.com'        	: '13077554-2',
		'cosmetologyschools.com'	   	: '24161709-20',
        'criminaljusticedegree.org' 	: '13077554-9',
        'culinaryschools.net'       	: '13077554-10',
        'dallaseducation.com'       	: '13077554-25',
        'danceschools.net'       		: '25149415-22',
        'databaseschools.com'       	: '25149415-21',
        'dentalschools.com'         	: '13077554-42',
        'denvereducation.com'       	: '13077554-28',
        'designschools.com'         	: '13077554-11',
		'detroiteducation.com'			: '24161709-21',
        'education.org'             	: '13077554-12',
		'engineeringschools.com'   		: '24161709-4',
		'enviroeducation.com'	   		: '24161709-22',
        'executivembaschools.com'       : '25149415-25',
        'fashionschools.com'        	: '13077554-13',
        'filmschools.com'           	: '13077554-14',
		'financeschools.org'			: '24161709-23',
        'financialdegree.com'       	: '25149415-24',
		'fortlauderdaleeducation.com'   : '24161709-24',
        'gamedesignschools.com'     	: '13077554-37',
		'graduateschools.net'			: '24161709-25',
        'graphicdesignschools.com'  	: '13077554-15',
		'guitarschools.com'				: '24161709-26',
        'healthcaredegrees.org'     	: '13077554-16',
		'healthmanagementschools.com'	: '25149415-18',
		'helicopterschools.org'			: '24161709-27',
        'hospitalityschools.com'    	: '13077554-35',
		'houstoneducation.com'			: '24161709-28',
		'hvacschools.com'   			: '24161709-29',
        'indianapoliseducation.com' 	: '13077554-34',
        'interiordesignschools.org' 	: '13077554-17',
		'jacksonvilleeducation.com'		: '24161709-30',
        'journalismschools.com'     	: '13077554-48',
        'lasvegaseducation.org'     	: '13077554-41',
		'lawschools.com'   				: '24161709-5',
		'londonschools.org'				: '25149415-19',
        'losangeleseducation.com'   	: '13077554-21',
        'managementschools.com'       	: '25149415-23',
		'marketingschools.com'			: '24161709-31',
        'massageschools.net' 			: '13077554-53',
        'medicalassistingschools.com' 	: '13077554-49',
		'medicalschools.com'   			: '24161709-6',
        'miamieducation.com'        	: '13077554-26',
		'militaryschools.com'			: '24161709-32',
		'milwaukeeeducation.com'		: '24161709-33',
        'minneapoliseducation.com'  	: '13077554-30',
		'mortuaryschools.com'   		: '24161709-7',
		'nashvilleeducation.com'		: '24161709-34',
		'naturopathicschools.com'		: '24161709-35',
		'newjerseyeducation.com'		: '24161709-36',
        'newyorkcolleges.com'       	: '13077554-5',
        'nursingschools.com'        	: '13077554-18',
		'obedienceschools.com'			: '24161709-37',
		'onlinegraduateschools.net'		: '24161709-38',
		'onlinembadegrees.net'			: '24161709-39',
        'onlineschools.net'         	: '13077554-40',
		'optometryschools.com'	   		: '24161709-40',
        'orangecountyeducation.org' 	: '13077554-31',
		'orientalmedicinecolleges.com'	: '24161709-41',
        'orlandoeducation.org'      	: '13077554-29',
		'paralegalschools.com'	   		: '24161709-42',
		'performingartsschools.com'   	: '24161709-8',
		'pharmacyschools.com'	   		: '24161709-9',
		'philadelphiaeducation.com'   	: '24161709-43',
        'phoenixeducation.com'      	: '13077554-32',
        'photographyschools.com'    	: '13077554-19',
        'pittsburgheducation.com'   	: '13077554-38',
        'portlandeducation.com'     	: '13077554-27',
		'privateschools.com'	   		: '24161709-44',
		'providenceeducation.org'		: '24161709-45',
        'psychologyschools.com'    		: '13077554-50',
		'regionaleducation.com'			: '24161709-46',
        'restaurantschools.com'     	: '13077554-36',
		'sandiegoeducation.com'			: '24161709-47',
        'sanfranciscoeducation.com' 	: '13077554-22',
		'santamonicaeducation.com'		: '24161709-48',
		'schaumburgeducation.com'		: '24161709-49',
        'seattleschools.com'        	: '13077554-20',
		'securityschools.com'   		: '24161709-50',
		'stateschools.com'				: '25149415-1',
		'stlouiseducation.com'			: '25149415-20',
        'tampaeducation.com'   			: '25149415-2',
        'teaching.org'      			: '13077554-51',
		'teachingschools.org'			: '25149415-3',
		'theatreschools.net'			: '25149415-4',
		'theeducationcompany.com'		: '25149415-5',
		'topbusinessschools.com'		: '25149415-6',
		'topgraducateschools.com'		: '25149415-7',
		'torontoeducation.org'			: '25149415-8',
        'tradeschools.com'        		: '13077554-45',
        'truckdrivingschools.com'   	: '25149415-9',
        'vancouvereducation.org'    	: '13077554-33',
		'veterinaryschools.com'   		: '13077554-43',
		'vocationalschools.com'   		: '24161709-1',
		'washingtoneducation.com'		: '25149415-10',
		'webdesignschools.com'			: '13077554-44',
		'weldingschools.com'			: '25149415-11',
		'workingstudent.com'			: '25149415-12',
		'yorkcolleges.com'				: '25149415-13'
    }

    function Get_Cookie( name ) {
        var start = document.cookie.indexOf( name + '=' );
        var len = start + name.length + 1;
        if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
            return null;
        }
        if ( start == -1 ) return null;
        var end = document.cookie.indexOf( ';', len );
        if ( end == -1 ) end = document.cookie.length;
        return unescape( document.cookie.substring( len, end ) );
    }

    var host_domain_page = /^http:\/\/([^\.]+)\.([^\/]+)([^?]*)/
    var part = host_domain_page.exec( window.location.href );
    if( part[0] ) {
        var host = part[1];
        var domain = part[2];
        var page = part[3];
        var account_part = account_part_by_domain[domain];
        // only continue if an account_part was found AND the host is not a test or qa machine
        var testSpotter = /^(test|test-drf|qa|qa-drf)$/;
        if( account_part && ! testSpotter.test( host ) ) {
            var paid_or_organic = 'ORGANIC';
	    	var patid_param = /[?&]patid=/i;
            if( patid_param.test( window.location.href || '' ) ||
				patid_param.test( document.referrer || '' ) ||
				patid_param.test( Get_Cookie( 'wtmc' ) || '' ) ||
				patid_param.test( Get_Cookie( 'track_cookie' ) || '' )) {
                paid_or_organic = 'PAID';
            }
            var _gaq = _gaq || [];
            _gaq.push( ['_setAccount', 'UA-' + account_part] );
            _gaq.push( ['_trackPageview', page + '/' + paid_or_organic] );
            ( function() {
                var ga = document.createElement( 'script' );
                ga.type = 'text/javascript';
                ga.async = true;
                ga.src = ( 'https:' == document.location.protocol ? 'https://ssl' : 'http://www' ) + '.google-analytics.com/ga.js';
                var s = document.getElementsByTagName( 'script' )[0];
                s.parentNode.insertBefore( ga, s );
            } )();
        }
    }
