// Name: 		Script_Extras
// Compiler:  	Jacob Angel
// Created: 		June 19, 2008
// Updated: 		July 23, 2008
/* ----------------------------------- 
Name:		Select Bumping 
History: 	This selection was included by Winnercom
Function: 	Allows the custom select elements to fail gracefully, leaving selects in their correct postiion
 ------------------------------------- */
//document.write('<style type="text/css">select { position: absolute !important; left: -9000em !important; }</style>');

/* ----------------------------------- 
Set reCaptcha options 
 ------------------------------------- */
var RecaptchaOptions  = {
	theme: 'white',
	lang : 'en'
};
/* ----------------------------------- 
Set Rand_Number and Pr_Tile
 ------------------------------------- */
var pr_tile  = 2; //assumes that pr_tile is hardcoded for the banner ad
var rand_number = Math.floor( Math.random() * 9999999999 + 1 );

/* -----------------------------
positionAd 
-------------------------------*/
function positionAd(adSourceId, adTargetId) {
			try{
            var scriptdiv = document.getElementById(adSourceId);
			document.getElementById(adTargetId).appendChild(scriptdiv);
            }
			catch(err)
			{
				var errorNode = document.createTextNode("<!-- Error: " + err.description + "-->");
				document.getElementById(adTargetId).appendChild(errorNode);
			}
}
/*****************************************************************************/
/* FFonly - a simple ff3 check using mootools 1.11                           */
/* author - jacob angel; date - 07/21/08; required files - mootools          */
/*****************************************************************************/
/*
 gteFF3 - window.gecko: true if firefox
        - [].reduceRight returns true if ff3 or greater
        - returns true if firefox 3 or greater
*/
function gteFF3(){if(window.gecko==true && [].reduceRight) {return true} else {return false}}
if(gteFF3()){ //wherein we create a style tag, set some css for it and insert it into the head.
    window.addEvent('domready', function(){
        var ff3Style = new Element('style', {}); 
        ff3Style.setHTML(".sIFR-active .article_subcontent em, .sIFR-active .browse_all_link { margin-top:-3.7em !important;} .advanced_search fieldset select {height: auto !important}");
        $(ff3Style).injectInside($$('head')[0]);
        });
}

/*****************************************************************************/
/* Validation - a simple form validator using mootools 1.11                                    */
/* author - jacob angel; date - 07/22/08; required files - mootools                       */
/*****************************************************************************/
/*
 Functions
*/
// alarum - parameters(element, warning)
//            @param - element - the element of give focus
//            @param - warning - the warning to give out
//  factored out the warning so that we could eventually improve it.
function alarum(elem, warn){
        window.alert(warn);
        $(elem).focus();
}

/** is_checked - parameters(element, warning)
    @param element  string or valid mootools element  The element's name or a dom node
    @param warning  string  The warning displayed by the validation function
    @returns        boolean
*/              
function is_checked(elem,warning){
    element = $(elem);
    if(element.getValue() === false)
    {
    	alarum(element, warning)
        return false;
    }
    else {
        return true;
    }
}

