function v(){
}

function ClearMe (Ctarget, defaultval) {
 if (Ctarget.value == defaultval) Ctarget.value = '';
 if (Ctarget.value == defaultval) 
 {
  Ctarget.value = '';
  Ctarget.style.fontStyle = "normal";
 }
 
}
function CheckMe (Ctarget, defaultval) {
 if (Ctarget.value == '') Ctarget.value = defaultval;
 if (Ctarget.value == '')
 {
  Ctarget.value = defaultval;
  Ctarget.style.fontStyle = "italic";
 }
}

function updateTimer(timerID) {
 timer_remaining = timer_current-timer_offset;
 //alert(timer_remaining);
 if (timer_remaining<0) timer_remaining = 0;
 //if (timer_remaining==0) window.location.href=window.location.href;
 timer_remaining_minutes = Math.floor(timer_remaining/60);
 timer_remaining_seconds = timer_remaining%60;
 if (timer_remaining_minutes<10) timer_remaining_minutes = '0'+timer_remaining_minutes;
 if (timer_remaining_seconds<10) timer_remaining_seconds = '0'+timer_remaining_seconds;
 document.getElementById(timerID).innerHTML = timer_remaining_minutes + ":" + timer_remaining_seconds;
 timer_offset++;
}

function postlang (langcode) {
 document.langform.lang.value = langcode;
}

function check_methods (clickedObj, submitaftercheck) {
 if (clickedObj!==undefined) {
	cn = clickedObj.name;
 } else {
	cn = null;
 }
 d = document.forms['basketform'].elements['deliverymethod'];
 p = document.forms['basketform'].elements['paymethod'];
 dval = getCheckedValue(d);
 pval = getCheckedValue(p);
 if (dval=="") dval = document.getElementById('deliverymethod').value;
 if (pval=="") pval = document.getElementById('paymethod').value;
 if (cn!==null) {
	if (cn=='deliverymethod' && dval!=='COURIER' && pval=='COURIER') {
  		var setresult = setCheckedValue(p, 'CCARD');
  		if (setresult!==true) setresult = setCheckedValue(p, 'PAYPALEC');
  		if (setresult!==true) setresult = setCheckedValue(p, 'CASH');
	} else if (cn=='paymethod' && dval!=='COURIER' && pval=='COURIER') {
  		var setresult = setCheckedValue(d, 'COURIER');
	} else if (submitaftercheck==true) {
		AjaxUpdTarget = "itemlist_container";
		if (document.getElementById(AjaxUpdTarget)==null) { 
 			document.basket_paychange_form.paymethod.value=pval;
			document.basket_paychange_form.submit();
		} else {
			AjaxUpdMode = "html";
			//document.getElementById('itemlist_container_cover').style.display="block";
			document.getElementById(AjaxUpdTarget).style.filter="alpha(opacity=50)";
			document.getElementById(AjaxUpdTarget).style.opacity='0.5';
			AjaxObj.Open('basket.php', '?listonly&pm='+pval+'&dm='+dval, updatebasketlist, null, AjaxUpdTarget, AjaxUpdMode);
		}
	}
 } 
  var currcharge = (deliverycharges!==undefined && deliverycharges[dval]!==undefined) ? deliverycharges[dval] : 0;
  var currpaycharge = (paycharges!==undefined && paycharges[pval]!==undefined) ? paycharges[pval] : 0;
  var netprice_f = document.getElementById('netprice');
  var delcharge_f = document.getElementById('delcharge');
  if (delcharge_f!==null) {
  	var bnp = Number(netprice_f.innerHTML.replace(" ", ""))-Number(delcharge_f.innerHTML.replace(" ", ""));
  } else {
  	var bnp = netprice_f.innerHTML.replace(" ", "");
  }
  //var selectedcharge = currcharge==undefined ? 0 : currcharge;
  //var selectedpaycharge = currpaycharge==undefined ? 0 : currpaycharge;
  if (delcharge_f!==null) delcharge_f.innerHTML = number_format(Number(currcharge)+Number(currpaycharge), decimalcount, ".", " ");
  if (netprice_f!==null) netprice_f.innerHTML = number_format(Number(bnp)+Number(currcharge)+Number(currpaycharge), decimalcount, ".", " ");
 //alert(decimalcount+" + "+bnp+" + "+selectedcharge+" + "+selectedpaycharge);
}
function updatebasketlist (e) {
	var XH = e;
    var UpdTarget = e.UpdTarget;
    var UpdMode = e.UpdMode;
    if(XH.readyState == 4) {
    	document.getElementById(UpdTarget).style.filter="alpha(opacity=100)";
		document.getElementById(UpdTarget).style.opacity='1';
		document.getElementById(UpdTarget).innerHTML = XH.responseText;
    }
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
	if (getCheckedValue(radioObj)==newValue.toString()) {
   return true;
  } else {
   return false;
  }
}

