﻿function onclick_keySearch(){
   if(document.getElementById('ctl00_rightInc_searchAll').value.trim() == "חיפוש כללי"){
      document.getElementById('ctl00_rightInc_searchAll').value = "";
   }
}
function change_group(areaId,catId,to){
  var url=new String();
    url = site_url + "attractions/get_group_cat.aspx?areaId="+ areaId + "&doubCatId=" + catId + "&to=" + to;  
  //alert(url);
  var div_update="allCat_" + catId;
  new Ajax.Request(url,{method: 'get', onComplete: function(req) {if (req.status == '200' && req.responseText != '') {$(div_update).update(req.responseText);} } } )
}
function change_group_Cat(catId,areaId,to){
  var url=new String();
    url = site_url + "attractions/get_group_area.aspx?catId="+ catId + "&doubAreaId=" + areaId + "&to=" + to;  
  //alert(url);
  var div_update="allAreas_" + areaId;
  new Ajax.Request(url,{method: 'get', onComplete: function(req) {if (req.status == '200' && req.responseText != '') {$(div_update).update(req.responseText);} } } )
}

function printDiv(additional,bw){
	var thisdoc=document;
	var strdoc=new String("");

	document.body.style.cursor = "wait";
	win = window.open("","_blank","height=650,width=632,top=100,left=50,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");
	var doc = win.document;
	doc.open();
	strdoc="<html><title>Print Page</title>"
	if (bw==1){
	strdoc= strdoc + "<head><LINK href='" + SiteHe + "coupons/styleCoupons.css' type='text/css' rel='STYLESHEET'></head>"
	}else{
	strdoc= strdoc + "<head><LINK href='" + SiteHe + "include/style.css' type='text/css' rel='STYLESHEET'></head>"
	}
	strdoc= strdoc + "<body onload=\"window.print();window.close();\" style=\"background-color:#ffffff\">"
	//if (aditional!='') {
	//strdoc= strdoc + additional
	//}
	//alert('divforPrint_' + additional);
	strdoc= strdoc + document.getElementById('divforPrint_' + additional).innerHTML
	strdoc= strdoc + "</body></html>" 
	doc.write(strdoc);
	doc.close();
	document.body.style.cursor = "default";
	return false;
}

function change_pictureBig(pictureID,lang){
 var url=new String();
 if (lang!=''){
   var url = SiteHe+"cards/get_pictureBig_lang.asp?pictureID="+pictureID+"&lang="+lang;  
 }else{
   var url = SiteHe+"cards/get_pictureBig.asp?pictureID="+pictureID;  
 }
 // alert(url);
var div_update="div_card_content";
 var obj_picture="picture_card";
 new Ajax.Request(url,{method: 'get', onComplete: function(req) { 
  if (req.status == '200' && req.responseText != '') {
     response_Results=new String(req.responseText)
     arr_Results=response_Results.split('_SRC_') 
     applyFilter(obj_picture);
	 document.getElementById(obj_picture).src = arr_Results[0];
     $(div_update).update(arr_Results[1]);
  }
 } } )
}

function applyFilter(obj_picture){
	//alert(obj_picture)
	if( document.all && document.getElementById(obj_picture)) // Apply only 4 IE
	{
		document.getElementById(obj_picture).style.filter="blendTrans(duration=1)";
		document.getElementById(obj_picture).filters.blendTrans.apply();
		document.getElementById(obj_picture).filters.blendTrans.play()
	}
}

/* card Page pictures  - - - */
function change_picturesPage(cardID,page,pageSize,lang){
  var url=new String();
  if (lang!=''){
    url = SiteHe+"cards/get_picturePage_lang.aspx?cardID="+cardID+"&page="+page+"&pageSize="+pageSize+"&lang="+lang;  
  }else{
    url = SiteHe+"cards/get_picturePage.aspx?cardID="+cardID+"&page="+page+"&pageSize="+pageSize;  
  }
 // alert(url);
  var div_update="card_picturesPage";
  new Ajax.Request(url,{method: 'get', onComplete: function(req) {if (req.status == '200' && req.responseText != '') {$(div_update).update(req.responseText);} } } )
}

