﻿// custom mdk // has been lighten for size
var vspirits_chat_client = "stevemdk"; // custom mdk

function addEvent(obj, evType, fn){
 if (obj.addEventListener){
    obj.addEventListener(evType, fn, false);
    return true;
 } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
 } else {
    return false;
 }
}
function removeEvent(obj, evType, fn, useCapture){
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
}

function getViewportHeight() {
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 

	return window.undefined; 
}
function getViewportWidth() {
	var offset = 17;
	var width = null;
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
}


function getScrollTop() {
	if (self.pageYOffset) // all except Explorer
	{
		return self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		return document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		return document.body.scrollTop;
	}
}
function getScrollLeft() {
	if (self.pageXOffset) // all except Explorer
	{
		return self.pageXOffset;
	}
	else if (document.documentElement && document.documentElement.scrollLeft)
		// Explorer 6 Strict
	{
		return document.documentElement.scrollLeft;
	}
	else if (document.body) // all other Explorers
	{
		return document.body.scrollLeft;
	}
}

// Popup code
var gPopupMask = null;
var gPopupContainer = null;
var gReturnFunc;
var gPopupIsShown = false;
var gDefaultPage = "/loading.html";
var gHideSelects = false;
var gReturnVal = null;

var gTabIndexes = new Array();
// Pre-defined list of tags we want to disable/enable tabbing into
var gTabbableTags = new Array("A","BUTTON","TEXTAREA","INPUT","IFRAME");	

// If using Mozilla or Firefox, use Tab-key trap.
if (!document.all) {
	document.onkeypress = keyDownHandler;
}

/* virtual spirits */
var agentstatus;
var activepage=false;
var activeexit=false;
var activetimer=false;
var activebutton=false;
var proactiveMinTimer=30000; // custom MDK
var exitMinTimer=5000; // custom MDK
var title_param;
var referrer_param;
var url_param;
var timeInterval;
var loadTime = new Date();
var exitTime;
var chatTime;
var closeTime;
var posX = 0;
var posY = 0;
var browser;

function initAgent() {
var x = readCookie('vspirits_status');
if (x) {
	// a cookie is written if the user has been handled
	// the cookie is removed if the user has closed the chat screen and is pending
	agentstatus=x;
} else {
agentstatus="empty";
}

if (agentstatus=="-1") {
agentstatus="empty";
}

getchatparam();
var tempref=getdomain(referrer_param);
var tempurl=getdomain(url_param);
//alert(tempref+" -> "+tempurl);
	
if (agentstatus=="empty"){	
	if (tempref=="") {
		createCookie("vspirits_status","prospect",1); // write the cookie
		agentstatus="prospect";
	 } 	else {
		if (tempurl==tempref) {
		// remain empty
		} else {
			createCookie("vspirits_status","prospect",1); // write the cookie
			agentstatus="prospect";
		}
	}
}


if (agentstatus=="empty"){		
	// special demo pages
	if (tempurl.indexOf("virtualspirits.com")!=-1) {
	agentstatus="prospect";
	activepage=true;
	}
	if (tempurl.indexOf("localhost")!=-1) {
	agentstatus="prospect";
	activepage=true;
	}
}

filterpages();
filtertimeofday(); //custom mdk
setactive();

if (activeexit || activetimer || activebutton) {
	initPopup();
	if (activeexit) { initExit(); }
	if (activebutton) { showButton(); }
	if (activetimer) { setTimeout('proactivechat()',proactiveMinTimer); }
}
//alert("initPage");
}

function setactive(){
if (activepage){
	if (agentstatus=="prospect"){
		 activeexit=true; // custom mdk
		 activetimer=false; // custom mdk
		 activebutton=false; // custom mdk
	}
	if (agentstatus=="pending"){
		 activeexit=false;
		 activetimer=false;
		 activebutton=false; // custom mdk
	}
	if (agentstatus=="handled"){
		 activeexit=false;
		 activetimer=false;
		 activebutton=false;
		}
	if (agentstatus=="closed"){
		 activeexit=false;
		 activetimer=false;
		 activebutton=false;
	}
} else {
	activeexit=false;
	activetimer=false;
	activebutton=false;
	}
}

function initPopup(){
	// Add the HTML to the body
	theBody = document.getElementsByTagName('BODY')[0];
	popmask = document.createElement('div');
	popmask.id = 'popupMask';
	popcont = document.createElement('div');
	popcont.id = 'popupContainer';
	popcont.innerHTML = '' +
		'<div id="popupInner">' +
			'<div id="popupTitleBar">' +
				'<div id="popupTitle"></div>' +
				'<div id="popupControls">' +
					'<img src="http://www.virtualspirits.com/vsa/images/close-mdk.png" onclick="setPending();hidePopWin(false);" id="popCloseBox" />' +
				'</div>' +
			'</div>' +
			'<div id="proactive"></div>' +
		'</div>';
		
	popbutton = document.createElement('div');
	popbutton.id = 'popupButton';	
	popbutton.innerHTML = '<div id="openButton" align="right" style="border:0px solid #000000;position: fixed; bottom: 5px;  left: 10px; _left: 10px; _position:absolute;  _top:expression(document.body.scrollTop+document.body.clientHeight-this.clientHeight-5);direction:ltr;">&nbsp;</div>';
		
	theBody.appendChild(popmask);
	theBody.appendChild(popcont);
	theBody.appendChild(popbutton);
	
	gPopupMask = document.getElementById("popupMask");
	gPopupContainer = document.getElementById("popupContainer");
	
	// check to see if this is IE version 6 or lower. hide select boxes if so
	// maybe they'll fix this in version 7?
	var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
	if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {
		gHideSelects = true;
	}
//alert("initPopup");
}

getbrowser();
addEvent(window, "load", initAgent);

