//Drop-in slider JSI
if(__UInotifier_type == "drop_in") {
	document.writeln("<script type=\"text/javascript\" src=\""+__UIserver+"clientsrc/invite_types/drop_in_header.js\"></script>");
}
else if(__UInotifier_type == "top_floater") {
	document.writeln("<script type=\"text/javascript\" src=\""+__UIserver+"clientsrc/invite_types/top_floater_header.js\"></script>");
}
else if(__UInotifier_type == "bottom_floater") {
	document.writeln("<script type=\"text/javascript\" src=\""+__UIserver+"clientsrc/invite_types/bottom_floater_header.js\"></script>");
}

// Initiate Chats
function launchChat(chat_session, initiate_type) {
	if(initiate_type == "invite") {
		document.invitenotify.chat_session.value = chat_session;
	        
		launchInvite();
	} else {
		window.open(__UIserver+"clientsrc/chat/chat.php?accnt_id_str="+__UI_id+"&chat_session="+chat_session+"&mynickname=visitor&ident="+cookiesession, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=465,height=335");
	}
}

function accept_invite() {
	chat_session = document.invitenotify.chat_session.value;
	window.open(__UIserver+"clientsrc/chat/chat.php?accnt_id_str="+__UI_id+"&chat_session="+chat_session+"&mynickname=visitor&ident="+cookiesession, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=465,height=335");
	
	closeInvite();
}

function supportCall() {
	// Load chat page
	window.open(__UIserver+"clientsrc/chat/request.php?accnt_id_str="+__UI_id+"&cat_id="+__UIcat_id+"&ident="+cookiesession, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=465,height=335");
}

//create cookie
function cookie_sess() {
	function getCookieVal(offset) {  
		var endstr = document.cookie.indexOf (";", offset);  
		if (endstr == -1)    
		endstr = document.cookie.length;  
		return unescape(document.cookie.substring(offset, endstr));
	}
	function getCookie(name) {  
		var arg = name + "=";  
		var alen = arg.length;  
		var clen = document.cookie.length;  
		var i = 0;  
		while (i < clen) {    
			var j = i + alen;    
			if (document.cookie.substring(i, j) == arg) return getCookieVal (j);    
			i = document.cookie.indexOf(" ", i) + 1;    
			if (i == 0) break;   
		}  
		return null;
	}
	
	var cookiesession = getCookie("UserInteract.com/"+__UI_id);
	
	return cookiesession;
}

var cookiesession = cookie_sess();

if(cookiesession != null) {
	//cookie exists and this user is a repeat within 24 hours - update expire
	var u_visit = '0';
	
	//renew expire date
	var expires = new Date();
	expires.setTime(expires.getTime() + (86400*1000));
	document.cookie = "UserInteract.com/" + __UI_id + "=" + cookiesession + "; expires = " + expires.toGMTString() + "; path= /;";
} else {
	//cookie does not exist - Unique visit
	var u_visit = '1';
	
	var ran_unrounded = Math.random()*999999999999999999;
	var cookiesession = Math.round(ran_unrounded);
	
	//set cookie to expire in 24 hours
	var expires = new Date();
	expires.setTime(expires.getTime() + (86400*1000));
	document.cookie = "UserInteract.com/" + __UI_id + "=" + cookiesession + "; expires = " + expires.toGMTString() + "; path= /;";
}

// Status Icons
function status_icon(__UI_id, __UIcat_id) {
	//call status.php
	var status_img = __UIserver+"clientsrc/status.php?accnt_id_str="+__UI_id+"&cat_id="+__UIcat_id;
	
	if(document.getElementById("status_img")) {
		document.getElementById("status_img").src = status_img;
	} else {
		//TODO: load default image
	}
	
}