function new_freecap(elementname, failtext)
{
 	if (elementname==undefined) elementname="freecap";
	if(document.getElementById)
	{
		thesrc = document.getElementById(elementname).src;
		thesrc = thesrc.substring(0,thesrc.lastIndexOf(".")+4);
		document.getElementById(elementname).src = thesrc+"?"+Math.round(Math.random()*100000);
	} else {
		if (failtext!==undefined) alert(failtext);
	}
}

function hideobj (objname) {
 var brokenstring=objname.split(",");
 var len = brokenstring.length;
 for (var n = 0; n < len; n++){
 	if (document.getElementById(brokenstring[n])!==null) {
 	  document.getElementById(brokenstring[n]).style.display = "none";
 	}
 }
}

function showobj (objname) {
 var brokenstring=objname.split(",");
 var len = brokenstring.length;
 for (var n = 0; n < len; n++){
 	if (document.getElementById(brokenstring[n])!==null) {
	   document.getElementById(brokenstring[n]).style.display = "block";
 	}
 }
}

function toggleVis (objname) {
 var brokenstring=objname.split(",");
 var len = brokenstring.length;
 var target;
 for (var n = 0; n < len; n++) {
  target = document.getElementById(brokenstring[n]);
  //alert(target.name);
  if (target.style.display=="none") {
   target.style.display="block";
  } else {
   target.style.display="none";
  }
 }
}

function toggleVis2 (objname,path,mess,hhh,pic,msg) {
 var brokenstring=objname.split(",");
 var len = brokenstring.length;
 var target;
 for (var n = 0; n < len; n++) {
  target = document.getElementById(brokenstring[n]);
  targetpic = document.getElementById(pic);
  //alert(target.name);
  if (target.style.height==hhh) 
  {
   target.style.height="";
   targetpic.src=path+"images/button-up2.png";
    var celElem = document.getElementById(msg);  
    celElem.innerHTML = "";   
  } 
  else 
  {
   target.style.height=hhh;
   targetpic.src=path+"images/button-down2.png";
    var celElem = document.getElementById(msg);  
    celElem.innerHTML = mess;    
  }
 }
}

function toggleVis_check (cbox, objname) {
 if (cbox.checked) {
  showobj(objname);
 } else {
  hideobj(objname);
 }
}

var Url = {

    // public method for url encoding
    encode : function (string) {
        return escape(this._utf8_encode(string));
    },

    // public method for url decoding
    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}

function isNumeric (expression) {
 if (isNaN(parseFloat(expression))) return false;
 return true;
}

function updatecalendar (newurl) {
 AjaxUpdTarget = "calendarcont";
 AjaxUpdMode = "";
 document.getElementById(AjaxUpdTarget).innerHTML = "";
 AjaxObj.Open('search.php', newurl+'&calonly', AjaxUpd, null, AjaxUpdTarget, AjaxUpdMode);
}


function inc(filename)
{
	var body = document.getElementsByTagName('body').item(0);
	script = document.createElement('script');
	script.src = filename;
	script.type = 'text/javascript';
	body.appendChild(script)
}

function showBigImage (fileurl, imglist) {
	SC_showImage(fileurl, imglist);
}

