// JavaScript Document

/// Brake from any frame
function Unframe(){
if (top != self) {
top.location.href = self.location.href;
	}
}


//Focus on object
function DoFocus(CHname){
	//alert(CHname)
	CHname.focus()
	}
//Blue from object
function DoBlur(CHname){
	//alert(CHname)
	CHname.blur()
	}


/// Check a checkbox by function
function DoCheckbox(CHname){
	//alert(CHname)
	if (CHname.checked == false)
	{
	CHname.checked = true
	}
	else
	{
	CHname.checked = false
	}
	
	}
	
/// Check a RadioButton by function
function DoRadioBT(CHname,NM){
	//alert(CHname)
	if (CHname[NM].checked == false)
	{
	CHname[NM].checked = true
	}
	else
	{
	CHname[NM].checked = false
	}
	
	}


//Open window - Center screen
function WinOpen(winURL,winWidth,winHeight){
	var w = screen.width; 
	var h = screen.height;
	var left = (w-winWidth)/2;
	var top = (h-winHeight)/2;

window.open(winURL,'popWin','width='+winWidth+',height='+winHeight+',screenX='+top+',top='+top+',screenY='+left+',left='+left+'')
}

function WinOpenScroll(winURL,winWidth,winHeight){
	var w = screen.width; 
	var h = screen.height;
	var left = (w-winWidth)/2;
	var top = (h-winHeight)/2;

window.open(winURL,'popWin','width='+winWidth+',height='+winHeight+',screenX='+top+',top='+top+',screenY='+left+',left='+left+',scrollbars=1')
}


function MarkErr(FormName){
	var TheClass = document.getElementById(FormName).className
	document.getElementById(FormName).className = TheClass+" errMark"
	document.getElementById(FormName).style.backgroundColor = "#FC9"	
	}

function DoErrorField(FormName){
	document.getElementById(FormName).focus()
	var TheClass = document.getElementById(FormName).className
	document.getElementById(FormName).className = TheClass+" errMark"
	document.getElementById(FormName).style.backgroundColor = "#FC9"
	
if (FormName=='Don_CC_CVV' || FormName=='Don_CC_Y_Date' || FormName=='Don_CC_M_Date' || FormName=='Don_CC_ID'){
	MarkErr('Don_CC_CVV')
	MarkErr('Don_CC_Y_Date')
	MarkErr('Don_CC_M_Date')
	MarkErr('Don_CC_ID')
	}
	
	}

function toggle(item) {
	var obj = document.getElementById(item);
	var visible = (obj.style.display != "none");

	if(visible){
		obj.style.display = "none";
		} else {
		obj.style.display = "block";
		}
}

function toggleON(item) {
	var obj = document.getElementById(item);
	obj.style.display = "block";

}
function toggleOFF(item) {
	var obj = document.getElementById(item);
	obj.style.display = "none";

}

//  ValidMail(this.value)
function ValidMail(txtValid, FormName){
var re;
        re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
        if (re.test(txtValid) == true)
			return true;
        else
        {
            alert('יש למלא כתובת דואר אלקטרוני נכונה');
			DoErrorField(FormName)
			return false;
        }
}

//   NoSpace(this.value,' שם פרטי')
function NoSpace(txtValid, fieldname,FormName){
	re = /\s/;
	if (re.test(txtValid)==false)
	{
		return true;
		}
	else
	{
		alert('אין להשתמש ברווחים בשדה - '+fieldname)
		DoErrorField(FormName)
		return false;
		}
	
	}
	
	