function initExit(){
document.onmousemove = function(evt) {
if (typeof evt == 'undefined') {
myEvent = window.event; } 
else {
myEvent = evt; }

if (browser=="MSIE"){
posX = myEvent.clientX;
posY = myEvent.clientY; 
}
if (browser=="FF" || browser=="other"){
posX = myEvent.pageX-window.pageXOffset;
posY = myEvent.pageY-window.pageYOffset;
}

// first attempt
if(posY < 15) { 
//alert("mouse" +posY);
exitchat(); }
}
}

function exitchat(){
	if (activeexit==true) {
	exitTime = new Date();
	timeInterval=exitTime-loadTime;
	if (timeInterval>exitMinTimer){
	//call your logout page
	activeexit=false;
	startchat("exit");
	if(confirm('נציג החנות ממתין לתת לך מידע נוסף והצעה')){
		//continue
		}
	else { 
	setPending();
	hidePopWin(false);
		}
	}
	}
}

function proactivechat(){
if (activetimer==true) {
	startchat("timer");
	}
}

function buttonchat(){
	startchat("button");
}


function setPending(){
closeTime = new Date();
timeInterval=closeTime-chatTime;
if (timeInterval<45000){
// time interval too short for real interaction, follow this visitor
createCookie("vspirits_status","pending",1); // write the cookie
agentstatus="pending";
setactive();
if (activebutton) { showButton(); } // fixed condition for mdk
}
}

function setClosed(){
hideButton(); // hide the button chat
createCookie("vspirits_status","closed",1); // write the cookie
agentstatus="closed";
setactive();
}

function showButton(){
// custom mdk
var buttonstr;
buttonstr = '' +
		'<a href="#" onclick="buttonchat();return false;"><img src="http://www.virtualspirits.com/vsa/images/chat-combi-' + vspirits_chat_client + '.jpg" border="0" /></a>' +
		'<span style="border:0px solid #000000;position: absolute; top:0px; right:0px; width: 30px; height: 30px;"><a href="#" onclick="setClosed();return false;" style="text-decoration:none">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></span>' +
		'<span style="position: absolute; top:125px; _top:130px; left:35px;">' +
		'<img border="0" align="absmiddle" alt="" src="http://www.virtualspirits.com/vsa/images/blink.gif" /> ' +
		'<img border="0" align="absmiddle" alt="" src="http://www.virtualspirits.com/vsa/images/button-text.gif" />' +
		'</span>';

document.getElementById("openButton").innerHTML = buttonstr;
}

function hideButton(){
document.getElementById("openButton").innerHTML = "&nbsp;";
}

function getchatparam(){
title_param = encodeURI(document.title);
referrer_param = document.referrer;
url_param=location.href;
url_param=url_param.toLowerCase();
}

