function initPage()
{
	var navRoot = document.getElementById("log-block");
	if (navRoot) 
	{
		navRoot.onmouseover = function()
		{
			this.className = "hover";
                }
		navRoot.onmouseout = function()
		{
			this.className = "";
		}
	}
	var navRoot = document.getElementById("searchmenu");
	if (navRoot) 
	{
		navRoot.onmouseover = function()
		{
			this.className = "hover";
                }
		navRoot.onmouseout = function()
		{
			this.className = "";
		}
	}

}

function addHref(){
	var username =fetch_cookie('username');
	var encodedGroupId=	fetch_cookie('enc_usergroupid');
	var refc = getUrlParam('refc');
	if (isNaN(refc)) refc = "";
	if(username==null){
		//document.getElementById('logdOutCreateProfile').href='http://www.paltalk.com/people/webapp/login.wmt?keepThis=true&TB_iframe=true&height=270&width=300&target=/people/webapp/my/info.wmt';
		//document.getElementById('logdOutCreateGroup').href='http://www.paltalk.com/people/webapp/login.wmt?keepThis=true&TB_iframe=true&height=270&width=300&target=/g2/webapp/my/edit_info.wmt';
		document.getElementById('createProfile').href='http://www.paltalk.com/people/webapp/my/info.wmt';
		if (refc != "") {
			document.getElementById('mastheadHome').href = '/index.php?refc=' + refc;
			document.getElementById('navHomeLink').href = '/index.php?refc=' + refc;
			document.getElementById('navExpressLink').href = '/express/?refc=' + refc;
			document.getElementById('navWhatIsPaltalk').href = '/learnaboutpaltalk.shtml?refc=' + refc;
			document.getElementById('navHearMeLink').href = 'http://www.hearme.com/?refc=' + refc;
			document.getElementById('navCameoLink').href = document.getElementById('navCameoLink').href + '?refc=' + refc;
			document.getElementById('navMembers').href = document.getElementById('navMembers').href + '?refc=' + refc;
			document.getElementById('navBrowseMembers').href = 'http://www.paltalk.com/people/webapp/index.wmt?refc=' + refc;
			document.getElementById('navChatRooms').href = document.getElementById('navChatRooms').href + '?refc=' + refc;
			document.getElementById('navBrowseChatRooms').href = 'http://www.paltalk.com/g2/webapp/groups/GroupsPage.wmt?refc=' + refc;
			document.getElementById('logdOutCreateProfile').onclick = function () {
				showLogin('http://www.paltalk.com/people/webapp/my/info.wmt?refc=' + refc); 
				return false;
			}
			document.getElementById('logdOutCreateGroup').onclick = function () {
				showLogin('http://www.paltalk.com/g2/webapp/my/edit_info.wmt?refc=' + refc); 
				return false;
			}

		}
	}

	else {
		//	alert('http://www.paltalk.com/people/users/'+username+'/index.wmt');
		if (refc == "") {
			document.getElementById('logdCreateProfile').href='http://www.paltalk.com/people/users/'+username+'/toolbox/my_info.wmt';
			document.getElementById('logdViewProfile').href='http://www.paltalk.com/people/users/'+username+'/index.wmt';
			document.getElementById('logdEditProfile').href='http://www.paltalk.com/people/users/'+username+'/toolbox/my_info.wmt';
			document.getElementById('changePicture').href='http://www.paltalk.com/people/users/'+username+'/toolbox/photo.wmt';
			document.getElementById('logdCreateGrp').href='http://www.paltalk.com/g2/webapp/my/edit_info.wmt';
			document.getElementById('logdViewGrp').href='http://www.paltalk.com/g2/group/'+encodedGroupId;
			document.getElementById('profile-notification').href='http://www.paltalk.com/people/users/'+username+'/toolbox/index.wmt';
			document.getElementById('createProfile').href='http://www.paltalk.com/people/users/'+username+'/toolbox/my_info.wmt';
			document.getElementById('viewProfile').href='http://www.paltalk.com/people/users/'+username+'/index.wmt';
			document.getElementById('editProfile').href='http://www.paltalk.com/people/users/'+username+'/toolbox/my_info.wmt';
			document.getElementById('profSettings').href='http://www.paltalk.com/people/users/'+username+'/toolbox/index.wmt';
			document.getElementById('createGroup').href='http://www.paltalk.com/g2/webapp/my/edit_info.wmt';
			document.getElementById('viewGroup').href='http://www.paltalk.com/g2/group/'+encodedGroupId;
		}
		else {
			document.getElementById('mastheadHome').href = '/index.php?refc=' + refc;
			document.getElementById('logdCreateProfile').href='http://www.paltalk.com/people/users/'+username+'/toolbox/my_info.wmt?refc=' + refc;
			document.getElementById('logdViewProfile').href='http://www.paltalk.com/people/users/'+username+'/index.wmt?refc=' + refc;
			document.getElementById('logdEditProfile').href='http://www.paltalk.com/people/users/'+username+'/toolbox/my_info.wmt?refc=' + refc;
			document.getElementById('changePicture').href='http://www.paltalk.com/people/users/'+username+'/toolbox/photo.wmt?refc=' + refc;
			document.getElementById('logdCreateGrp').href='http://www.paltalk.com/g2/webapp/my/edit_info.wmt?refc=' + refc;
			document.getElementById('logdViewGrp').href='http://www.paltalk.com/g2/group/'+encodedGroupId + '?refc=' + refc;
			document.getElementById('profile-notification').href='http://www.paltalk.com/people/users/'+username+'/toolbox/index.wmt?refc=' + refc;
			document.getElementById('createProfile').href='http://www.paltalk.com/people/users/'+username+'/toolbox/my_info.wmt?refc=' + refc;
			document.getElementById('viewProfile').href='http://www.paltalk.com/people/users/'+username+'/index.wmt?refc=' + refc;
			document.getElementById('editProfile').href='http://www.paltalk.com/people/users/'+username+'/toolbox/my_info.wmt?refc=' + refc;
			document.getElementById('profSettings').href='http://www.paltalk.com/people/users/'+username+'/toolbox/index.wmt?refc=' + refc;
			document.getElementById('createGroup').href='http://www.paltalk.com/g2/webapp/my/edit_info.wmt?refc=' + refc;
			document.getElementById('viewGroup').href='http://www.paltalk.com/g2/group/'+encodedGroupId + '?refc=' + refc;
			document.getElementById('editGroup').href = document.getElementById('editGroup').href + '?refc=' + refc;
			document.getElementById('joindGroup').href = document.getElementById('joindGroup').href + '?refc=' + refc;
			document.getElementById('logdJoindGrp').href = document.getElementById('logdJoindGrp').href + '?refc=' + refc;
			document.getElementById('logdEditGrp').href = document.getElementById('logdEditGrp').href + '?refc=' + refc;
			document.getElementById('logdNavHomeLink').href = document.getElementById('logdNavHomeLink').href + '?refc=' + refc;
			document.getElementById('logdNavExpressLink').href = '/express/?refc=' + refc;
			document.getElementById('logdNavWhatIsPaltalk').href = '/learnaboutpaltalk.shtml?refc=' + refc;
			document.getElementById('logdHearMeLink').href = 'http://www.hearme.com/?refc=' + refc;
			document.getElementById('logdNavMembers').href = document.getElementById('logdNavMembers').href + '?refc=' + refc;
			document.getElementById('logdNavBrowseMembers').href = "http://www.paltalk.com/people/webapp/index.wmt?refc=" + refc;
			document.getElementById('logdNavChatRooms').href = document.getElementById('logdNavChatRooms').href + '?refc=' + refc;
			document.getElementById('logdNavBrowseChatRooms').href = 'http://www.paltalk.com/g2/webapp/groups/GroupsPage.wmt?refc=' + refc;
			document.getElementById('logdCameoLink').href = document.getElementById('logdCameoLink').href + '?refc=' + refc;
		}
	}

}


