﻿
//this function will show the content within the <div> tag
function toggleDiv(divName)
{
	//alert('test');
    if (popups) {
        for (popup = 0; popup <= popups.length; popup = popup + 1) {
            thisDiv = document.getElementById(popups[popup]);
            if (thisDiv) {
                thisDiv.style.display = "none";
            }
        }
    }
	
	thisDiv = document.getElementById(divName);
	if (thisDiv)
	{
		thisDiv.style.display = "block";
	}
	else
	{
		alert("Error: Could not locate div with id: " + divName);
	}
}

function showShare(divName) {
    thisDiv = document.getElementById(divName);
    if(thisDiv)
    {
        thisDiv.cssClass.setAttribute("class", thisDiv.getAttribute('ShareClass'));
    }
    toggleDiv(divName + "_popupDialog");
}

function shareHide(divName, headlineName) {
    thisDiv = document.getElementById(headlineName);
    if (thisDiv) {
        thisDiv.setAttribute("class", thisDiv.getAttribute('shareclass'));
    }
    toggleDiv2(divName);
}

function toggleImage(divName) {

    thisDiv = document.getElementById(divName);
    if (thisDiv) {
        thisDiv.style.display = "block";
    }
    else {
        alert("Error: Could not locate div with id: " + divName);
    }
}


//this function will hide the content within the <div> tag
function toggleDiv2(divName)
{
	//alert('test');
	thisDiv = document.getElementById(divName);
	if (thisDiv)
	{
	    if (thisDiv.style.display == "block")
		{
			thisDiv.style.display = "none";
		}
	}
	else
	{
		alert("Error: Could not locate div with id: " + divName);
	}
}
function fbs_click()
{
	u = location.href;
	t = document.title;
	window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
}

function SetSelected(textboxName)
{
	textbox = document.getElementById(textboxName);
	textbox.select();
}

function twitter_click() {
    u = location.href;
    t = document.title;
    window.open('http://www.twitter.com/home?status=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
    return false;
}

function SetSelected(textboxName) {
    textbox = document.getElementById(textboxName);
    textbox.select();
}

function checkpopup()
{
	var cVal = getCookie("VGTTNKS");
	var elem = document.getElementById(cVal);

	if (elem)
	{
		toggleDiv(cVal);
	}
	
	setCookie("VGTTNKS", "", -1);
}

function getCookie(c_name)
{
	if (document.cookie.length > 0)
	{
		c_start = document.cookie.indexOf(c_name + "=");
		if (c_start != -1)
		{
			c_start = c_start + c_name.length + 1;
			c_end = document.cookie.indexOf(";", c_start);
			if (c_end == -1) c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start, c_end));
		}
	}
	return "";
}

function setCookie(c_name, value, expiredays)
{
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie = c_name + "=" + escape(value) +
((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}

function clearTextbox(textBox)
{
	var tb = document.getElementById(textBox);
	tb.value = '';
}

function popWindow(page) {
    window.open(page, 'infoWindow', 'height=400px, width=550px, scrollbars=yes');
}
