function _gel(a){return document.getElementById(a)}
function trim(s){return s.replace(/^\s+/,'').replace(/\s+$/,'');}
function get_random(){var ranNum= Math.round(Math.random()*98929);return ranNum;}
function ColorInput(Obj,CellColor){Obj.style.backgroundColor=CellColor}
function Load(){var a=null;try{a=new ActiveXObject("Msxml2.XMLHTTP")}catch(b){try{a=new ActiveXObject("Microsoft.XMLHTTP")}catch(c){a=null}}if(!a&&typeof XMLHttpRequest!="undefined"){a=new XMLHttpRequest()}return a}

var iresult = 1
function addRatingFeedback(responseXML,d, id) {
	mydiv = _gel(d)
	var s = responseXML.responseText
	mydiv.innerHTML = s
	
	iresult = id
}

function _loadcontentGET(d, id,cid){
	var xmlhttp = Load();
	mydiv = _gel(d)
	var u = 'gethitem.asp?id=' + id + '&cid=' + cid + '&r=' + get_random()
	//mydiv.innerHTML=u
	mydiv.innerHTML= '<img src="i/working.gif" width=13 height=13>'
	xmlhttp.open("get", u, true);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {
			if (xmlhttp.status == 200){	
				mydiv.innerHTML= '<img src="i/working.gif" width=13 height=13>'
				addRatingFeedback(xmlhttp,d, id);
			}else{
				mydiv.innerHTML= 'erorr loading'
			} 
		}
	}
	xmlhttp.send(null);
}

function xnv(iid,p){
	var d=_gel(iid.id)
	var imn = d.src
	if(p==0){
		imn = imn.replace('0.gif','1.gif')
	}else{
		imn = imn.replace('1.gif','0.gif')
	}
	d.src=imn
}

var ilast_scpx = 0
function scpx(i, cid){
	if(ilast_scpx==i) return
	var f = _gel('prx'+ilast_scpx)
	if (f){
		f.style.border='1px solid #fff'
		//f.style.className='prod_bord'
	}
	f = _gel('prx'+i)
	if (f){
		f.style.border='1px solid #D9D9D9'
		//f.style.className='prod_bord'
	}
	ilast_scpx = i
	_loadcontentGET('item_content',i,cid)
}

var ilast_swp = 0
function swp(s, i){
	var f = _gel('nvp'+ilast_swp)
	if (f){
		f.style.color='#8C8C8C'
	}	
	
	s = trim(s)
	if(s==''){
	}else{
		var d=_gel('tpic')
		d.src = 'upfiles/' + s
	}	
		
	f = _gel('nvp'+i)
	if (f){
		f.style.color='#656565'
	}	
	ilast_swp = i
}

function vfeedback(f){
var t = trim(f.elements['fname'].value)
	if (t.length < 2) {
		alert('יש להזין שם מלא');
		ColorInput(f.elements['fname'],'#FF9E2B')
	    document.formy.fname.focus();
		return false
	}ColorInput(f.elements['fname'],'#ffffff')
	
	var t = trim(f.elements['email'].value)
	if (t.length < 10) {
		alert('יש להזין כתובת מייל');
		ColorInput(f.elements['email'],'#FF9E2B')
	    document.formy.email.focus();
		return false
	}ColorInput(f.elements['email'],'#ffffff')
	
	if(!isEmail(t)){
		alert('יש להזין כתובת מייל תקינה');
		ColorInput(f.elements['email'],'#FF9E2B')
	    document.formy.email.focus();
		return false	
	}ColorInput(f.elements['email'],'#ffffff')
	return true
}

function vcontact(f){
	var t = trim(f.elements['flname'].value)
	if (t.length < 2) {
		alert('יש להזין שם מלא');
		ColorInput(f.elements['flname'],'#FF9E2B')
	    document.formy.flname.focus();
		return false
	}ColorInput(f.elements['flname'],'#ffffff')
	if(!isEmail(t)){
		alert('יש להזין כתובת מייל תקינה');
		ColorInput(f.elements['email'],'#FF9E2B')
	    document.formy.email.focus();
		return false	
	}ColorInput(f.elements['email'],'#ffffff')	
	return true
}
function pw(pg, wn, w, h) {
  wparms = 'top=20,left=20,height='+h+',width='+w+',status=1,scrollbars=1,resizable=1'
  win = window.open(pg,wn, wparms)
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function jqc(i){
	var v = i + ''
	var temp = new Array();
	temp = v.split('_');
	//alert(temp[0])
	var cid = temp[0]
	var pid = temp[1]	
	if(pid){
		document.location.href='product_category.asp?cid=' + cid + '&qcat_id=' + pid
	}else{
		document.location.href='product_category.asp?cid=' + cid
	}
	//alert(temp[1])
	//if v.indexOf("pid_"){
	//document.location.href='product_category.asp?'
	//}
}
