function v(){
}

function ClearMe (Ctarget, defaultval) {
 if (Ctarget.value == defaultval) Ctarget.value = '';
}
function CheckMe (Ctarget, defaultval) {
 if (Ctarget.value == '') Ctarget.value = defaultval;
}

function updateTimer(timerID) {
 timer_remaining = timer_current-timer_offset;
 //alert(timer_remaining);
 if (timer_remaining<0) timer_remaining = 0;
 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 {
			//alert('basket.php?listonly&pm='+pval);
			AjaxUpdMode = "html";
			document.getElementById('itemlist_container_cover').style.display="block";
			//document.getElementById(AjaxUpdTarget).innerHTML = "";
			AjaxObj.Open('basket.php', '?listonly&pm='+pval+'&dm='+dval, AjaxUpd, null, AjaxUpdTarget, AjaxUpdMode);
			//alert('basket.php?listonly&pm='+pval);
		}
	}
 } 
  var currcharge = deliverycharges[dval];
  var currpaycharge = paycharges[pval];
  netprice_f = document.getElementById('netprice');
  delcharge_f = document.getElementById('delcharge');
  var bnp = netprice_f.innerHTML.replace(" ", "")-delcharge_f.innerHTML.replace(" ", "");
  var selectedcharge = currcharge==undefined ? 0 : currcharge;
  var selectedpaycharge = currpaycharge==undefined ? 0 : currpaycharge;
  if (delcharge_f!==null) delcharge_f.innerHTML = number_format(selectedcharge+selectedpaycharge, decimalcount, ".", " ");
  if (netprice_f!==null) netprice_f.innerHTML = number_format(bnp+selectedcharge+selectedpaycharge, decimalcount, ".", " ");
 
}

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 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);
}