function showBigVideo (videotype, videoid) {
	var htmltodisplay = "";
	bigitemheight = 385;
	bigitemwidth = 480;
	if (videotype=="szinhaztv") {
		htmltodisplay = '<object width="'+bigitemwidth+'" height="'+bigitemheight+'" data="http://www.szinhaz.tv/site/player/flowplayer.swf" type="application/x-shockwave-flash">';
		htmltodisplay += '<param name="movie" value="http://www.szinhaz.tv/site/player/flowplayer.swf" />';
		htmltodisplay += '<param name="allowfullscreen" value="true" />';
		htmltodisplay += '<param name="allowscriptaccess" value="always" />';
		htmltodisplay += '<param name="flashvars" value=\'config=http://www.szinhaz.tv/embed/'+videoid+'\' />';
		htmltodisplay += '<embed src="http://www.szinhaz.tv/site/player/flowplayer.swf" flashvars="config=http://www.szinhaz.tv/embed/'+videoid+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+bigitemwidth+'" height="'+bigitemheight+'"></embed>';
		htmltodisplay += ' </object>';
	} else if (videotype=="youtube") {
		htmltodisplay = '<object width="'+bigitemwidth+'" height="'+bigitemheight+'" data="http://www.youtube.com/v/'+videoid+'&hl=en_US&fs=1&" type="application/x-shockwave-flash">';
		htmltodisplay += '<param name="movie" value="http://www.youtube.com/v/'+videoid+'&hl=en_US&fs=1&" />';
		htmltodisplay += '<param name="allowfullscreen" value="true" />';
		htmltodisplay += '<param name="allowscriptaccess" value="always" />';
		htmltodisplay += '<embed src="http://www.youtube.com/v/'+videoid+'&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+bigitemwidth+'" height="'+bigitemheight+'"></embed>';
		htmltodisplay += ' </object>';
	}
	SC_showContent(htmltodisplay, bigitemwidth, bigitemheight);
}
function showBigContent (control, width, height, endfunc) {
	SC_showContent(control, width, height, endfunc);
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

function increasefield (fieldid, displayid, dir, min, max) {
	var field = document.getElementById(fieldid);
	field.value = parseInt(field.value)+dir;
	if (min!==undefined) {
		field.value = Math.max(parseInt(field.value), min);
	}
	if (max!==undefined) {
		field.value = Math.min(parseInt(field.value), max);
	}
	if (displayid!==null) {
		var display = document.getElementById(displayid);
		display.innerHTML = field.value;
	}
}

function number_format(number, decimals, dec_point, thousands_sep) {
    var n = !isFinite(+number) ? 0 : +number, 
        prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
        sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
        dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
        s = '',
        toFixedFix = function (n, prec) {
            var k = Math.pow(10, prec);
            return '' + Math.round(n * k) / k;
        };
    // Fix for IE parseFloat(0.55).toFixed(0) = 0;
    s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
    if (s[0].length > 3) {
        s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
    }
    if ((s[1] || '').length < prec) {
        s[1] = s[1] || '';
        s[1] += new Array(prec - s[1].length + 1).join('0');
    }
    return s.join(dec);
}

var act_tr_fieldname;
var act_tr_currval;
function showtranslatebtn (e, fieldname, currval) {
	if (document.getElementById("tranlateBTN")!==undefined && document.getElementById("tranlateBTN").style.display=="none" && document.getElementById("tranlateEDIT").style.display=="none") {
		var mx = getMouseX(e);
		var my = getMouseY(e);
		var trbtn = document.getElementById("tranlateBTN");
		trbtn.style.position = "absolute";
		trbtn.style.top = (my-40)+"px";
		trbtn.style.left = (mx+20)+"px";
		trbtn.style.background = "#ffffff";
		trbtn.style.color = "#000000";
		trbtn.style.cursor = "pointer";
		trbtn.style.display = "block";
		act_tr_fieldname = fieldname;
		act_tr_currval = currval;
		setTimeout("removetranslatebtn()",2000);
	}
}
function removetranslatebtn () {
	if (document.getElementById("tranlateBTN")!==undefined) {
		document.getElementById("tranlateBTN").style.display="none";
	}
}
function getnewtranslation (e, lang) {
	var mx = getMouseX(e);
	var my = getMouseY(e);
	var trbtn = document.getElementById("tranlateBTN");
	trbtn.style.display = "none";
	var trinput = document.getElementById("tranlateEDIT");
	trinput.style.position = "absolute";
	trinput.style.top = (my+20)+"px";
	trinput.style.left = mx+"px";
	trinput.style.background = "#ffffff";
	trinput.style.color = "#000000";
	trinput.style.display = "block";
	document.getElementById("translateNewval").value=act_tr_currval;
}
function setnewtranslation (e, lang) {
	var trbtn = document.getElementById("tranlateEDIT");
	trbtn.style.display = "none";
	var newval=document.getElementById("translateNewval").value;
	//alert('?q=language&tlang='+lang+'&modval='+act_tr_fieldname+'&newval='+urlencode(newval));
	AjaxObj.Post('admin.php', '?q=language&tlang='+lang+'&modval='+act_tr_fieldname+'&newval='+urlencode(newval), AjaxUpd, refreshpage, null, null);
	
}

function urlencode (str) {
    str = (str + '').toString();
    return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
}
function refreshpage () {
	document.location.reload();
}

/*Maintext size change*/
function resizeText(inc) {
  var p = document.getElementById('leftBoxContent');
    if(p.style.fontSize) {
       var size = parseInt(p.style.fontSize.replace("px", ""));
    } else {
       var size = 12;
    }
    var fontsize = size+inc;
    p.style.fontSize = fontsize + 'px';
    setCookie("fontsize",fontsize,365);
}

/*Cookie set easing*/
function setCookie(c_name,value,exdays) {
  var exdate=new Date();
  exdate.setDate(exdate.getDate() + exdays);
  //var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
  var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString())+";  path=/";
  document.cookie=c_name + "=" + c_value;
}