function selectedState()
{
	var mainNavLists = document.getElementById("nav-states").getElementsByTagName("ul");
	var userNavLists = document.getElementById("userinfo-menu").getElementsByTagName("ul");
	
	for (var i=0; i<mainNavLists.length; i++) {
		
		if (mainNavLists[i].className == 'nav'){
			
			var dropDownLists = mainNavLists[i].getElementsByTagName("ul");
			for (var j=0; j<dropDownLists.length; j++) {
				
				dropDownLists[j].onmouseover=function() {
					var selectedTab = this.parentNode.firstChild;
					selectedTab.className += " tab-hover";
				}
				
				dropDownLists[j].onmouseout=function() {
					var selectedTab = this.parentNode.firstChild;
					selectedTab.className = selectedTab.className.replace(new RegExp("tab-hover\\b"), "");
				}

			}
			
		}
		
	}
	
	for (var i=0; i<userNavLists.length; i++) {

		userNavLists[i].onmouseover=function() {
			var selectedTab = this.parentNode.firstChild;
			selectedTab.className += " usermenu-selected";
		}

		userNavLists[i].onmouseout=function() {
			var selectedTab = this.parentNode.firstChild;
			selectedTab.className = selectedTab.className.replace(new RegExp("usermenu-selected\\b"), "");
		}
		
	}
}

