// Handles e-mail window
function emailArticle(content) {
	window.open('/email.html', 'cbEmailWindow','width=620, height=500, status=1, scrollbars=1');
}


var addportlink = "";
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');

	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return ca.length;
}

function linkcheck() {
var tick1 = readCookie("ticket");
var tick2 = readCookie("uid");
var tick3 = readCookie("ext");
var cookies = 0;

if (tick1>0){
cookies = cookies + 1;
}
if (tick2>0){
cookies = cookies + 1;
}
if (tick3>0){
cookies = cookies + 1;
}

if(cookies == 3){
addportlink = "Add to portfolio";
} else {
addportlink = "Sign-in to add to portfolio";
}
}




function gup(name){  
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if(results == null)return ""; 
else return results[1];
}


function addListener(element, event, listener, bubble) {
        if(element.addEventListener) {
          if(typeof(bubble) == "undefined") bubble = false;
          element.addEventListener(event, listener, bubble);
        } else if(this.attachEvent) {
          element.attachEvent("on" + event, listener);
        }
      }

/* 
  ================================================
  PVII Uberlink Script
  Copyright (c) 2006 Project Seven Development
  www.projectseven.com
  Version: 1.0.0
  ================================================
  This is a modified version fo the PVII Uberlink Script
  function P7_Uberlink(cl,d){
	var i,ob,tA,h=document.location.href;
	if(document.getElementById){
	ob=(d)?document.getElementById(d):document;
	if(ob){
	tA=ob.getElementsByTagName('A');
	for(i=0;i<tA.length;i++){
	if(tA[i].href==h){
	tA[i].className=cl;
}}}}}
*/

function P7_Uberlink(cl,d,iden){
	var i,ob,tA,h=document.location.href;
	if(document.getElementById){
	ob=(d)?document.getElementById(d):document;
	if(ob){
	tA=ob.getElementsByTagName('A');
	for(i=0;i<tA.length;i++){
	if(tA[i].id==iden){
	tA[i].className=cl;
}}}}}


function showhidelist(d,iden){
	var i,ob,tA,h=document.location.href;
	if(document.getElementById){
	ob=(d)?document.getElementById(d):document;
	if(ob){
	tA=ob.getElementsByTagName('span');
	for(i=0;i<tA.length;i++){
	if(tA[i].id==iden){
	tA[i].className="list-menu-show";
	} else {
	tA[i].className="list-menu-hide";
}
}}}}



function showTitle()
{
var t = document.getElementsByTagName('title')[0];
if ( !!t.childNodes.length ) {
//alert( t.firstChild.data );
	var ffp = t.firstChild.data.indexOf("|");
		if (ffp > 0) {
		var theTitle = t.firstChild.data.substring(0,ffp);
			}
		else
		{
		theTitle = t.firstChild.data;
		}
} else if ( t.innerHTML ) {
var fp = t.innerHTML.indexOf("|");
if (fp > 0) {
var theTitle = t.innerHTML.substring(0,fp);
}
else
{
theTitle = t.innerHTML;
}

}

document.emailtoafriend.articleTitle.value = theTitle;

}

function showURL ()
{
var U = document.URL;
document.emailtoafriend.articleURL.value = U;

}

function getdescription() {
var dek = GetMetaValue('description');
document.emailtoafriend.articleDEK.value = dek;
}


function GetMetaValue(meta_name) {

    var my_arr=document.getElementsByTagName("META");
    for (var counter=0; counter<my_arr.length; counter++) {
        if (my_arr[counter].name.toLowerCase() == meta_name.toLowerCase()) {
           return my_arr[counter].content;
           }
    }
    return "N/A";

}


function sendarticle() {
document.emailtoafriend.submit();
}