function getY( oElement ) {
	var iReturnValue = 0;
	while( oElement != null ) {
		iReturnValue += oElement.offsetTop;
		oElement = oElement.offsetParent;
	}
	return iReturnValue;
}
function getX( oElement ) {
	var iReturnValue = 0;
	while( oElement != null ) {
		iReturnValue += oElement.offsetLeft;
		oElement = oElement.offsetParent;
	}
	return iReturnValue;
}

var numberonly = ["phone", "zip", "cardnum"];
var emailformart = ["email", "email2"];
var lengthlimits = {"cardnum":15};
		
if(typeof jQuery == 'function') {
	$(function() {
  		setUpTooltips();
  		if ( $('#paysubmit').length > 0 ) {
  			$($('#paysubmit').get(0).form).removeAttr('onSubmit');
  			$($('#paysubmit').get(0).form).unbind('submit');;
  			$($('#paysubmit').get(0).form).submit(function (event) {
  				return validatePayForm(event);
  			});
  			$("#email").bind('paste', function(e) {return false;});
  			$("#email2").bind('paste', function(e) {return false;});
  			
			$($('#paysubmit').get(0).form).find(':input').removeAttr('onKeyPress');
			$($('#paysubmit').get(0).form).find(':input').keypress(
				function (event) {
					pushedchar = String.fromCharCode(event.charCode);
					if ((event.charCode==null) || (event.charCode==0) || (event.charCode==8) ||
         				event.charCode || event.charCode || (event.charCode==27) )  return true;

					result = null;
					if ( $.inArray(this.id, numberonly)>-1 && ("0123456789").indexOf(pushedchar) == -1 ) {
						result = false;
					}
					if (result==null) {
						result = true;
					}
					return result;
				}
			);
			$($('#paysubmit').get(0).form).find(':input').removeAttr('onKeyUp');
			$($('#paysubmit').get(0).form).find(':input').keyup(
				function () { 
					processPipes();
				}
			);
		}
		/*
  		$('form').submit(function(){
			// On submit disable its submit button
    		$('input[type=submit]', this).attr('disabled', 'disabled');
		});
		*/
		
  		$($('#ITtimer').get(0)).removeAttr('onMouseOver');
  		$($('#ITtimer').get(0)).removeAttr('onMouseOut');
  		$("#ITtimer").qtip(	{content: lang_array[active_language]['lang_basket_timer_tooltip']});
		
	});
} else {
	//alert("no jquery");
}

function setUpTooltips () {
	$(':input').each ( function () {
		setUpTooltipHandlers(this);
	});
	/*
	$('select').each ( function () {
		if ($(this).siblings(".hint-info").length > 0) {
			setUpTooltipHandlers(this);
		}
	});*/
}

function setUpTooltipHandlers (target) {
	$(target).mouseover( function() { showAutoTooltip(this); } );
	$(target).mouseout ( function() { hideAutoTooltip(this); } );
	$(target).focus( function() { showAutoTooltip(this); } );
	$(target).focusout ( function() { hideAutoTooltip(this, true); } );
}