function ListChange(Obj){
//alert('chuparim');
if ((document.activeElement.id=="ctl00_ContentPlaceHolder1_rightInc_categoryList") && (Obj.value!=-1)) {
    document.location.href=SiteHe+'search/categories.aspx?categoryId=' + Obj.value;
    return false;
 }else if ((document.activeElement.id=="ctl00_ContentPlaceHolder1_rightInc_areaList") && (Obj.value!=-1)) {
    document.location.href=SiteHe+'search/product_inner.aspx?productId=' + Obj.value;
    return false;
  }
return true;
}
// ctl00_ContentPlaceHolder1_btn_mailing
function check_fields(formObj) {
if ((document.activeElement.id == "ctl00_ContentPlaceHolder1_btn_mailing") || (document.activeElement.id == "ctl00_ContentPlaceHolder1_btn_contact" )){
	return CheckFields_contact(formObj);
}
if (document.activeElement.id == "inputSearch" ){
	if(emptyField(formObj.keySearch)){
	window.alert("אנא מילאו השדה מילות חיפוש");
	formObj.keySearch.focus()
	return false;
	}else{
    document.location.href=SiteHe+'search/search.aspx?keySearch=' + formObj.keySearch.value;
	return false;
	}
}else if (( document.activeElement.id=="knisa")&& (emptyField(formObj.loginUser))) {
	window.alert("אנא מלא/י שדה שם משתמש");
//	document.all("knisa").activeElement=false
	formObj.loginUser.focus()
	return false;
  } else if ((document.activeElement.id=="knisa") && (emptyField(formObj.passwordUser))) {
	window.alert("אנא מלא/י שדה סיסמה");
//	document.all("knisa").activeElement=false
	formObj.passwordUser.focus()
	return false;
  }
}
function check_log() {		
	window.alert("סיסמה / שם משתמש לא נכון");
/**	formObj.loginGr.focus()**/
	return false;
}
function MM_openBrWindow(theURL,winName,features) {window.open(theURL,winName,features);}
String.prototype.trim = function(){return this.replace(/(^\s*)|(\s*$)/g, "");}

function checkEmail(checkThisEmail){
var myEMailIsValid = true;
var myAtSymbolAt = checkThisEmail.indexOf('@');
var myLastDotAt = checkThisEmail.lastIndexOf('.');
var mySpaceAt = checkThisEmail.indexOf(' ');
var myLength = checkThisEmail.length;
if (myAtSymbolAt < 1 ){myEMailIsValid = false}
if (myLastDotAt < myAtSymbolAt){myEMailIsValid = false}
if (myLength - myLastDotAt <= 2){myEMailIsValid = false}
if (mySpaceAt != -1){myEMailIsValid = false}
   return myEMailIsValid
}

function CheckFields_contact(formObj){
	if (document.getElementById("ctl00_ContentPlaceHolder1_fullName").value==''){alert('אנא מלא/י שדה שם '); document.getElementById("ctl00_ContentPlaceHolder1_fullName").focus(); return false;}
//	if (document.getElementById("ctl00_ContentPlaceHolder1_phone").value==''){alert('Fill in the required field "Telephone"'); document.getElementById("ctl00_ContentPlaceHolder1_phone").focus(); return false;}
	if (document.getElementById("ctl00_ContentPlaceHolder1_email").value==''){alert('Fill in the required field "Email"');document.getElementById("ctl00_ContentPlaceHolder1_email").focus();return false;}
    if (document.getElementById("ctl00_ContentPlaceHolder1_email").value!=''  && !checkEmail(document.getElementById("ctl00_ContentPlaceHolder1_email").value)){alert('E-mail address is incorrect,');document.getElementById("ctl00_ContentPlaceHolder1_email").select();return false;}
	if (document.getElementById("ctl00_ContentPlaceHolder1_upl_file")){
	    filePictureValue=formObj.ctl00_ContentPlaceHolder1_upl_file.value
  	    if (!checkFileType(filePictureValue)){
			alert('File extension not valid '+ '\"'+ filePictureValue + '\"'+ '\n' + 'Extensions is the correct: '+ 'TXT, DOC, XDOC, RTF, PDF, JPG, GIF, BMP, PNG.');
			return false;
	    }
	}
 //   if (document.getElementById("ctl00_ContentPlaceHolder1_captchacode").value==''){alert('Fill in the required field "Code"');document.getElementById("ctl00_ContentPlaceHolder1_captchacode").focus();return false;}
    return true;
}
function emptyField(textObj){
	if (textObj.value.length == 0) return true;
	for (var i=0; i<textObj.value.length; i++) {
		var ch = textObj.value.charAt(i);
		if (ch != ' ' && ch != '\t') return false;	
	}
	return true;	
}
function checkFileType(fileVal){
	var validExtension=",txt,doc,xdoc,rtf,pdf,gif,jpeg,jpg,bmp,png"
	var fname=new String(fileVal)
	dotpos=fname.lastIndexOf(".")
	ext=fname.substring(dotpos+1,fname.length)
	if (validExtension.indexOf(","+ext.toLowerCase()) != -1)
		return true;
	else
		return false;
}
function addbookmark(url){
var title="chuparim";
if (window.sidebar) { // firefox
   window.sidebar.addPanel(title, url,"");
}else if(window.opera && window.print){ // opera
   var elem = document.createElement('a');elem.setAttribute('href',url);elem.setAttribute('title',title);elem.setAttribute('rel','sidebar');elem.click();
}else if(document.all)// ie
   window.external.AddFavorite(url, title);
}