function filterpages(){
tempstr=url_param.replace("http://","");
tempstr=tempstr.replace("www.","");

var m=0;

// agent: steve mdk
// categories
// mdk.co.il/category/video_camera
// mdk.co.il/category/jvc_video_cameras
// mdk.co.il/category/panasonic_video_cameras
// mdk.co.il/category/sony_video_cameras
// mdk.co.il/category/samsung_video_cameras
// mdk.co.il/category/canon_video_cameras
// products
if (tempstr=="mdk.co.il/item/sony_dcr_sx30e") { m=1;}
if (tempstr.indexOf("itemid={d427a1e6-238b-4bd2-ba84-752b2f40e1dd}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/jvc_everio_gz-hd500") { m=1;}
if (tempstr.indexOf("itemid={f7d97a47-91b9-4c07-9380-6f4f95dd2046}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/canon_fs200") { m=1;}
if (tempstr.indexOf("itemid={e267fb53-e1b1-4965-b9ac-4be21fb6b062}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/jvc_everio_gz_ms120") { m=1;}
if (tempstr.indexOf("itemid={3abd740a-ebc8-4318-b6fa-ec20a4d9f8ad}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/samsung_smx_k44") { m=1;}
if (tempstr.indexOf("itemid={8da088dd-e326-4cc4-88fe-d3585060afc1}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/samsung_smx_f44") { m=1;}
if (tempstr.indexOf("itemid={8fdd8edb-5282-4c4a-9b79-d2822445e37a}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/sony_hdr_cx105e") { m=1;}
if (tempstr.indexOf("itemid={00563f30-7f0a-48de-af52-68b7a6f7346d}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/sony_hdr_xr550e") { m=1;}
if (tempstr.indexOf("itemid={d066c5c4-6179-461a-a225-20a9e3b77b51}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/panasonic_sdr-h90") { m=1;}
if (tempstr.indexOf("itemid={dc774a61-8eef-4b5c-b369-517f3aa51d91}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/sony_hdr_xr150e") { m=1;}
if (tempstr.indexOf("itemid={bcfefc4a-2d1a-411d-9efa-e876e0073214}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/samsung_hmx_h104") { m=1;}
if (tempstr.indexOf("itemid={9faab9aa-b3b9-4f36-896f-3bb7655c7e21}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/panasonic_sdr_s50") { m=1;}
if (tempstr.indexOf("itemid={2cebad7e-759c-42d2-897d-c01f70005627}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/sony_hdr_cx115e") { m=1;}
if (tempstr.indexOf("itemid={920239b8-ddad-41bb-90d5-640a7d21f33c}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/jvc_everio_gz-hm300") { m=1;}
if (tempstr.indexOf("itemid={1c0f59a6-49df-45f2-87a5-eaf8821fbb66}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/jvc_everio_gz_ms110") { m=1;}
if (tempstr.indexOf("itemid={babd61a3-1c4e-471d-a5ae-52e5752cd006}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/jvc_everio_gz-hd10") { m=1;}
if (tempstr.indexOf("itemid={93f39f81-0d94-4e8b-890a-ed3874f02fe8}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/jvc_everio_gz-hd30") { m=1;}
if (tempstr.indexOf("itemid={5d5ce0d1-957e-444e-9e77-a545b07a9a81}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/jvc_everio_gz-hm200") { m=1;}
if (tempstr.indexOf("itemid={b1468d95-20bf-4ead-ac01-213014290edf}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/panasonic_sdr_s15") { m=1;}
if (tempstr.indexOf("itemid={70cc10b2-ef25-45ba-88fe-e2578c77a8a2}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/panasonic_hdc_hs200") { m=1;}
if (tempstr.indexOf("itemid={0edd24f9-c0f8-4bcd-af49-ac004eb14af1}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/panasonic_ag-hvx200") { m=1;}
if (tempstr.indexOf("itemid={fe571580-8ec1-4efd-ab4a-b8313add9992}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/panasonic_nv-md10000") { m=1;}
if (tempstr.indexOf("itemid={8357bf35-afff-4972-a32c-c4bc69553725}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/hvr-hd1000") { m=1;}
if (tempstr.indexOf("itemid={a39b4de9-8727-4ed6-80e4-16968994cdbe}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/sony_dcr_sx33e") { m=1;}
if (tempstr.indexOf("itemid={9dea6cb4-ca2d-490c-83c4-bf62c644a679}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/sony_hdr_xr155e") { m=1;}
if (tempstr.indexOf("itemid={ca26904d-c5c4-49bc-81e2-78da36b389f0}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/sony_dcr-sr57e") { m=1;}
if (tempstr.indexOf("itemid={e56f6118-c2c1-40aa-b6a9-89b69a7384b2}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/sony_dcr-sr87e") { m=1;}
if (tempstr.indexOf("itemid={a781b283-aaec-4867-8d8c-015c578f5875}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/sony_hdr-xr500e") { m=1;}
if (tempstr.indexOf("itemid={61bc48aa-822c-41db-abb4-37207290a6bd}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/sony_dcr_sr47e") { m=1;}
if (tempstr.indexOf("itemid={3ffd8ce0-83d7-4185-bc6c-4e33821c7334}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/sony_hdr_xr520e") { m=1;}
if (tempstr.indexOf("itemid={57911b43-a7cb-4c72-96dd-23854e1ce616}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/sony_hdr_cx100e") { m=1;}
if (tempstr.indexOf("itemid={a4f86e87-9adc-41fa-91c4-01cbad96525c}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/sony_hdr-xr500ve_gps") { m=1;}
if (tempstr.indexOf("itemid={04165197-3767-460f-af3f-09a4ca80a98b}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/samsung_smx_f33") { m=1;}
if (tempstr.indexOf("itemid={0092198e-c264-44c6-bae7-a0195f991e62}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/samsung_hmx_h200") { m=1;}
if (tempstr.indexOf("itemid={d7839d6a-d4af-46ba-9226-95c9aafcc6d2}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/canon_fs305") { m=1;}
if (tempstr.indexOf("itemid={0b7f770e-1c03-40a4-85e0-21b541a10b76}")!=-1) { m=1;}

// categories
// mdk.co.il/category/pro_video_cam
// products
if (tempstr=="mdk.co.il/item/panasonic_nv-md10000") { m=1;}
if (tempstr.indexOf("itemid={8357bf35-afff-4972-a32c-c4bc69553725}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/hvr-hd1000") { m=1;}
if (tempstr.indexOf("itemid={a39b4de9-8727-4ed6-80e4-16968994cdbe}")!=-1) { m=1;}
if (tempstr=="mdk.co.il/item/panasonic_ag-hvx200") { m=1;}
if (tempstr.indexOf("itemid={fe571580-8ec1-4efd-ab4a-b8313add9992}")!=-1) { m=1;}

// agent: david mdk
// categories
// mdk.co.il/category/dslr_cameras1
// mdk.co.il/category/slr_nikon
// mdk.co.il/category/slr_canon
// mdk.co.il/category/slr_panasonic
// products
if (tempstr=="mdk.co.il/item/nikon_d90_body") { m=2;}
if (tempstr.indexOf("itemid={019850f1-025b-4937-8ad5-2f92e01bb4c3}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_500d_18-55_is") { m=2;}
if (tempstr.indexOf("itemid={b8ab3c76-7aa9-4914-8461-75d696ca8b6b}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/nikon_d5000_body") { m=2;}
if (tempstr.indexOf("itemid={7c558b5f-5938-4980-8613-6a405a01c412}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_450d_body") { m=2;}
if (tempstr.indexOf("itemid={9a00f755-b52f-42fb-8da3-f1dcf716f2bb}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_550d_18-55") { m=2;}
if (tempstr.indexOf("itemid={50ee259e-4ff5-4341-8758-cf4a24f6b084}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_7d_body") { m=2;}
if (tempstr.indexOf("itemid={20bafc85-465d-47ab-ad71-fc8e059dca9a}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/nikon_d90__18-200_vr") { m=2;}
if (tempstr.indexOf("itemid={3b4a48c6-a2e3-4c21-802c-0a67d412c29a}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/nikon_d90_18-105_vr") { m=2;}
if (tempstr.indexOf("itemid={7dc4e236-98d5-4652-9d7e-8103a6ee9b2f}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_500d_body") { m=2;}
if (tempstr.indexOf("itemid={2c982899-ac07-4e10-8266-09dcbf5650ce}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_500d_18-200_is") { m=2;}
if (tempstr.indexOf("itemid={22d3c90a-c44f-4940-a72a-6c3bb6243b98}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/nikon_d5000_18-55") { m=2;}
if (tempstr.indexOf("itemid={98c03071-2212-4e8e-82f7-583d38d4bbc8}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/nikon_d5000_18-105vr") { m=2;}
if (tempstr.indexOf("itemid={320ac719-8b4a-4e3d-bf39-bc1897bb3320}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/nikon_d5000_18-200vr") { m=2;}
if (tempstr.indexOf("itemid={88c659fa-ea98-4f30-ba80-22f71f8df89e}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_450d_17_85_is") { m=2;}
if (tempstr.indexOf("itemid={17ea5c1a-c445-4ce1-a47c-6e8baf45a33d}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_450d_18_200_is") { m=2;}
if (tempstr.indexOf("itemid={601ade69-c6a6-4383-bc44-a6c07d286469}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_450d_2_lenses") { m=2;}
if (tempstr.indexOf("itemid={bebfd4d2-a58a-4b21-8490-c84086bee5a6}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_450d_18-55_is") { m=2;}
if (tempstr.indexOf("itemid={a802482e-ca94-4998-8aa3-85dfa4c8cf09}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_7d_15-85") { m=2;}
if (tempstr.indexOf("itemid={4b5481bb-afe2-4ed9-acce-0a7951991c27}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_7d_18-135") { m=2;}
if (tempstr.indexOf("itemid={99665354-31f1-4760-b56b-245a1ff8fd8c}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_550d_body") { m=2;}
if (tempstr.indexOf("itemid={c4a47638-956e-474d-b74f-e46decd45aed}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_500d_17-85_is") { m=2;}
if (tempstr.indexOf("itemid={b4814411-957a-4485-8797-9e098868055a}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/nikon_d300s_body") { m=2;}
if (tempstr.indexOf("itemid={4eae4809-7f6c-42eb-93b9-9b2e64e11c50}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/nikon_d700_body") { m=2;}
if (tempstr.indexOf("itemid={3968ecc1-9a83-41ed-b95b-22685fdf8104}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/nikon_d3000_body") { m=2;}
if (tempstr.indexOf("itemid={d9b79896-66eb-474f-8fda-8ee5bcad35bc}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/nikon_d300s_18-200vr") { m=2;}
if (tempstr.indexOf("itemid={ac9783e4-1292-481d-8ade-d0aa30381f2a}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/nikon_d300s_18-105vr") { m=2;}
if (tempstr.indexOf("itemid={f73b2165-cb31-4501-91cc-db76f7131bfb}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/nikon_d300s_16-85vr") { m=2;}
if (tempstr.indexOf("itemid={0a6190b7-8e0c-4189-8811-4fc9dd8ef187}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/nikon_d700_24-120vr") { m=2;}
if (tempstr.indexOf("itemid={efac3b29-1781-4499-831d-6a2457ab7703}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/nikon_d3000_18_55_vr") { m=2;}
if (tempstr.indexOf("itemid={8f42a490-f014-45d3-a417-bcd6d51e7457}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/nikon_d3000_18_105_vr") { m=2;}
if (tempstr.indexOf("itemid={1613b406-64ce-4b8b-8ba1-d14337763d32}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_5d_mark_ii_body") { m=2;}
if (tempstr.indexOf("itemid={b0a9d9c7-ef6f-445c-8e3d-0c44e81a1f6f}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_5d_mark_ii_24-105") { m=2;}
if (tempstr.indexOf("itemid={4e4ef09f-f45e-459f-b03d-dee8bbfc00e7}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_550d_18_200") { m=2;}
if (tempstr.indexOf("itemid={2a933a8a-019f-45f2-b09f-4aefeab2a8e2}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_50d_body_eos-50d") { m=2;}
if (tempstr.indexOf("itemid={33b2dd1a-d318-4f68-a79e-36f65b451ebd}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_50d_18_200_is") { m=2;}
if (tempstr.indexOf("itemid={9ad67607-b4bc-4f50-b820-dfbb0241c2ba}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_50d_17_85_is") { m=2;}
if (tempstr.indexOf("itemid={3240fce7-9428-4116-8c57-f69978093a07}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/canon_eos_50d_28_135_is") { m=2;}
if (tempstr.indexOf("itemid={60e1efc8-b1de-4f5a-9a5f-c1ec00ca7827}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/panasonic_lumix_dmc_gf1_14_45_ois") { m=2;}
if (tempstr.indexOf("itemid={7e4534f9-7bac-4901-8cc1-927bd0f00d2c}")!=-1) { m=2;}
if (tempstr=="mdk.co.il/item/panasonic_lumix_dmc_g1_14_45_ois") { m=2;}
if (tempstr.indexOf("itemid={6fcbbd2b-e55f-4fa2-ac00-bac2147dc9c6}")!=-1) { m=2;}

// agent: gadi mdk
// categories
// mdk.co.il/category/digital_camera_lenses
// mdk.co.il/category/lens_for_nikon
// mdk.co.il/category/lens_for_canon
// mdk.co.il/category/lens_sigma
// mdk.co.il/category/tamron_lenses
// products - only the first 100lines

if (tempstr=="mdk.co.il/item/nikon_af_s_dx_18_105mm_vr") { m=3;}
if (tempstr.indexOf("itemid={54041795-253b-4764-990e-b7fac2079c86}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_24_105mm_f_4l_is") { m=3;}
if (tempstr.indexOf("itemid={2f624e08-59f0-4589-bad7-963e3313d894}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/tamron_17_50_f_2_8_nik") { m=3;}
if (tempstr.indexOf("itemid={a0c0a1d4-f1b7-48d8-b5c8-16f06fa48a72}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/nikon_af_s_vr_70_300mm") { m=3;}
if (tempstr.indexOf("itemid={3f24b4e3-661b-4bde-9509-15ef154cd1d0}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_s_55_250mm_is") { m=3;}
if (tempstr.indexOf("itemid={fd040ac5-d51a-4e8a-819d-530a6578e0e1}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/nikon_af_s_dx_vr_18_200mm") { m=3;}
if (tempstr.indexOf("itemid={029b38ec-0e7d-4efc-93b3-2890dffcf6ea}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_s_18_135_is") { m=3;}
if (tempstr.indexOf("itemid={8db75630-59b4-44e2-8b60-ef50c9115625}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_24_70_f_2_8l") { m=3;}
if (tempstr.indexOf("itemid={8339038d-cabc-402c-bc6b-d9a98bc4ac0f}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_s_18_200mm_is") { m=3;}
if (tempstr.indexOf("itemid={96199d23-4a4c-42eb-9afe-1a07bd570ce0}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_50mm_f_1_4_usm") { m=3;}
if (tempstr.indexOf("itemid={93298ac1-6773-4918-945d-89dfb753557c}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/nikon_af_50mm_f_1_4d") { m=3;}
if (tempstr.indexOf("itemid={3038b96c-a597-43c5-8946-7a2d915d3af6}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_70_300mm_apo_can") { m=3;}
if (tempstr.indexOf("itemid={d620fb1c-8628-4879-9865-acc4da6691ae}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/nikon_af_s_dx_18_135mm") { m=3;}
if (tempstr.indexOf("itemid={b07ef87b-bac2-47c2-9b5e-c089f7ea345c}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/nikon_af_s_dx_55_200mm_vr") { m=3;}
if (tempstr.indexOf("itemid={ee8710ad-2255-439d-8b00-54311e4fd3e7}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/nikon_28_200mm_af_d") { m=3;}
if (tempstr.indexOf("itemid={7089a04b-68c7-4d98-aeef-5e3902cbb6ac}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/nikon_af_s_16_85mm_vr") { m=3;}
if (tempstr.indexOf("itemid={d31a02bf-c149-480f-9a0c-bda70739d063}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/nikon_af_s_24_120mm_vr") { m=3;}
if (tempstr.indexOf("itemid={f7b7051a-d233-4ce2-8b15-37e39bafc7ec}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/nikon_af_60mm_f2_8d_micro") { m=3;}
if (tempstr.indexOf("itemid={60c5aa10-7993-4fdb-9381-4f73503a0227}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/nikon_af_s_17_55mm_f_2_8g") { m=3;}
if (tempstr.indexOf("itemid={9066644e-dc21-494e-b722-79a29b4805ea}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/nikon_af_s_24_70mm_f_2_8g") { m=3;}
if (tempstr.indexOf("itemid={b7008a52-bd3f-4a2a-a048-da7940158bf2}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_s_15_85mm_is") { m=3;}
if (tempstr.indexOf("itemid={fb94182f-d391-4047-a580-6c24069c162e}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_s_17_85mm_is_usm") { m=3;}
if (tempstr.indexOf("itemid={1089ab87-c3be-456f-86c1-82b20b1a8105}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_100_f_2_8_macro") { m=3;}
if (tempstr.indexOf("itemid={eac55678-37e5-4e50-b54f-2a393e0e22fb}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_70_300mm_is_usm") { m=3;}
if (tempstr.indexOf("itemid={d158cb6b-528c-4576-bf65-c22ea71ddbbb}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_28_135_is") { m=3;}
if (tempstr.indexOf("itemid={a5346271-67c4-4ce3-a330-155346c17b86}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_17_40mm_f_4l_usm") { m=3;}
if (tempstr.indexOf("itemid={65c47027-072e-41b8-969c-171950b49bb4}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_100_400mm_is_usm") { m=3;}
if (tempstr.indexOf("itemid={c07cb1ff-5935-4d10-b811-ab063394e998}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/anon_ef_s_10_22mm_usm") { m=3;}
if (tempstr.indexOf("itemid={ae718c61-7f3a-4562-8942-64ee7f473d0c}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_28_300mm_is_usm") { m=3;}
if (tempstr.indexOf("itemid={f10faa6e-1b45-4e7d-a765-2bf99ea24df3}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_16_35_f_2_8l_ii") { m=3;}
if (tempstr.indexOf("itemid={08ffab12-d9f7-4d27-a294-04ca07820d4f}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_s_60_f_2_8_macro") { m=3;}
if (tempstr.indexOf("itemid={a6804acc-834e-4cf2-8585-a7d7f18bc40e}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_70_200mm_f_4l_is") { m=3;}
if (tempstr.indexOf("itemid={90364d0d-8066-43dc-b943-272b05f6494f}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_70_200_f_4l_usm") { m=3;}
if (tempstr.indexOf("itemid={4ded6c8c-63f6-4ac6-be23-f5a72a197cf0}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/canon_ef_s_17_55_f_2_8_is") { m=3;}
if (tempstr.indexOf("itemid={62134d41-2d83-4b9b-a001-d71d33466440}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_18_200_dc_os_can1") { m=3;}
if (tempstr.indexOf("itemid={d72cf692-f8c7-4013-9dc8-51d5c1e50e7a}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_18_200_dc_os_nik1") { m=3;}
if (tempstr.indexOf("itemid={9966b8ed-e6af-4e6d-aea6-41cbce1ec473}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_18_200mm_dc_can1") { m=3;}
if (tempstr.indexOf("itemid={9a58c4a0-9cc4-4f64-96fe-15ff7c50c2cd}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_18_200mm_dc_nik1") { m=3;}
if (tempstr.indexOf("itemid={f037b75d-31f3-4b60-a0c3-81a330bfd462}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_10_20mm_hsm_can1") { m=3;}
if (tempstr.indexOf("itemid={fea3c2e0-1096-4198-9228-05e549ecd112}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_10_20mm_f35_can") { m=3;}
if (tempstr.indexOf("itemid={f1b56d88-42ec-4a7a-92a2-211847338451}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_10_20mm_hsm_nik1") { m=3;}
if (tempstr.indexOf("itemid={869a009e-d878-4849-a302-9b7e03ae67c6}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_70_300mm_apo_nik1") { m=3;}
if (tempstr.indexOf("itemid={85732b22-a6d8-4470-9a32-e6d0c9b96bf7}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_18_250_dc_os_can1") { m=3;}
if (tempstr.indexOf("itemid={909d1b99-1b78-4e7b-9dd6-9aa0c81a111e}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_18_250_dc_os_nik1") { m=3;}
if (tempstr.indexOf("itemid={3b0f781b-7dfd-47bd-9a4d-f80372dc0426}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_70_300mm_apo_can1") { m=3;}
if (tempstr.indexOf("itemid={8a35dc48-9e6b-4d9e-a0b7-3bf352bf4125}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_70_300mm_apo_nik") { m=3;}
if (tempstr.indexOf("itemid={5b496c32-8cc1-4ea6-a1d6-870bb9ed0c64}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_70_300mm_os_can1") { m=3;}
if (tempstr.indexOf("itemid={f8d1b5d4-5ddd-4eda-95f3-9dea779f683f}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_70_300mm_os_nik1") { m=3;}
if (tempstr.indexOf("itemid={8161e155-c86b-48de-9d09-b603b80f7f87}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_70_300mm_os_can") { m=3;}
if (tempstr.indexOf("itemid={cce78f94-6b45-4b41-9989-a04bca5b7020}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_70_300mm_os_nik") { m=3;}
if (tempstr.indexOf("itemid={6c37d113-3c66-49c3-8274-76071b9eca0c}")!=-1) { m=3;}
if (tempstr=="mdk.co.il/item/sigma_70_200mm_apo_hsm_can") { m=3;}
if (tempstr.indexOf("itemid={98da17c1-fd5f-41b8-add5-e25884d1e33c}")!=-1) { m=3;}


// agent: dani mdk
// categories
// mdk.co.il/category/digital_cameras
// mdk.co.il/category/canon
// mdk.co.il/category/nikon
// mdk.co.il/category/olympus
// mdk.co.il/category/panasonic
// mdk.co.il/category/fujifilm
// mdk.co.il/category/sony
// mdk.co.il/category/kodak
// mdk.co.il/category/samsung
// products
if (tempstr=="mdk.co.il/item/canon_powershot_sx20_is") { m=4;}
if (tempstr.indexOf("itemid={10b45ee9-cd50-4490-bda7-0214e4c570a1}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/panasonic_lumix_dmc_fz35") { m=4;}
if (tempstr.indexOf("itemid={77104006-6140-4966-aea0-556e2a2d2b38}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/canon_powershot_sx210_is") { m=4;}
if (tempstr.indexOf("itemid={ca8ae9b3-4496-4435-bd4b-ab21462a92ed}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/canon_powershot_sx200_is") { m=4;}
if (tempstr.indexOf("itemid={b55dc319-f875-4ed0-bd57-7ab36e050a4e}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/panasonic_dmc_tz10_zs7") { m=4;}
if (tempstr.indexOf("itemid={24dfe674-7daf-4b09-b41b-48541ccd13af}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/panasonic_dmc_tz7_zs3") { m=4;}
if (tempstr.indexOf("itemid={c546f4cd-eb15-47bb-b64f-05b53fcb5a8a}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/fuji_finepix_hs10") { m=4;}
if (tempstr.indexOf("itemid={a4d4d3f7-0313-4716-bf84-ff9dfe1a86ef}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/nikon_coolpix_p100") { m=4;}
if (tempstr.indexOf("itemid={5a0a2df4-f5f8-4034-8190-ecdd26a45cda}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/canon_ixus_200_is_sd980") { m=4;}
if (tempstr.indexOf("itemid={5d474ff3-78e6-4084-a6fc-df94da8e790f}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/canon_ixus_130_is_sd1400") { m=4;}
if (tempstr.indexOf("itemid={e4a474e7-ab0c-42de-9d30-16c54d480b96}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/canon_powershot_a2100_is") { m=4;}
if (tempstr.indexOf("itemid={ee80f29f-6299-4759-845c-5fd8701306b7}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/canon_powershot_s90") { m=4;}
if (tempstr.indexOf("itemid={1637e4cb-10cf-4ad2-9476-d8b19d87932e}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/canon_powershot_g11") { m=4;}
if (tempstr.indexOf("itemid={c05cb626-85d2-41fb-b6a3-65ee50f894c1}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/canon_ixus_120_is_sd940") { m=4;}
if (tempstr.indexOf("itemid={443b4ca0-1203-4047-9fb5-e38eedfa7e5f}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/canon_ixus_210_is_sd3500") { m=4;}
if (tempstr.indexOf("itemid={63acc230-8f9b-4228-82a3-95a93066fefd}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/nikon_coolpix_l110") { m=4;}
if (tempstr.indexOf("itemid={84efb0a8-932b-4713-bebf-9a066579f1a6}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/nikon_coolpix_s60") { m=4;}
if (tempstr.indexOf("itemid={63bf25eb-6bae-46ab-944b-8f546c3cd177}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/nikon_coolpix_s8000") { m=4;}
if (tempstr.indexOf("itemid={b9b1f1e4-8325-4181-8063-cee881427132}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/nikon_coolpix_s1000pj") { m=4;}
if (tempstr.indexOf("itemid={e3b01c89-f74c-40a4-bbc5-74d5d8ab858c}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/olympus_sp_600uz") { m=4;}
if (tempstr.indexOf("itemid={00bd4ccf-2833-4ed7-ae57-f0093c43f33d}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/olympus_sp_800uz") { m=4;}
if (tempstr.indexOf("itemid={b891fe3e-89a0-4dee-964e-f4e878c7f908}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/olympus_mju_9000") { m=4;}
if (tempstr.indexOf("itemid={88e2757f-7c42-4d65-9bc7-ce0eca67bfe8}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/panasonic_lumix_dmc_lx3") { m=4;}
if (tempstr.indexOf("itemid={b57b5dce-a411-4a85-99b8-eb41637b1da8}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/panasonic_lumix_dmc_fp8") { m=4;}
if (tempstr.indexOf("itemid={6fb707f1-6ef3-4fd9-834d-2f98dd2586eb}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/panasonic_lumix_dmc_gf1_14_45_ois") { m=4;}
if (tempstr.indexOf("itemid={7e4534f9-7bac-4901-8cc1-927bd0f00d2c}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/panasonic_lumix_dmc_g1_14_45_ois") { m=4;}
if (tempstr.indexOf("itemid={6fcbbd2b-e55f-4fa2-ac00-bac2147dc9c6}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/panasonic_dmc_tz8_zs5") { m=4;}
if (tempstr.indexOf("itemid={9d892e0f-c4bc-4f90-a69e-7ce5725a6b44}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/fuji_finepix_s2500hd") { m=4;}
if (tempstr.indexOf("itemid={262007da-1fa1-4d1d-830d-502b72f7eb72}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/fuji_finepix_f200exr") { m=4;}
if (tempstr.indexOf("itemid={f1a21148-8650-430c-91fc-4af0ef0daaf0}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/fuji_finepix_f80exr") { m=4;}
if (tempstr.indexOf("itemid={b4ef93fd-c0c3-430d-9dc2-d9c3bb2cfe19}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/fuji_finepix_jz300") { m=4;}
if (tempstr.indexOf("itemid={cc20611b-338c-4b29-8ced-7f44be27ded9}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/sony_cybershot_dsc_tx1") { m=4;}
if (tempstr.indexOf("itemid={e28a1613-e34b-4fff-be6f-63c18edc9a60}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/sony_cybershot_dsc_t90") { m=4;}
if (tempstr.indexOf("itemid={6dd35eb2-761b-4b99-a075-df29772fd699}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/sony_cybershot_dsc_hx1") { m=4;}
if (tempstr.indexOf("itemid={3ca3e26d-b1f3-46c2-a08f-04b03887df36}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/sony_cybershot_dsc_tx7") { m=4;}
if (tempstr.indexOf("itemid={09b75d49-49da-44d7-a57e-17ce6bbae731}")!=-1) { m=4;}
if (tempstr=="mdk.co.il/item/samsung_hz10w_/_wb500") { m=4;}
if (tempstr.indexOf("itemid={dc5c83e8-e808-4c56-a672-89b939201325}")!=-1) { m=4;}


if (m==1){
activepage=true; 
vspirits_chat_client = "stevemdk";
} 

if (m==2){
activepage=true; 
vspirits_chat_client = "danimdk";
} 

if (m==3){
activepage=true; 
vspirits_chat_client = "gadimdk";
} 

if (m==4){
activepage=true; 
vspirits_chat_client = "davidmdk";
} 


}


function getdomain(url){
if (url!=""){ 
	url=url.split(/\/+/g)[1];
	}
return url;
}

function startchat(launcher){
chatTime = new Date();
timeInterval=chatTime-loadTime;
try {
hideButton(); // hide the button chat
createCookie("vspirits_status","handled",1); // write the cookie
agentstatus="handled";
setactive();
if (launcher=="exit"){
// exit chat
showPopWin("http://www.virtualspirits.com/vsa/"+vspirits_chat_client+"vsahebrew.aspx?launcher="+launcher+"&launchertime="+timeInterval+"&referrer="+referrer_param+"&title="+title_param, 500, 450, null, true);
} else {
// timed chat
showPopWin("http://www.virtualspirits.com/vsa/"+vspirits_chat_client+"vsahebrew.aspx?launcher="+launcher+"&launchertime="+timeInterval+"&referrer="+referrer_param+"&title="+title_param, 500, 450, null, false);
}
} catch (e) {
// nothing
//alert(e);
}	
}


 /**
	* @argument width - int in pixels
	* @argument height - int in pixels
	* @argument url - url to display
	* @argument returnFunc - function to call when returning true from the window.
	* @argument showOverlay - show the body overlay
		*/
function showPopWin(url, width, height, returnFunc, showOverlay) {
	// show or hide the window close widget
	document.getElementById("popCloseBox").style.display = "none";
	
	gPopupIsShown = true;
	disableTabIndexes();
	
	if (showOverlay) {
	gPopupMask.style.display = "block";
	}
	
	gPopupContainer.style.display = "block";
	// calculate where to place the window on screen
	centerPopWin(width, height);
	setMaskSize();
	document.getElementById("proactive").innerHTML = "<iframe src="+ url + " style=\"width:1;height:1;background-color:transparent;\" scrolling=\"no\" frameborder=\"0\"  id='iframeContent' name='iframeContent"+Math.round(Math.random()*1000)+"' allowtransparency=\"true\" id=\"popupFrame\" name=\"popupFrame\" width='1' height='1' onload='custom_showIframe();'></iframe>"
	
	// for IE
	if (gHideSelects == true) {
		hideSelectBoxes();
	}

}

//
var gi = 0;
function centerPopWin(width, height) {
	if (gPopupIsShown == true) {
		if (width == null || isNaN(width)) {
			width = gPopupContainer.offsetWidth;
		}
		if (height == null) {
			height = gPopupContainer.offsetHeight;
		}
		
		//var theBody = document.documentElement;
		var theBody = document.getElementsByTagName("BODY")[0];
		//theBody.style.overflow = "hidden";
		var scTop = parseInt(getScrollTop(),10);
		var scLeft = parseInt(theBody.scrollLeft,10);
	
		setMaskSize();
		
		//window.status = gPopupMask.style.top + " " + gPopupMask.style.left + " " + gi++;
		
		var titleBarHeight = parseInt(document.getElementById("popupTitleBar").offsetHeight, 10);
		
		var fullHeight = getViewportHeight();
		var fullWidth = getViewportWidth();
		
		
		// center of page but top of client never above page, in order to always be able to close it
		var toptemp = scTop + ((fullHeight - (height+titleBarHeight)) / 2);
		if (toptemp<scTop) {toptemp=scTop;}
		gPopupContainer.style.top = toptemp + "px";
		gPopupContainer.style.left =  (scLeft + ((fullWidth - width) / 2)) + "px";
				
		// top left
		//gPopupContainer.style.top = (scTop + 10) + "px";
		//gPopupContainer.style.left =  (scLeft + 10) + "px";
				
		//alert(fullWidth + " " + width + " " + gPopupContainer.style.left);
	}
}
addEvent(window, "resize", centerPopWin);
addEvent(window, "scroll", centerPopWin);
window.onscroll = centerPopWin;


/**
 * Sets the size of the popup mask.
 *
 */
function setMaskSize() {
	var theBody = document.getElementsByTagName("BODY")[0];
	var fullHeight = getViewportHeight();
	var fullWidth = getViewportWidth();
	
	// Determine what's bigger, scrollHeight or fullHeight / width
	if (fullHeight > theBody.scrollHeight) {
		popHeight = fullHeight;
	} else {
		popHeight = theBody.scrollHeight;
	}
	
	if (fullWidth > theBody.scrollWidth) {
		popWidth = fullWidth;
	} else {
		popWidth = theBody.scrollWidth;
	}
	
	gPopupMask.style.height = popHeight + "px";
	gPopupMask.style.width = popWidth + "px";
}

/**
 * @argument callReturnFunc - bool - determines if we call the return function specified
 * @argument returnVal - anything - return value 
 */
function hidePopWin(callReturnFunc) {
	gPopupIsShown = false;
	document.getElementById("proactive").innerHTML = "&nbsp;";
	var theBody = document.getElementsByTagName("BODY")[0];
	theBody.style.overflow = "";
	restoreTabIndexes();
	if (gPopupMask == null) {
		return;
	}
	gPopupMask.style.display = "none";
	gPopupContainer.style.display = "none";
	if (callReturnFunc == true && gReturnFunc != null) {
		// Set the return code to run in a timeout.
		// Was having issues using with an Ajax.Request();
		gReturnVal = window.frames["popupFrame"].returnVal;
		window.setTimeout('gReturnFunc(gReturnVal);', 1);
	}

	// display all select boxes
	if (gHideSelects == true) {
		displaySelectBoxes();
	}
}


// Tab key trap. iff popup is shown and key was [TAB], suppress it.
// @argument e - event - keyboard event that caused this function to be called.
function keyDownHandler(e) {
    if (gPopupIsShown && e.keyCode == 9)  return false;
}

// For IE.  Go through predefined tags and disable tabbing into them.
function disableTabIndexes() {
	if (document.all) {
		var i = 0;
		for (var j = 0; j < gTabbableTags.length; j++) {
			var tagElements = document.getElementsByTagName(gTabbableTags[j]);
			for (var k = 0 ; k < tagElements.length; k++) {
				gTabIndexes[i] = tagElements[k].tabIndex;
				tagElements[k].tabIndex="-1";
				i++;
			}
		}
	}
}

// For IE. Restore tab-indexes.
function restoreTabIndexes() {
	if (document.all) {
		var i = 0;
		for (var j = 0; j < gTabbableTags.length; j++) {
			var tagElements = document.getElementsByTagName(gTabbableTags[j]);
			for (var k = 0 ; k < tagElements.length; k++) {
				tagElements[k].tabIndex = gTabIndexes[i];
				tagElements[k].tabEnabled = true;
				i++;
			}
		}
	}
}


/**
 * Hides all drop down form select boxes on the screen so they do not appear above the mask layer.
 * IE has a problem with wanted select form tags to always be the topmost z-index or layer
 *
 * Thanks for the code Scott!
 */
function hideSelectBoxes() {
  var x = document.getElementsByTagName("SELECT");

  for (i=0;x && i < x.length; i++) {
    x[i].style.visibility = "hidden";
  }
}

/**
 * Makes all drop down form select boxes on the screen visible so they do not 
 * reappear after the dialog is closed.
 * 
 * IE has a problem with wanting select form tags to always be the 
 * topmost z-index or layer.
 */
function displaySelectBoxes() {
  var x = document.getElementsByTagName("SELECT");

  for (i=0;x && i < x.length; i++){
    x[i].style.visibility = "visible";
  }
}


//helper functions below
function custom_showIframe(){
	//jQuery('#proactive').show();//show window
	//proactive_position(); //position the window
	document.getElementById("iframeContent").style.display = "block";
	document.getElementById("iframeContent").style.width = "500px";
	document.getElementById("iframeContent").style.height = "450px";
	document.getElementById("popupTitleBar").style.width = "500px";
	document.getElementById("popCloseBox").style.display = "block";
	//document.getElementById("popupTitle").innerHTML = strTitle;
	centerPopWin();
	
	//jQuery("#dragbar").width("500px");
	//jQuery('#dragbar').html("<a href='#' onclick='proactive_remove(); return false;'><img src='http://www.virtualspirits.com/vsa/images/close.png' border='0'></a>");
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

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 null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function getbrowser() {
if (navigator.userAgent.indexOf('MSIE') !=-1)
{
	browser="MSIE";
} else {
	if (navigator.userAgent.indexOf('Firefox') !=-1)
	{
	browser="FF";
	} else {
	browser="other";
	}
}
//alert(browser);
}


// custom mdk
function filtertimeofday(){
var d = new Date();
var curr_hour = d.getHours();
// custom mdk.co.il 
// allow chats in time band 9:00 till 19:00
if (curr_hour < 9) {activepage=false;}
if (curr_hour > 19) {activepage=false;}
}

