// JavaScript Document
function extract ( urlStr ){
	var tmpstr = urlStr.split(":");
	if ( tmpstr[1].substring(0,5) == "//www")
		tmpstr[1] = tmpstr[1].substring(6,tmpstr[1].length);
	else
		tmpstr[1] = tmpstr[1].substring(2,tmpstr[1].length);
	return tmpstr;
	
}

function checkURL ( urlStr ){
	/*incomplete reg exp */
	var tmp = new RegExp ("(http:\/\/)(www\.)?(([a-zA-Z0-9\-\_])+)([\.][a-zA-Z])");
	if (!tmp.test(urlStr) ){
		alert ( "String is NOT in good condition\nEX:\n  http://www.domain-name.com \n OR \n  http://domain-name.com");
		return false;
	}return true;
		
}

function capitalize( urlStr ){
	var i, str, t1, t2, finalstr = "";
	str = urlStr.split(" ");
	for( i = 0; i < str.length; i++ ){
		str[i] = (str[i].substring(0,1)).toUpperCase() + str[i].substring(1,str[i].length);
	}
	for ( i = 0; i < str.length; i++ ){
		if ( finalstr == "" ) finalstr = str[i];
		else finalstr = finalstr + " " + str[i];
	}
	return finalstr;
}



function display( clientURL, email, anchortitle, description ){
	var client0, client, anctitle;
	var test = checkURL ( clientURL );	
	if (test){
		client0 = extract (clientURL);
		client = client0[1];
		anctitle = capitalize ( anchortitle );
  	document.write("<h2>Link to " + client + "</h2>");
  	document.write("<p>Link popularity is fast becoming one of the highest weighted criteria used in ranking your site in the search engines. The more related sites linking to yours ");
  	document.write("the higher your sites ranking climbs in the search engine results. We like to link with sites that complement ours or can offer our clients a valid service. We will not exchange ");
  	document.write("links with any website that is unduly offensive or fraudulently boastful in its claims.<br><br>");
  	document.write("<strong>How do I swap links with " + client + " ?</strong><br><br>");
  	document.write("Exchanging links between our two sites is easy. <a href=\"mailto:" + email + "\" style=\"text-decoration:underline;\">Send us an email</a> with a one or two sentence description of ");
  	document.write("your site and the exact URL. We\'ll review your site as soon as possible, validate the reciprocal link on your site and if we feel that your site provides good complimentary content, ");
  	document.write("we will reciprocate the link. Please, consider putting a link to our site before requesting link exchange.<br><br><b>To add " + client + " link to your website, simply use the following html code:</b><br><br>");
  	document.write("<div style=\"border-style:solid;border-width:2px;border-color:#023365;padding:5px;color:#000000;\">&lt;a href=\"" + clientURL + "\" title=\"" + anctitle + "\"&gt;" + anctitle + "&lt;/a&gt;&lt;br&gt;" + description + "</div>");
  	document.write("<br><br>Thank you kindly,<br>" + client + "<br>");
  	document.write("<h3>Resources</h3>");
	}
	else{
		document.write ("<div style=\"font-size:14px;font-weight:bold;color:#ff0000;\">PLEASE CORRECT URL STRING ! </div>");
	}
}

function toggle_visibility(id) {

var e = document.getElementById(id);

if(e.style.display == 'block'){

e.style.display = 'none';
}
else{

e.style.display = 'block';
}
}
function cellImg(idcell, imgName) { 
idcell.style.background = "url(" + imgName + ")";
} 
function togglec(idcell, cname) { 
idcell.className = cname;
} 
function redirect(url){
window.location.href=url;
}



