﻿function printDiv(aditional){
	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>"
	strdoc= strdoc + "<head><LINK href='" + SiteHe + "include/style.css' type='text/css' rel='STYLESHEET'></head>"
	//strdoc= strdoc + "<body onload=\"logoimg.style.display=\'block\';imgprint.style.display=\'none\';window.print();window.close();\">"
	strdoc= strdoc + "<body onload=\"window.print();window.close();\" style=\"background-color:#ffffff\">"
	if (aditional!='') {
	strdoc= strdoc + aditional
	}
	strdoc= strdoc + divforPrint.innerHTML
	strdoc= strdoc + "</body></html>" 
	doc.write(strdoc);
	doc.close();
	document.body.style.cursor = "default";
	return false;
}
function ListChange(Obj){
//alert('uniSite');
if ((document.activeElement.id=="ctl00_ContentPlaceHolder1_catalogInc_categoryList") && (Obj.value!=-1)) {
    document.location.href=SiteHe+'catalog/categories.aspx?categoryId=' + Obj.value;
    return false;
 }else if ((document.activeElement.id=="ctl00_ContentPlaceHolder1_catalogInc_productsList") && (Obj.value!=-1)) {
    document.location.href=SiteHe+'catalog/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="uniSite";
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;
}

