if (document.images) {
buttonUp = new Image(); buttonUp.src = "images/04.jpg";
buttonDown = new Image(); buttonDown.src = "images/05.jpg";
}

function turn_off(cell) {
if (document.images != null) {
cell.style.backgroundImage = "url('" + buttonUp.src + "')";
}
}

function turn_on(cell) {
if (document.images != null) {
cell.style.backgroundImage = "url('" + buttonDown.src + "')";
}
}

if (document.images) {
buttonUp2 = new Image(); buttonUp2.src = "images/33.jpg";
buttonDown2 = new Image(); buttonDown2.src = "images/34.jpg";
}


function turn_off2(cell) {
if (document.images != null) {
cell.style.backgroundImage = "url('" + buttonUp2.src + "')";
}
}

function turn_on2(cell) {
if (document.images != null) {
cell.style.backgroundImage = "url('" + buttonDown2.src + "')";
}
}

function activo(src){
    src.className = src.className + "On"
}

function inactivo(src){
    var estilo = src.className
    if(estilo.indexOf("On") != -1)
        src.className = estilo.substring(0, estilo.length - 2)
}

function getImage (){
 tempWin = window.open('../includes/showImg.asp?proID=<%=proID%>', 'tt', 'scroller=yes,width=500,height=500,left=0,top=0')
}

function openNew (url,name,sclr,wid,hei,lft,top){
 tempWin = window.open(url, name, 'scroller='+sclr+',width='+wid+',height='+hei+',left='+lft+',top='+top+'')
}
		
browserName = navigator.appName;
browserVersion = parseInt(navigator.appVersion);

Netscape = (browserName == "Netscape" && browserVersion >= 3);
explorer = (browserName.indexOf("Microsoft") >= 0 && browserVersion >= 4);

function ChangeImage(img) {
 if (Netscape || explorer) {
  imgOn = ("Uploads/Products/" + img);
  imgOnBig = ("Uploads/Products/Big/" + img);
  document.ProPic.src = imgOn;
  document.ProPicBig.src = imgOnBig;
 }
}

function check_Coupon(){

	if (document.getElementById('CouponCode').value/document.getElementById('CouponCode').value != 1){
		alert ("יש לציין מספר קופון תקין")
		return false
	}
	
	else{
		return true
	}
}

function CheckActive() {
   if(document.Pay.Policy.checked == false)
   {
    document.Pay.CheckOutBut.disabled=true; }
   else{
    document.Pay.CheckOutBut.disabled=false;
   }
}

function OrderType(typ) {
 if(typ == 0) {
  document.all.Card1.style.display='none'
  document.all.Card2.style.display='none'
  document.all.Card3.style.display='none'
  document.all.Card4.style.display='none'
  document.all.Card5.style.display='none'
 } else {
  document.all.Card1.style.display=''
  document.all.Card2.style.display=''
  document.all.Card3.style.display=''
  document.all.Card4.style.display=''
  document.all.Card5.style.display=''
 }
 
}

function SearchType(typ) {
  if(typ == 0) {
    document.all.SearchType0.style.display=''
    document.all.SearchType1.style.display='none'
    document.all.SearchType2.style.display='none'
	document.all.SearchTypeO.value='0'
  } else if(typ == 1) {
    document.all.SearchType0.style.display='none'
    document.all.SearchType1.style.display=''
    document.all.SearchType2.style.display='none'
	document.all.SearchTypeO.value='1'
  } else if(typ == 2) {
    document.all.SearchType0.style.display='none'
    document.all.SearchType1.style.display='none'
    document.all.SearchType2.style.display=''
	document.all.SearchTypeO.value='2'
  }
}

function FloatingsBanner()
{
if(document.body.offsetWidth >= 1024)
{
 FloatingLeftBanner.style.display='';
 FloatingRightBanner.style.display='';
 }
 else
 {
 FloatingLeftBanner.style.display='none';
 FloatingRightBanner.style.display='none';
 }
}

