String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
function checkLinks(){
    var liveForexLinks = document.getElementById('liveForexLinksCC');
	var liveForexLinkOne = document.getElementById('liveForexLinkOneCC');
	var liveForexLinkTwo = document.getElementById('liveForexLinkTwoCC');
	
	var liveChartsContainer = document.getElementById('liveForexCCContainer');
	if ( liveChartsContainer.style.display != '' ||  liveChartsContainer.style.visibility == 'hidden' ) {
		return false;
	}
	var children = liveChartsContainer.getElementsByTagName('*');
	for ( var i = 0; i < children.length; i++ ) {
		if ( children[i].style.display != '' ||  children[i].style.visibility == 'hidden' ) {
			return false;
		}
	}
	
	
	if ( liveForexLinkOne && liveForexLinkTwo &&
		 (liveForexLinkOne.getAttribute("href") == "http://www.live-forex.co.uk" || liveForexLinkOne.getAttribute("href") == "http://www.live-forex.co.uk/") && 
		 liveForexLinkOne.innerHTML == "Live Forex" && 
		 liveForexLinkTwo.getAttribute("href") == "http://www.live-forex.co.uk/exchangerates.php" &&
		 liveForexLinkTwo.innerHTML == "Exchange Rates"
	    ) {
		return true;
	}
	return false;
}
function writeQT() {
	var divIFrame          = document.createElement('DIV');
	//var w                  = parseInt(document.getElementById('liveForexCCContainer').style.width);
	//var h                  = parseInt(document.getElementById('liveForexCCContainer').style.width) - 65;
	var w                  = 530;
	var h                  = 180;
	//divIFrame.style.width  = w + "px;";
	//divIFrame.style.height = h + "px";
	divIFrame.innerHTML    = '<iframe style="width:' + w + 'px; height:' + h + 'px; border:0px solid red;" frameborder="0" marginheight="0" marginwidth="0" src="http://www.live-forex.co.uk/cc.php" />';
	document.getElementById('liveForexCCContainer').insertBefore(divIFrame, document.getElementById('liveForexLinksCC'));
}
if ( checkLinks() ) {
    writeQT();
}
else {
	document.getElementById('liveForexCCContainer').style.display    = '';
	document.getElementById('liveForexCCContainer').style.visibility = 'visible';
    document.getElementById('liveForexCCContainer').innerHTML        = 'Wrong widget code';
    //document.getElementById('liveForexCCContainer').innerHTML = 'Please add live forex links';
}