// equality - parameters
//            @param - element - a 2 element array of element ids
//            @param - warning - the warning
/* @author */
// returns true if element[0].value == element[1].value
function equality(element, warning){
    if($chk($(element[0]))){ //if there
        if($(element[0]).value == $(element[1]).value){
            return true;
        }
    }
    alarum(element[1], warning);
    return false;
}
// not_default - parameters
//            @param - element - a 2 element array, [0] = id [1] = value
//            @param - warning - the warning
// returns true if element[0].value != element[1]
function not_default(element, warning){
    if($chk($(element[0]))){ //if there
        if($(element[0]).value == element[1]){
        alarum(element[0], warning);
        return false;    
        }
    }
    return true;
}
// good_password_request_email - returns true if the request is good
//    good cases: email wellformed || username != Username
//    bad cases: both email and username are default or the email address is malformed and not default
//    note: this accepts an array in the element field
function good_password_request(element,warning){
    
    if( ($chk($(element[0]).value) && $(element[0]).value != "Username") || ($chk($(element[1]).value) && $(element[1]).value != "Email Address" && $(element[1]).value.indexOf('@') > 0 && $(element[1]).value.indexOf('.') > 0 && $(element[1]).value.indexOf('@') < email.lastIndexOf('.')) ) 
        return true;
    else
    {
        alarum(element[0], warning);
        return false;
    }
}
// not_empty - returns true if an element is null, "" or otherwise empty
function not_empty(element, warning){
    if(!$chk($(element).value)){
        alarum(element, warning);
        return false;
    }
    else{    
        return true;
    }
}
// good_email - returns true if an element is a good email
// note: assumed to be required; an empty string is considered a bad email
function good_email(element, warning){
    var email = $(element).value;
    if( !(email.indexOf('@') > 0 && email.indexOf('.') > 0 && email.indexOf('@') < email.lastIndexOf('.')) )  {
        alarum(element, warning);
        return false;
    }
    else{    
        return true;
    }
}
// no_swears - returns true if no swears, false otherwise
// note: an empty or null string does not contain swears
function no_swears(element, warning)
{
	var swearlist = ['whore','whoar','wetback','wank','vagina','twaty','twat','titty','titties','teets','spic','snatch','smut','sluts','slut','shiz','shitty','shittings','shitting','shitters','shitter','shitted','shits','shitings','shiting','shitfull','shited','shit','sheister','sh!t','scrotum','schlong','qweef','queef','pussys','pussy','pussies','pusse','prostitute','pr0n','pornos','pornography','porno','pissoff','pimp','phuq','phuks','phukking','phukked','phuking','phuked','phuk','phuck','niggers','nigger','nigga','motherfucks','motherfuckings','motherfucking','motherfuckin','motherfuckers','motherfucker','motherfucked','motherfuck','mothafucks','mothafuckings','mothafucking','mothafuckin','mothafuckers','mothafucker','mothafucked','mothafuckaz','mothafuckas','mothafucka','mothafuck','masturbate','lesbo','kunilingus','kums','kumming','kummer','kuksuger','kondums','kondum','kock','kike','jizz','jizm','jiz','jism','jesus fucking christ','jerk-off','jap','jackoff','jacking off','jackass','jack-off','jack off','hotsex','honkey','homo','hardcoresex','h4x0r','h0r','gook','gonads','gazongers','gaysex','gay','gangbangs','gangbanged','gangbang','fux0r','furburger','fuks','fuk','fucks','fuckme','fuckings','fucking','fuckin','fuckers','fucker','fucked','fuck','fistfucks','fistfuckings','fistfucking','fistfuckers','fistfucker','fistfucked','fistfuck','fingerfucks','fingerfucking','fingerfuckers','fingerfucker','fingerfucked','fingerfuck','fellatio','felatio','feces','fcuk','fatass','fags','fagots','fagot','faggs','faggot','faggit','fagging','fagget','fag','ejaculation','ejaculatings','ejaculating','ejaculates','ejaculated','ejaculate','dyke','dumbass','douche bag','dong','dipshit','dildos','dildo','dike','cyberfucking','cyberfuckers','cyberfucker','cyberfucked','cyberfuck','cyberfuc','cunts','cuntlicking','cuntlicker','cuntlick','cunt','cunnilingus','cunillingus','cunilingus','cumshot','cums','cumming','cummer','cum','cooter','cocksucks','cocksucking','cocksucker','cocksucked','cocksuck','clits','clit','circle jerk','buttpicker','butthole','buttfucker','buttfuck','butt fucker','bung hole','bullshit','bull shit','bucket cunt','browntown','browneye','brown eye','blowjobs','blowjob','blow job','bitching','bitchin','bitches','bitchers','bitcher','bitch','bestiality','belly whacker','beastility','beastiality','bastard','asswipe','asskisser','assholes','asshole','ass lick','ass'];
	var swearReg = new RegExp("\b"+swearlist.join("|")+"\b", "i");
    var exclusivelist = ['whore','whoar','wetback','wank','vagina','twaty','twat','titty','titties','teets','spic','snatch','smut','sluts','slut','shiz','shitty','shittings','shitting','shitters','shitter','shitted','shits','shitings','shiting','shitfull','shited','shit','sheister','sh!t','scrotum','schlong','qweef','queef','pussys','pussy','pussies','pusse','prostitute','pr0n','pornos','pornography','porno','pissoff','pimp','phuq','phuks','phukking','phukked','phuking','phuked','phuk','phuck','niggers','nigger','nigga','motherfucks','motherfuckings','motherfucking','motherfuckin','motherfuckers','motherfucker','motherfucked','motherfuck','mothafucks','mothafuckings','mothafucking','mothafuckin','mothafuckers','mothafucker','mothafucked','mothafuckaz','mothafuckas','mothafucka','mothafuck','masturbate','lesbo','kunilingus','kums','kumming','kummer','kuksuger','kondums','kondum','kock','kike','jizz','jizm','jiz','jism','jesus fucking christ','jerk-off','jackoff','jacking off','jackass','jack-off','jack off','hotsex','honkey','homo','hardcoresex','h4x0r','gook','gaysex','gangbangs','gangbanged','gangbang','fux0r','furburger','fuks','fucks','fuckme','fuckings','fucking','fuckin','fuckers','fucker','fucked','fuck','fistfucks','fistfuckings','fistfucking','fistfuckers','fistfucker','fistfucked','fistfuck','fingerfucks','fingerfucking','fingerfuckers','fingerfucker','fingerfucked','fingerfuck','fellatio','felatio','fatass','fags','fagots','fagot','faggs','faggot','faggit','fagging','fagget','fag','ejaculation','ejaculatings','ejaculating','ejaculates','ejaculated','ejaculate','dyke','dumbass','douche bag','dipshit','dildos','dildo','cyberfucking','cyberfuckers','cyberfucker','cyberfucked','cyberfuck','cyberfuc','cunts','cuntlicking','cuntlicker','cuntlick','cunt','cunnilingus','cunillingus','cunilingus','cumshot','cums','cumming','cummer','cum','cooter','cocksucks','cocksucking','cocksucker','cocksucked','cocksuck','clits','clit','circle jerk','buttpicker','butthole','buttfucker','buttfuck','butt fucker','bung hole','bullshit','bull shit','bucket cunt','browntown','browneye','brown eye','blowjobs','blowjob','blow job','bitching','bitchin','bitches','bitchers','bitcher','bitch','bestiality','belly whacker','beastility','beastiality','bastard','asswipe','asskisser','assholes','asshole'];
    var exclusiveReg = new RegExp(exclusivelist.join("|"), "i");
    var elementText = $(element).value;
	if($chk(elementText))
	{
        if(swearReg.test(elementText) || exclusiveReg.test(elementText))
	    {	
		    alarum(element, warning);
            return false;
	    }
        else return true;
    }
    else return true;
}

// bindValidator - accepts an object literal, binding the contents to form elements
function bindValidator(validatorConfig){
    if($chk($(validatorConfig.formId))){
        $(validatorConfig.formId).addEvent('submit', function(event){
            for(var i = 0; i<validatorConfig.requests.length;i++){
                if(!(window[validatorConfig.requests[i].functionName](validatorConfig.requests[i].element, validatorConfig.requests[i].warning))){
                    var eventHolder = new Event(event).stop();
                    return false;
                }
            }
            return true;
        });
    }
}