function showAutoTooltip (target) {
	if ($(target).siblings(".hint-info").length > 0) {	
		$(target).siblings(".hint-info").css('display', 'inline'); 
	} else {
		text = "";
		if (lang_array[active_language]['lang_'+target.id+'_comment']!==undefined) text = lang_array[active_language]['lang_'+target.id+'_comment'];
		else if (lang_array[active_language]['lang_'+target.id+'_message']!==undefined) text = lang_array[active_language]['lang_'+target.id+'_message'];
		else if (lang_array[active_language]['lang_pay_'+target.id+'_comment']!==undefined) text = lang_array[active_language]['lang_pay_'+target.id+'_comment'];
		else if (lang_array[active_language]['lang_pay_'+target.id+'_message']!==undefined) text = lang_array[active_language]['lang_pay_'+target.id+'_message'];
		if (text!==undefined && text!=="") {
		$(target).qtip(
			{
			id: 'modal',
			content: text,
  			show: {
  			 event: "none",
  			 target: $(this),
	         solo: false,
	         effect: false,
  			},
  			hide: false,
			}
		).qtip("show");
		}
	}
}
function hideAutoTooltip (target, forced) {
	if (document.activeElement!=target || forced==true) {
		if ($(target).siblings(".hint-info").length > 0) {
			$(target).siblings(".hint-info").css('display', 'none');
		} else {
			$(target).qtip("hide");
		}
	}
}

var validatePaySubresult;
function validatePayForm (event) {
	processPipes();
	var validateresult = true;
	$($('#paysubmit').get(0).form).find(":input").each(
		function () {
			if (this.id!==undefined && validateresult) validateresult = validatePayFormSub(this.id);
		}
	);
	if (!validateresult) return validateresult;
	 
	validatePaySubresult = true;
	$($('#paysubmit').get(0).form).find(':input').each (
		function () {
			if (lengthlimits[this.id]!==undefined) {
				if (checkLength(this.id, lengthlimits[this.id])==false) validatePaySubresult = false;
			}
		}
	);
	if (validatePaySubresult==false) return false;

	// terms agree
	if ($('#agree_terms').length > 0 && checkChecked('agree_terms')==false) return false;
	
	return validateresult;
}

function validatePayFormSub (itemid) {
	if (itemid=="email" && checkEmail('email')==false) return false;
	if (itemid=="email2" && checkEmail('email2')==false) return false;
	if (itemid=="email" && checkEqual('email', 'email2')==false) return false;
	if (itemid=="lastname" && checkEmpty('lastname')==false) return false;
	if (itemid=="firstname" && checkEmpty('firstname')==false) return false;
	if (itemid=="phone" && checkEmpty('phone')==false) return false;
	if (itemid=="city" && checkEmpty('city')==false) return false;
	if (itemid=="zip" && checkEmpty('zip')==false) return false;
	if (itemid=="address" && checkEmpty('address')==false) return false;
	//ccard
	if (itemid=="cardname" && checkEmpty('cardname')==false) return false;
	if (itemid=="cardnum" && checkEmpty('cardnum')==false) return false;
	// invoice
	if (itemid=="need_bill" && checkChecked('need_bill')) {
		if (checkEmpty('billing_name')==false) return false;
		if (checkEmpty('billing_taxnumber')==false) return false;
		if (checkEmpty('billing_city')==false) return false;
		if (checkEmpty('billing_zipcode')==false) return false;
		if (checkEmpty('billing_street_name')==false) return false;
		if (checkEmpty('billing_house_number')==false) return false;
	}
	// reg
	if (itemid=="wannaReg" && checkChecked('wannaReg')) {
		if (checkEmpty('password')==false) return false;
		if (checkEmpty('password2')==false) return false;
		if (checkEqual('password', 'password2')==false) return false;
	}
	
	return true;
}

function checkEmail (id) {
	var emailFilter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;
	if ($('#'+id).length > 0) {
		if ($('#'+id).val() == '' || !emailFilter.test($('#'+id).val()) ) {
			WarnError($('#'+id));
			return false;
		} else {
			RemoveWarnError($('#'+id));
		}
	}
	return true;
}
function checkEqual (id1, id2) {
	if ($('#'+id1).length > 0 && $('#'+id2).length > 0) {
		if ( $('#'+id1).val() !== $('#'+id2).val() ) {
			WarnError($('#'+id2));
			return false;
		} else {
			RemoveWarnError($('#'+id2));
		}
	}
	return true;
}
function checkEmpty (id) {
	if ($('#'+id).length > 0) {
		if ($('#'+id).val() == '') {
			WarnError($('#'+id));
			return false;
		} else {
			RemoveWarnError($('#'+id));
		}
	}
	return true;
}
function checkChecked (id) {
	if ($('#'+id).length > 0) {
		if (!$('#'+id).get(0).checked) {
			WarnError($('#'+id));
			return false;
		} else {
			RemoveWarnError($('#'+id));
			return true;
		}
	}
	return false;
}
function checkLength (id, length) {
	if ($('#'+id).length > 0) {
		if ($('#'+id).val().length < length) {
			WarnError($('#'+id));
			return false;
		} else {
			RemoveWarnError($('#'+id));
		}
	}
	return true;
}