function toggleVisibility(elem) {
	if (elem.className == "show") {
		elem.className = elem.className.replace ("show","hide");
	} else if (elem.className == "hide") {
		elem.className = elem.className.replace ("hide","show");
	}
}

function hideClass(elem) {
	if (elem.className == "show")
	elem.className = elem.className.replace ("show","hide");
} 
	
function showClass(elem) {
	if (elem.className == "hide")

	elem.className = elem.className.replace ("hide","show");
}

function setLoggedOutFlag(){
	var myDate = new Date();
	myDate.setDate(myDate.getDate()+5);
	set_cookie('userLoggedOut', 'User logged out.',myDate,'paltalk.com');
}

/*-------------- script for preloading images -------------*/
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/*-------------- script for preloading images -------------*/

/* Checks if the user is logged in or not and displays logged in or not logged state in the header */
function checkSignIn() {
	MM_preloadImages('/bb/images/features_on.png','/bb/images/download_on.png','/bb/images/faq_on.png','/bb/images/bug_report_on.png','/iphone/images/download_on.png','/iphone/images/faq_on.png','/iphone/images/bug_report_on.png','/iphone/images/features_on.png');
	
	var username =fetch_cookie('username');
	var thumbnail =fetch_cookie('thumbnail');
					
	if(thumbnail!=null){
	var thumbnail35x35 =thumbnail.replace("SQ3","SQ5");
	}
	
	var pplCookieNotification=	fetch_cookie('people_notes');
	if (pplCookieNotification == null) pplCookieNotification = 0;
	var grpCookieNotification =	fetch_cookie('grp_notes');
	if (grpCookieNotification == null) grpCookieNotification = 0;
	var hasProfile =fetch_cookie('profile');
	var hasGroup = fetch_cookie('group'); 
	var joinedGroups = fetch_cookie('groups_joined');
	
	var loggedInUser = document.getElementById("userInfoLoggedIn");
	var loggedOutUser = document.getElementById("userInfoLoggedOut");
	var loggedInNav = document.getElementById("navLoggedIn");
	var loggedOutNav = document.getElementById("navLoggedOut");
	var searchBox = document.getElementById("masthead-search");
	var formHide = document.getElementById("search-form");
	
	var usernick = document.getElementById("nickname");
	var thumb = document.getElementById("userpic");
	var logoutLink = document.getElementById("log-out");
	var profileNotification=document.getElementById("profile-notification");
	var groupNotification=document.getElementById("group-notification");


	if ( username == null || username==''){
		toggleVisibility(loggedOutNav);
		toggleVisibility(loggedOutUser);
		toggleVisibility(formHide);
		searchBox.className = searchBox.className.replace ("hide","show");
		return false;
	} else {
		toggleVisibility(loggedInNav);
		toggleVisibility(loggedInUser);
		toggleVisibility(formHide);
		searchBox.className = searchBox.className.replace ("hide","show");
		nick = document.createTextNode(username);
		if(thumbnail!=null){
		thumb.src=thumbnail35x35;	
		}else{
		thumb.src = thumbnail;
		}

		usernick.appendChild(nick);
		profileNotification.appendChild(document.createTextNode(pplCookieNotification));
		groupNotification.appendChild(document.createTextNode(grpCookieNotification));
		if(pplCookieNotification==0){
			document.getElementById("profile-notification").className="notification messages-off";	
			document.getElementById("profile-notification").href="#";
		}
		else{
			document.getElementById("profile-notification").className="notification messages-on";	
		}
		if(grpCookieNotification==0){
			document.getElementById("group-notification").className="notification messages-off";
			document.getElementById("group-notification").href="#";			
		}else{
			document.getElementById("group-notification").className="notification messages-on";	
		}
		
		
		/******code for  Menu Display*******/
		if(hasProfile=='Y'){
			
			document.getElementById('logdCreateProfile').style.display="none";
			document.getElementById('logdViewProfile').style.display="";
			document.getElementById('logdEditProfile').className="";
			
			document.getElementById('createProfile').style.display="none";
			document.getElementById('viewProfile').style.display="";
			document.getElementById('editProfile').className="";
			document.getElementById('profSettings').className="";
		}else{
			
			document.getElementById('logdCreateProfile').style.display="";
			document.getElementById('logdViewProfile').style.display="none";
			document.getElementById('logdEditProfile').className="not-available";
			document.getElementById('logdEditProfile').href="#";
			
			document.getElementById('createProfile').style.display="";
			document.getElementById('viewProfile').style.display="none";
			document.getElementById('editProfile').className="not-available";
			document.getElementById('profSettings').className="not-available";
			document.getElementById('editProfile').href="#";
			document.getElementById('profSettings').href="#";

		}
		
		if(hasGroup=='Y'){
			document.getElementById('logdCreateGrp').style.display="none";
			document.getElementById('logdViewGrp').style.display="";
			document.getElementById('logdEditGrp').className="";
			
			
			document.getElementById('createGroup').style.display="none";
			document.getElementById('viewGroup').style.display="";
			document.getElementById('editGroup').className="";
			
	
		}else if(hasGroup=='N'){
			document.getElementById('logdCreateGrp').style.display="";
			document.getElementById('logdViewGrp').style.display="none";
			document.getElementById('logdEditGrp').className="not-available";
			document.getElementById('logdEditGrp').href="#";
			

			document.getElementById('createGroup').style.display="";
			document.getElementById('viewGroup').style.display="none"
			document.getElementById('editGroup').className="not-available";
			document.getElementById('editGroup').href="#";
			
		}
		if(joinedGroups >0){
			document.getElementById('logdJoindGrp').className="";
			document.getElementById('joindGroup').className="";
		}else{
			document.getElementById('logdJoindGrp').className="not-available";
			document.getElementById('logdJoindGrp').href="#";
			document.getElementById('joindGroup').className="not-available";
			document.getElementById('joindGroup').href="#";
		}
		logoutLink.onclick = function() {
			delete_cookie('adult','paltalk.com');
			delete_cookie('adult_access','paltalk.com');
			setLoggedOutFlag();
			document.logout.submit();
		}
		return true;
	}
}
/*********************************************************/
/* Changes the search domain in the header's search */
function changeMenu(){

	domainSelect = document.getElementById('drop-arrow');

	chatSearch = document.getElementById('searchChat');

	memberSearch = document.getElementById('searchMembers');

	newsSearch = document.getElementById('searchNews');

	
	chatSearch.onclick = function () {

		document.frmMenu.searchTarget.value = 0;
		for ( var i=0; i<domainSelect.childNodes.length; i++) {
			if (domainSelect.childNodes[i].nodeType == 1 && domainSelect.childNodes[i].firstChild.nodeValue == 'Chat Rooms')
				showClass(domainSelect.childNodes[i]);
			else 
				hideClass(domainSelect.childNodes[i]);
		}
	}

	memberSearch.onclick = function () {

		document.frmMenu.searchTarget.value = 1;
		for ( var i=0; i<domainSelect.childNodes.length; i++) {
			if (domainSelect.childNodes[i].nodeType == 1 && domainSelect.childNodes[i].firstChild.nodeValue == 'Members' )
				showClass(domainSelect.childNodes[i]);
			else 
				hideClass(domainSelect.childNodes[i]);
		}
	}

	newsSearch.onclick = function () {
		document.frmMenu.searchTarget.value = 2;
		for ( var i=0; i<domainSelect.childNodes.length; i++) {
			if (domainSelect.childNodes[i].nodeType == 1 && domainSelect.childNodes[i].firstChild.nodeValue == 'Support' )
				showClass(domainSelect.childNodes[i]);
			else 
				hideClass(domainSelect.childNodes[i]);
		}
	}
}

