//<script>
function ad_click(id,url,target,spaceid,ext) {
	if (url!='' && url!='none') {
		if (ext=='.swf') alert(id);
		if (url.indexOf('mailto:')!=-1) {	// email link?
			document.location.href = url;
		} else {	// normal link
			if (target=='_blank') {
				window.open('adjump.asp?id=' + id + '&url=' + url + '&spaceid=' + spaceid,'adjump');
			} else {
				document.location.href = 'adjump.asp?id=' + id + '&url=' + url + '&spaceid=' + spaceid;
			}
		}
	}
}
var now = new Date();
fixDate(now);
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);

//***************** survey functions ******************
function _vote(fid) {
	var frm = document.forms("survey" + fid);
	var voteid = null;
	for (var i=0;i<frm.item("vote").length;i++) {
		if (frm.item("vote").item(i).checked) {
			voteid = frm.item("vote").item(i).value;
		}
	}
	if (voteid==null) {
		alert("נא בחר מאפשרויות ההצבעה");
		return(false)
	} else {
		if (getCookie('v' + fid)==1) {
			alert('לא ניתן להצביע יותר מפעם אחת');
			return(false)
		}
		setCookie('v' + fid,1,now);
		var mywin = window.open('dynamic/survey/survey_results.asp?sid=' + fid + '&vid=' + voteid,'vote','width=490,height=300,status=no,toolbar=no,menubar=no,location=no');
		mywin.focus();
	}
}

function _vote_results(fid) {
	var mywin = window.open('dynamic/survey/survey_results.asp?sid=' + fid,'vote','width=490,height=300,status=no,toolbar=no,menubar=no,location=no');
}

//***************** cookie functions ******************
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

function _preview(img) {
	window.open ('preview.asp?img='+img,'imgPreview','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, copyhistory=no');
}

// open talkback pannel
function openTB(oLink,tbId) {
	var tbDiv = document.getElementById('divTB' + tbId);
	if (tbDiv) {
		if (tbDiv.style.display=='none') {
			tbDiv.style.display = '';
		} else {
			tbDiv.style.display = 'none';
		}
	}
}

// post talkback
function postTB(id) {
	var aId = document.getElementById("articleid").value;
	window.open ('talkback_post.asp?id='+aId,'postTB','width=350,height=260,toolbar=no, location=no, directories=no, status=yes, scrollbars=no');
}

function checkTB(frm) {
	if (frm.username.value=='' || frm.title.value=='') {
			alert("יש למלא שם וכותרת");
			return(false);
	}
	if (frm.user_email_display.checked) {
		if (frm.email.value=='') {
			alert("יש למלא כתובת דואר אלקטרוני");
			return(false);
		}
	}
	return (true);
}