//    NumbersOnly(this.value,'שם פרטי')	
function NumbersOnly(txtValid, fieldname,FormName){
	re = /\D/;
	if (re.test(txtValid)==false)
	{
		return true;
		}
	else
	{
		alert('נא להכניס מספרים בלבד בשדה - '+fieldname)
		DoErrorField(FormName)
		return false;
		}
	
	}
	
	function NotEmpty(txtValid,fieldname,FormName){
		
		if (txtValid=="")
		{
			alert('יש למלא את שדה - '+fieldname+' - זהו שדה חובה  ')
			DoErrorField(FormName)
			return false;
			}
			else{
				return true;
				}
		
		}
		
		
	function MinLength(txtValid,reqSize,fieldname, FormName){		
		if (txtValid.length<reqSize)
			{
				alert('שדה '+fieldname+' אינו מלא')
				DoErrorField(FormName)
				return false;
			}
		else
			{
			return true;
			}
		}
		
		
			function MinValue(txtValid,reqSize,fieldname,ReqInfo, FormName){		
		if (txtValid<reqSize)
			{
				alert('שדה '+fieldname+' אינו יכול להיות קטן מ'+reqSize +" "+ReqInfo)
				DoErrorField(FormName)
				return false;
			}
		else
			{
			return true;
			}
		}
		
			function MaxValue(txtValid,reqSize,fieldname,FormName){		
		if (txtValid>reqSize)
			{
				alert('שדה '+fieldname+' אינו יכול להיות גדול מ'+reqSize)
				DoErrorField(FormName)
				return false;
			}
		else
			{
			return true;
			}
		}
		
			function ValueLimits(txtValid,MinSize,MaxSize,fieldname,FormName){		
		if (txtValid<MinSize || txtValid>MaxSize)
			{
				alert('שדה '+fieldname+' חייב להיות בגודל שבין:'+MinSize+' ל:'+MaxSize)
				DoErrorField(FormName)
				return false;
			}
		else
			{
			return true;
			}
		}
		
		
		
		
		
		
	function selectVal(id){
	var SID = O(id)
	return SID.options[SID.selectedIndex].value
	}
	
	function O(id){
	return document.getElementById(id)
	}
	
	
	function G(id){
	return document.getElementById(id).value
	}
	
	function S(id,val){
	document.getElementById(id).value = val
	}	
		
		
		
		
	function altercontent(dcontent,NewTxt){
	
	if (document.all){
	var con = O(dcontent)
	con.innerHTML=NewTxt;
	}
	else if (document.getElementById){
	var rng = document.createRange();
	var el = O(dcontent);
	rng.setStartBefore(el);
	var htmlFrag = rng.createContextualFragment(NewTxt);
	while (el.hasChildNodes()) el.removeChild(el.lastChild);
	el.appendChild(htmlFrag);}
	}		
			

function DoalWrite(user,domain){
var emailE = (user +'@' + domain)
document.write('<A href="mailto:' + emailE + '">' + emailE + '</a>')
}


// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}


///////////  XHTP

function XHConn()
{
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, true);
		xmlhttp.setRequestHeader("Content-Type", "text/html;charset=UTF-8");
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);
        }};
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}

function cont(id){
var GalDiv = O("	contctDiv")
var mailFrm = O("mailFrm")
var Disp = (GalDiv.style.display == 'none')?"block":"none"

if (Disp =='block'){
	//GalDiv.height = "40px"
	toggleON('mailFrm')
	changeOpac(0, 'mailFrm')
	currentOpac('mailFrm', 100, 400)
	SwitchZ('mailFrm',20)
}
else
	{
	alert("st 1")
	GalDiv.height = "380px"
	CloseDiv('mailFrm')
	}
mailFrm.src = 'SendMail.asp?AID='+id	
}


function opacity(id, opacStart, opacEnd, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;
    if(opacStart > opacEnd) {
        for(var i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(var i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

function currentOpac(id, opacEnd, millisec) {
    var currentOpac = 100;
    if(document.getElementById(id).style.opacity < 100) {
        currentOpac = document.getElementById(id).style.opacity * 100;
    }
    opacity(id, currentOpac, opacEnd, millisec)
} 

function SwitchZ(id,z){
	var obj = O(id)
	obj.style.zIndex = z
}

function CloseDiv(id){
	currentOpac(id, 0, 400)
	setTimeout("toggleOFF('"+id+"')",500)	
}

function chkSrch(){
	var tagsearch = G('tagsearch')

	if (tagsearch==''){toggle('srEr2'); toggle('srEr'); return false}
	}