//<script>
function ad_click(id,url,target,spaceid) {
	if (url!='' && url!='none') {
		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');
}

