﻿//Useful functions
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

function externalLinks() { 
    if (!document.getElementsByTagName) return; 
    var anchors = document.getElementsByTagName("a"); 
    for (var i=0; i<anchors.length; i++) { 
        var anchor = anchors[i]; 
        if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") 
            anchor.target = "_blank"; 
    } 
} 

function fixDivHeight() { 
    if (!document.getElementsByTagName) return; 
    var divs = document.getElementsByTagName("div"); 
    for (var x=0; x<divs.length; x++) { 
        var thediv = divs[x]; 
        if(thediv.className == 'col' || thediv.className == 'brand'  || thediv.className == 'cat' ){
            var maxHeight = 0;
            var myChildren = thediv.children
                for (y=0; y<myChildren.length; y++) {
                    if (myChildren.item(y).clientHeight > maxHeight) {
                        maxHeight = myChildren.item(y).clientHeight;
                    }
                }
                for (y=0; y<myChildren.length; y++) {
                    myChildren.item(y).style.height = maxHeight + 'px';
                }
        } 
    } 
} 