/* Controls the search functionality in the header */
function searchSubmit(){
	var checkInput = document.getElementById('mainsearch');
	var clickDetect = document.getElementById('go');
	var submitDetect = document.frmMenu;
	checkInput.onfocus = function() { if(this.value=='Enter search term(s)') this.value=''; }
	clickDetect.onclick = function() { setSearchTarget(); }
	submitDetect.onsubmit = function() { setSearchTarget(); return false; }
}

function setSearchTarget(){
	var search_type = document.frmMenu.searchTarget.value;
	if(search_type==null || search_type==""){
		search_type=0;
	}
	var search_val = document.frmMenu.mainsearch.value;
		if(isWhitespace(search_val) || search_val=="Enter search term(s)"){
			Highlight("mainsearch");
			return;
		}else if(search_val!=null && search_val<3){
			alert("please enter minimum of 3 characters");
			return;
		}

	if ( search_type==0){					            
		document.groups_search.searchkey.value=search_val;
		document.groups_search.submit();

	}else if ( search_type==1){
		document.people_search.tag.value=search_val;
		document.people_search.submit();	
		
	}else if ( search_type==2){
		document.support_search.q.value=search_val;
		document.support_search.submit();

	}
}

// This is the amount of time (in milliseconds) that will lapse between each step in the fade
var FadeInterval = 600;