function processPipes () {
	if ($('#paysubmit').length>0) $($('#paysubmit').get(0).form).find(':input').each (
		function () {
			var emailFilter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;
			piperesult = null;
			if ( lengthlimits[this.id]!==undefined && $(this).val().length < lengthlimits[this.id] ) {
				piperesult = false;
			}
			if ( $.inArray(this.id, emailformart)>-1 && !emailFilter.test($(this).val()) ) {
				piperesult = false;
			}
			
			if (piperesult==null && $(this).val().length>0 ) {
				piperesult = true;
			}
			if ( $('#'+this.id+'_pipe').length>0 ) {
				if (piperesult) {
					$('#'+this.id+'_pipe').css('display', 'inline');
				}
				else $('#'+this.id+'_pipe').css('display', 'none');
			}
			if (piperesult) RemoveWarnError($('#'+this.id));
		}
	);
}

function WarnError (target) {
	$(target).addClass("invalid");
	$(target).focus();
	if ($(target).siblings(".hint-error").length > 0) {
		$(target).siblings(".hint-error").css('display', 'inline');
	} else {
		if (target.id==undefined) target = $(target).get(0);
		//alert(lang_array[active_language]['lang_'+target.id+'_errormessage']);
		if (lang_array[active_language]['lang_'+target.id+'_errorrmessage']!==undefined) text = lang_array[active_language]['lang_'+target.id+'_errorrmessage'];
		else text = lang_array[active_language]['lang_pay_'+target.id+'_errormessage'];
		//alert(text);
		if (text!==undefined) {
			$(target).qtip(
				{
				id: 'modal',
				content: text,
      			show: {
      			 event: "none",
      			 target: $(target),
		         solo: true, // ...and hide all other tooltips...
		         //modal: true, // ...and make it modal
		         effect: false,
      			},
      			hide: false,
				}
			).qtip("show");
		}
	}
}
function RemoveWarnError (target) {
	$(target).removeClass("invalid");
	if ($(target).siblings(".hint-error").length > 0) {
		$(target).siblings(".hint-error").css('display', 'none');
	} else {
		$(target).qtip("hide");
	}
}

function validate_basketform() {       
	if ( getCheckedValue(document.forms['basketform'].elements['paymethod'])!=="") {
		document.basketform.submit();
		return true;
	} else {
		if (lang_array[active_language]['lang_basket_paymethoderror']!=="") alert(lang_array[active_language]['lang_basket_paymethoderror']);
		else alert("Please select payment method!");
		document.basketform.paymethodOTPSHOP3D.focus();
		return false;
	}
}

function select1() {
	document.registeredUserForm.registeredUser.checked=false;
	document.newUserForm.newUser.checked=true;
	document.getElementById("newUserReg").style.display='block'; 
	document.getElementById("registeredUserLogin").style.display='none';
	document.getElementById("payButton").style.display='block';
	document.getElementById("payTerms").style.display='block';
	document.getElementById("wannaRegBox").style.display='block';
	document.getElementById("wannaNewsBox").style.display='block';
	document.getElementById("wannaReminderBox").style.display='block';
	document.getElementById("BillingBox").style.display='block';
}

function select2() {
	document.newUserForm.newUser.checked=false;
	document.registeredUserForm.registeredUser.checked=true;
	document.getElementById("newUserReg").style.display='none'; 
	document.getElementById("registeredUserLogin").style.display='block';	
	document.getElementById("payButton").style.display='none';
	document.getElementById("payTerms").style.display='none';
	document.getElementById("wannaRegBox").style.display='none';
	document.getElementById("wannaNewsBox").style.display='none';
	document.getElementById("wannaReminderBox").style.display='none';
	document.getElementById("BillingBox").style.display='none';
}

