/*
	This note must stay intact.
	
	Author:
		Mattias Rundqvist, Webparts (www.webparts.se)
	License:
		Creative Commons Attribution-Share Alike 3.0 License
		http://creativecommons.org/licenses/by-sa/3.0/
*/

var wp_Prototypes = true;

Array.prototype.find = function( value ) {
    for(count = 0; count<this.length; count++) {
        if( this[count] == value ) return count;
    }
    return -1;
};

Array.prototype.exist = function( value ) {
    for(count = 0; count<this.length; count++) {
        if( this[count] == value ) return true;
    }
    return false;
};

Array.prototype.intersection = function( setB ) {  
	var setA = this;  
	
	var setA_seen = {};  
	var setB_seen = {};  
	for ( var i = 0; i < setB.length; i++ ) {  
		setB_seen[ setB[i] ] = true;  
	}  

	var intersection = [];  
	for ( var i = 0; i < setA.length; i++ ) {  
		if ( !setA_seen[ setA[i] ] ) {  
			setA_seen[ setA[i] ] = true;  
			if ( setB_seen[ setA[i] ] ) {  
				intersection.push( setA[i] );  
			}  
		}  
	}  
	return intersection;  
}; 

Array.prototype.union = function( setB ) {  
	var setA = this;  

	var seen = {};  
	var union = [];  

	for ( var i = 0; i < setA.length; i++ ) {  
		if ( !seen[ setA[i] ] ) {  
			union.push( setA[i] );  
			seen[ setA[i] ] = true;  
		}  
	}  
	for ( var i = 0; i < setB.length; i++ ) {  
		if ( !seen[ setB[i] ] ) {  
			union.push( setB[i] );  
			seen[ setB[i] ] = true;  
		}  
	}  
	return union;  
};

  
Array.prototype.push_back = function( value ) {
	if( typeof value == "object" && value.length ) {
		for( var count = 0; count < value.length; count++ ) {
			this[this.length] = value[count];
		}
	} else {
		this[this.length] = value;
	}
}

Array.prototype.remove = function( value ) {
	var tmp = new Array();
	for( count = 0; count < this.length; count++ ) {
		if( value != this[count] ) {
			tmp[tmp.length]=this[count];
		}
	}
	return tmp;
}

String.prototype.isMatch = function( valid ) {
	for( count = 0; count < this.length; count++ ) {
		if( valid.indexOf(this.substring(count,count+1)) == -1 )
			return false;
	}
	return true;			
};

String.prototype.isNum = function() {
	return this.isMatch("1234567890");
};

String.prototype.isLetter = function() {
	return this.isMatch("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");			
};