// This is where the fade will start, if you want it to be faster and start with a lighter color, make this number smaller
// It corresponds directly to the FadeSteps below
var StartFadeAt = 7;

// This is list of steps that will be used for the color to fade out
var FadeSteps = new Array();
	FadeSteps[1] = "ff";
	FadeSteps[2] = "ee";
	FadeSteps[3] = "dd";
	FadeSteps[4] = "cc";
	FadeSteps[5] = "bb";
	FadeSteps[6] = "aa";
	FadeSteps[7] = "99";

// This function is just a small wrapper to use for the oncick events of the anchors
function Highlight(target) {
	// Get the target ID from the string that was passed to the function    
	DoFade(StartFadeAt, target);
}

// This is the recursive function call that actually performs the fade
function DoFade(colorId, targetId) {
	 if (colorId >= 1) {
		document.getElementById(targetId).style.background = "#ffff" + FadeSteps[colorId];
		// If it's the last color, set it to transparent
        if (colorId==1) {
        	document.getElementById(targetId).style.background = "#fff";
		}
        colorId--;		
        // Wait a little bit and fade another shade
        setTimeout("DoFade("+colorId+",'"+targetId+"')", FadeInterval);
	}
}


/* checkOS() is a OS sniffer */
/* 
if a link's rel attribute is set to 'os-sniff' 
it sends windows users to the download page and 
mac users to the express page

if a link's rel attribute is set to 'os-sniff-auto' 
it sends windows users to the download page and initiates a download
and sends mac users to the express page 
*/
function download_sniff() {
	var jsurl="/start_chatting.shtml"
	if (navigator.appVersion.indexOf("Mac")!=-1) jsurl="/express/";
	var refc = getUrlParam('refc');
	if (isNaN(refc)) refc = "";
	if (refc == "") 
		window.location.href = jsurl;
	else
		window.location.href = jsurl + '?refc=' + refc;
}

function gotoChat(){
	var refc = getUrlParam('refc');
	if (isNaN(refc)) refc = "";
	if (refc == "") 
		document.location="/download_auto.shtml";
	else 
		document.location="/download_auto.shtml?refc=" + refc;
}

function doChat(){
    
    window.setTimeout('gotoChat()', 1000); 
    ACTION='07';
	var refc =getUrlParam('refc');
	var advc =getUrlParam('advc');
	var pagc =getUrlParam('pagc');
	var gid =getUrlParam('gid');
	
	
	if(refc!="" && isNaN(refc)) refc = "";
	if(advc!="" && isNaN(advc)) advc = "";
	if(pagc!="" && isNaN(pagc)) pagc = "";
	if(gid!="" && isNaN(gid)) gid = "";
		
	if(refc == "" && advc == "" && pagc == "" && gid == "") {
		frames['downloadframe'].location.href="http://www.paltalk.com/download/0.x/pal_install_r17721.exe";
		return;
	} else {
		// rename the download	
		var downurl = "http://www.paltalk.com/download/0.x/pal_install";

		if(advc !="" ) downurl = downurl + "_a" + advc;
		if(refc !="" ) downurl = downurl + "_r" + refc;
		if(pagc !="" ) downurl = downurl + "_p" + pagc;
		if(gid !="" ) downurl = downurl + "_g" + gid;
				
		downurl = downurl + ".exe";
	
		frames['downloadframe'].location.href=downurl;
	}
}