function LoadIMG(siteUrl){
    document.getElementById('captcha_numchar').src=siteUrl+'global/captcha.asp?'+Date();
}
function getNumbers(){var ch=event.keyCode;event.returnValue =((ch >= 48 && ch <= 57) || ch ==46);}

function onclick_picture(picFile,picNumber){
   if (document.images['picture_Big'] && picFile!=''){
      if (document.all){
           document.images['picture_Big'].style.filter="blendTrans(duration=1)";
           document.images['picture_Big'].filters.blendTrans.Apply();
       }
       document.images['picture_Big'].style.visibility='hidden';
	   document.images['picture_Big'].src = picFile;
	   document.images['picture_Big'].style.visibility='visible';		
       if (document.all){
           document.images['picture_Big'].filters.blendTrans.Play();
        }
       if (picNumber!=''){
           changeHTML('SlideImageId',picNumber);
       }
   }
   return false;
}

function changeHTML(spanId,code){
    var element = document.getElementById(spanId);
	if(element) {
	    element.innerHTML = unescape(code);
	}
}
function gallery_picture(picFile){
   if (document.getElementById('picture_Big') && picFile!=''){
      if (document.all){
           document.getElementById('picture_Big').style.filter="blendTrans(duration=1)";
           document.getElementById('picture_Big').filters.blendTrans.Apply();
       }
       document.getElementById('picture_Big').style.visibility='hidden';
	   document.getElementById('picture_Big').src = picFile;
	   document.getElementById('picture_Big').style.visibility='visible';		
       if (document.all){
           document.getElementById('picture_Big').filters.blendTrans.Play();
        }
   }
   return false;
}
function showAjaxAreaCat(elem,id,areaId,catId) {
    var url = site_url+"attractions/get_area_cat_group.asp?groupNumber=" + id +"&elem="+elem+"&areaId="+areaId+"&catId="+catId;
    new Ajax.Request(url,{method: 'get', onComplete: function(req) { 
    var card_right_src="";
    var card_right_desc="";
    var card_left_src="";
    var card_left_desc="";
    if (req.status == '200' && req.responseText != '') {
         var response_Results=new String(req.responseText);
         /* - - right Card - - */
         var arr_Card_Right = response_Results.split('_CARDRIGHT_');
         if (arr_Card_Right.length>=1){
            str_right = new String(arr_Card_Right[1]);
            arr_pic_src = str_right.split("_CARDRIGHTPIC_");
            if (arr_pic_src.length>=1){card_right_src=arr_pic_src[0];card_right_desc=arr_pic_src[1];}
         }
         obj_picture="picture_cat_"+elem+"_right";
         if (card_right_src!='' && document.getElementById(obj_picture)){applyFilter(obj_picture);document.getElementById(obj_picture).src = card_right_src;}
         $("div_card_desc_"+elem+"_right").update(card_right_desc);
         // alert(elem)
         if (document.getElementById("title_"+elem+"_right") && document.getElementById("img_"+elem+"_right")){
             document.getElementById("img_"+elem+"_right").href=document.getElementById("title_"+elem+"_right").href;
             document.getElementById(obj_picture).alt=document.getElementById("title_"+elem+"_right").title;
         }
         /* - - left Card - - */
         var arr_Card_Left = response_Results.split('_CARDLEFT_');
         if (arr_Card_Left.length>=1){
            str_left = new String(arr_Card_Left[1]);
            arr_pic_src = str_left.split("_CARDLEFTPIC_");
            if (arr_pic_src.length>=1){card_left_src=arr_pic_src[0];card_left_desc=arr_pic_src[1];}
         }
         obj_picture="picture_cat_"+elem+"_left";
         if (card_left_src!='' && document.getElementById(obj_picture)){applyFilter(obj_picture);document.getElementById(obj_picture).src = card_left_src;}
         $("div_card_desc_"+elem+"_left").update(card_left_desc);
         if (document.getElementById("title_"+elem+"_left") && document.getElementById("img_"+elem+"_left")){
             document.getElementById("img_"+elem+"_left").href=document.getElementById("title_"+elem+"_left").href;
             document.getElementById(obj_picture).alt=document.getElementById("title_"+elem+"_left").title;
         }
    }
    } } )
}