var loadedobjects=""
var rootdomain="http://"+window.location.hostname
function ajaxpage(url, containerid){
 var page_request = false
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE
		try {
		page_request = new ActiveXObject("Msxml2.XMLHTTP")
	} 
	catch (e){
	try{
		page_request = new ActiveXObject("Microsoft.XMLHTTP")
	}
		catch (e){}
		}
	}
	else
	return false
   page_request.onreadystatechange=function(){
   loadpage(page_request, containerid)
  }
  page_request.open('GET', url, true)
  page_request.send(null)
  CountTime();
}
function loadpage(page_request, containerid){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
		document.getElementById(containerid).innerHTML=page_request.responseText
}


function validEmail(fld)
{ // simple email check
  if(!fld.length) return true; // blank fields are the domain of requireValue
  var emailfmt= /^\w+([.-]\w+)*@\w+([.-]\w+)*\.\w{2,8}$/;
  if(!emailfmt.test(fld))
          {return false;}
  return true;
}

function checkMail(){

if(document.all.EmailAddress.value == "" || !validEmail(document.all.EmailAddress.value))
	{
	alert ("אנא ציין כתובת דואר חוקית ונסה שנית")
    return false;
	}else{
		return true
	}
}


function checkSearch(){

if(document.all.SearchTypeO.value=='0')
 {
 
   if(document.all.SearchQuery.value.length < 2)
	{
	alert ("יש למלא מילת חיפוש !")
    return false;
	}else{
		return true
	}
	
 }else if(document.all.SearchTypeO.value=='1')
 {
 
   if((document.all.Fprice.value == "")||(document.all.Tprice.value == "") )
	{
	alert ("יש להזין מחירים !")
    return false;
	}else{
		return true
	}
	
 }else if(document.all.SearchTypeO.value=='2')
 {
 
   if(document.all.Creator.value == "")
	{
	alert ("יש לבחור יצרן !")
    return false;
	}else{
		return true
	}
	
 }
}


function MailAction(Action){
  if(Action == "1")
  {
  document.Mails.Action.value='InsertMail'
  }else{
  document.Mails.Action.value='DeleteMail'
  }
  
}

//Product Of The Day
 function showPD(){
  TopPosPD=parseInt(document.getElementById("ProductOfTheDay").style.top, 10)
  LowPosPD=150
  if (window.hideme){ window.clearInterval(hideme)}
   showme=window.setInterval("AppearPD()",20) 
 }

 function AppearPD(){
   tmp = parseInt(document.getElementById("ProductOfTheDay").style.top, 10)
    if ( tmp < LowPosPD) 
    {
	 tmp += 5
	 document.getElementById("ProductOfTheDay").style.top = tmp + "px"
	 //document.all.ProdubctOfTheDay.style.pixelLeft+=1 
	}
	else if (window.showme)
	{
	 clearInterval(window.showme)//
	}
 }

 function HideProductOfTheDay(){ 
   clearInterval(window.showme)
    if (window.hideme){ window.clearInterval(hideme) }
     hideme=window.setInterval("hideit()",20)
 }

 function hideit(){
  tmp = parseInt(document.getElementById("ProductOfTheDay").style.top, 10)
	if (tmp > TopPosPD) {
	 tmp -= 3
	 document.getElementById("ProductOfTheDay").style.top = tmp + "px" 
	}
	else if (window.hideme){
	 window.clearInterval(hideme)
	}
 }
//Product Of The Day


function CalcExist(ExtPrice,ExistID,ExistNum)
{
  if (ExtPrice==0 && ExistNum==0)
  {
   document.all.Subtotal.innerHTML=eval(document.all.Subtotal.value)-eval(document.getElementById("ExistInSub"+ExistID).value);
   document.all.Subtotal.value=eval(document.all.Subtotal.value)-eval(document.getElementById("ExistInSub"+ExistID).value);

   document.getElementById("ExistInSub"+ExistID).value=0;
   document.getElementById("ExistInNumSub"+ExistID).value=0;
   
  }else{
    if (document.getElementById("ExistInNumSub"+ExistID).value != ExistNum)
    {
     document.all.Subtotal.innerHTML=eval(document.all.Subtotal.value)+eval(ExtPrice)-eval(document.getElementById("ExistInSub"+ExistID).value);
     document.all.Subtotal.value=eval(document.all.Subtotal.value)+eval(ExtPrice)-eval(document.getElementById("ExistInSub"+ExistID).value);
	 
     document.getElementById("ExistInSub"+ExistID).value=ExtPrice;
     document.getElementById("ExistInNumSub"+ExistID).value=ExistNum;
    }
  }
}