function download_sniff_auto () {
	var jsurl="javascript:doChat();"
	if (navigator.appVersion.indexOf("Mac")!=-1) jsurl="/express/";
	window.location.href = jsurl;
}

function checkOS() {
	var sniffer = document.getElementsByTagName('a');
	for (var i=0; i<sniffer.length; i++ ) {
		if (sniffer[i].getAttribute("rel") == "os-sniff") {
			sniffer[i].onclick = function (){ download_sniff (); }
		} 
		
		else if (sniffer[i].getAttribute("rel") == "os-sniff-auto") {
			sniffer[i].onclick = function (){ download_sniff_auto (); }
		}
	}
}

/* 
checkref() checks for refc or advc params in the url string and appends them 
to the client link 
*/
function getUrlParam(name)
{
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var tmpURL = window.location.href;
  var results = regex.exec( tmpURL );
  if( results == null )
    return "";
  else
    return results[1];
}

function checkref() {
    
    if ((document.getElementById('dlu1')!= null) || (document.getElementById('dlu2')!= null)) {
    
    	var refc =getUrlParam('refc');
    	var advc =getUrlParam('advc');
    	var pagc =getUrlParam('pagc');
    	var gid =getUrlParam('gid');
    	
    	if(refc!="" && isNaN(refc)) refc = "";
    	if(advc!="" && isNaN(advc)) advc = "";
    	if(pagc!="" && isNaN(pagc)) pagc = "";
    	if(gid!="" && isNaN(gid)) gid = "";
    		
    	if(refc == "" && advc == "" && pagc == "" && gid == "") return;
    	// rename the download	
    	var downurl = "http://www.paltalk.com/download/0.x/pal_install";
    			
        if(advc !="" ) downurl = downurl + "_a" + advc;
    	if(refc !="" ) downurl = downurl + "_r" + refc;
    	if(pagc !="" ) downurl = downurl + "_p" + pagc;
    	if(gid !="" ) downurl = downurl + "_g" + gid;
    	    			
    	downurl = downurl + ".exe";
    			
        //update the href with correct link
        if (document.getElementById('dlu1')!= null) {
            document.getElementById('dlu1').href=downurl;
        }
        if (document.getElementById('dlu2')!= null) {
            document.getElementById('dlu2').href=downurl;
        }
    }
	return;
}

/* checks rel link attribute, if it's set to external the link goes to a new window */
function newWin() {
   if (!document.getElementsByTagName) return false;
   var links = document.getElementsByTagName("a");
   
   var startQueryStringIndex = window.location.href.indexOf("?");
   var queryString = window.location.href.substring(startQueryStringIndex);
   
   for (var i=0; i<links.length; i++) {
      if (links[i].getAttribute("rel") == "external") {
         links[i].onclick = function() {
            return !window.open((this.href + queryString));
         }
      }
   }
}

var chk_loginStatus;

function isAjaxCallReq(){
	return false;
}

function getLoginUrl(){
	var url = 'http://www.paltalk.com/browse/webapp/login.wmt'
	return url;
}

function addFunc(){
	document.onmousemove = closepopup;
	//document.onkeypress= reset_interval;
	//document.onclick= reset_interval;
	if(fetch_cookie('userLoggedOut') != null){
		$.jGrowl("You are logged out of the Paltalk site.",{theme:'growl-message',speed: 'slow'});
		delete_cookie('userLoggedOut','paltalk.com');
	}
	if(fetch_cookie('postLogoutMessage') != null){
		showLogin();
	}
}
var t = Number(600000);
//t = t-30000;
function getMaxSessIdleTime(){

	return(t-30000);
}
function checkLogin() {
	var status = checkSignIn(); //alert(status);
	if (status == true) {
		//xajax_sessionstart();
		//chk_loginStatus = true;
		//timer=setInterval("showPopup()",t);
	} 
	/*if (fetch_cookie('postLogout') == 'true') {
		showLogin();
		delete_cookie('postLogout');
	}*/
}


function isUserLoggedIn() {
	
	var username = fetch_cookie('username');
	if (username != null && username != '') return true;
	return false;
}