function CalcDeliverySelf(DeliveryPrice)
{
 if (document.all.DeliverySelf.checked) 
  {
   document.all.Subtotal.innerHTML=document.all.Subtotal.value-DeliveryPrice;
   document.all.Subtotal.value=document.all.Subtotal.value-DeliveryPrice;
   document.all.SubDelivery.innerHTML=0;
  }else{
   document.all.Subtotal.innerHTML=eval(document.all.Subtotal.value)+eval(DeliveryPrice);
   document.all.Subtotal.value=eval(document.all.Subtotal.value)+eval(DeliveryPrice);
   document.all.SubDelivery.innerHTML=DeliveryPrice;
  }
}

//ClientCardNum,ClientCardType

function ValidateCreditCardType(sCardNumber, sCardType)
{
	var sCard=sCardNumber
	if (sCard=='')
	{
		return false;
	}
	if (sCard=='4444333322221111')
	{
		return true;
	}
	var nType=sCardType;
	if ((nType==5)||(nType==2))
	{
		//Isracart
		if (sCard.length==9)
		{
		   if( prefix < 69 && prefix > 75) {
			return true;
		   }
		}
		if (sCard.length==8)
		{
		  var prefix = parseInt( sCard.substring(0,2));
		   if( prefix > 49 && prefix < 65) {
			return true;
		   }
		}
		if ((sCard.length==16)&&((sCard.substr(0,1)=='5')||(sCard.substr(0,1)=='6')))
		{
			return true;
		}
		return false;
	}
	if ((nType==1)||(nType==6))
	{
		//Visa CAAL
		if (sCard.length==16)
		{
			if (((sCard.substr(0,1)=='3')||(sCard.substr(0,1)=='4'))&&((sCard.substr(0,6)<352800)||(sCard.substr(0,6)>358999)))
			{
				return true;
			}
			return false;
		}
		if ((sCard.length<11)||(sCard.length>19))
		{
			return false;
		}
		if (sCard.substr(0,1)=='4')
		{
			return true;
		}
		return false;
	}
	if (nType==4)
	{
		//Diners
		if ((sCard.length==14)&&((sCard.substr(0,1)=='3')||(sCard.substr(0,1)=='6')))
		{
			return true;
		}
		return false;
	}
	if (nType==3)
	{
		//American Express
		if ((sCard.length==15)&&((sCard.substr(0,2)=='34')||(sCard.substr(0,2)=='37')))
		{
			return true;
		}
		return false;
	}
	if (nType==7)
	{
		//Alpha Card
		if ((sCard.length==16)&&(sCard.substr(0,1)=='4'))
		{
			if(sCard.substr(0,4)=='4580')
			{
				return true;
			}
			return true;
		}
		return false;
	}
	
}


function VShop_StartEffects()
{
	var top = 0;
	var step = 30;
	myFloatingBasket = new VShop.LeftSlidingDiv(VShop.findLayer("SlidingCart"), -350,  top+=step);
}

// Status bar text
var speed = 50 // decrease value to increase speed (must be positive)
var pause = 7000 // increase value to increase pause
var timerID = null
var bannerRunning = false
var ar = new Array()

var currentMessage = 0
var offset = 0

function stopStatus() {

        if (bannerRunning)
                clearTimeout(timerID)
        bannerRunning = false
}

function startStatus(StatusText,StatusText2,StatusText3) {

  ar[0] = StatusText
  ar[1] = StatusText2
  ar[2] = StatusText3


        stopStatus()
        showStatus()
}

function showStatus() {
        var text = ar[currentMessage]

        if (offset < text.length) {
                if (text.charAt(offset) == " ")
                        offset++                        

                var partialMessage = text.substring(0, offset + 1) 
                window.status = partialMessage
                offset++ 
                timerID = setTimeout("showStatus()", speed)
                bannerRunning = true

        } else {

                offset = 0
                currentMessage++

                if (currentMessage == ar.length)

                        currentMessage = 0
                timerID = setTimeout("showStatus()", pause)
                bannerRunning = true
        }

}
