function check_text_length(formobj_field,max) {
    if (formobj_field.value.length > max) {
        alert("Maximum " + max + " karakter engedélyezett!");
        formobj_field.value = formobj_field.value.substring(0,max);
        formobj_field.focus();
        }
    }
    
function checkForm (formobj,begin,end,nextpage) {
  	     
    var error = '';
    var check_psd = '';
  	var hibas = 0;
  	var set = false;
    
    if(formobj.elements[0].value == 'név') { 
        formobj.elements[0].value = '';
        }
                                     //e-mail cím <-> jelszó
    if(formobj.elements[1].value == 'jelszó') { 
        formobj.elements[1].value = '';
        }
         
    if (begin == undefined && end == undefined) {
        begin = 0;
        end = formobj.elements.length-1;
        }
         
  	for (i = begin; i <= end; i++) {
	    if (formobj.elements[i].value == '' && (formobj.elements[i].title != '-')) {
		  	error += "A(z) '"+formobj.elements[i].title+"' mező üres!\n";
			if (set == false) {
				hibas = i;
				set = true;
				}
			}
	    if ((formobj.elements[i].value[0] == ' ') && (formobj.elements[i].title != '-')) {
		  	error += "Nem lehet szóköz az első karakter!\n";
			}
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if (formobj.elements[i].name.indexOf('mail') != -1 && formobj.elements[i].value && !filter.test(formobj.elements[i].value)) {
			error += "Hibás e-mail cím!\n";
			if (set == false) {
				hibas = i;
				set = true;
				}
			}                 
                    
        if (formobj.elements[i].type == "password" && formobj.elements[i-1].type == "password") {       
            check_psd = "no";   
            if (formobj.elements[i].value != '' && formobj.elements[i-1].value != '') {
                if (formobj.elements[i].value != formobj.elements[i-1].value) {
                    error += "A két új jelszó nem egyezik meg!\n";
                    }
                    else if (formobj.elements[i].value.length <= 4) {
                        error += "Az új jelszónak minimum 5 karakternek kell lennie!\n";
                        }
                        else {
                            check_psd = "yes";;
                            }
                }
            }
		}                     
        
	if (error) {
	  	alert (error);
        formobj.elements[hibas].focus();
		}
	    else {
            if (check_psd == "no" ) {
                formobj.pass_1.value = formobj.pass_old.value;
                }
            formobj.submit();
		    }     
	}
    
function input_enter(evt,formobj_field) {
    
    evt = (evt) ? evt : event;
    
    var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
      
    if (charCode == 13 && character != 13) {
        document.getElementById(formobj_field).onclick();
        }
        
    character = charCode;
    }
           /*
function daysInMonth(month,year) {
    var m = [31,28,31,30,31,30,31,31,30,31,30,31];
    if (month != 2) return m[month - 1];
    if (year%4 != 0) return m[1];
    if (year%100 == 0 && year%400 != 0) return m[1];
    return m[1] + 1;
    }    */
              
function countback() {
    var td = document.getElementById('countback');
    
    now = new Date();

    now_year  = now.getFullYear();
    now_month = now.getMonth();
    now_day   = now.getDate();
    now_h   = now.getHours();
    now_min = now.getMinutes();
    now_sec = now.getSeconds();
    
    var target = new Date();
    
    target_year = 2007;
    target_month = 10;
    target_day = 28;
    target_h = 0;
    target_min = 0;
    target_sec = 0;
    
    counter_sec = target_sec - now_sec;
    counter_min = target_min - now_min;
    counter_h = target_h - now_h;
    counter_day = target_day - now_day;
    counter_month = target_month - now_month;
    counter_year = target_year - now_year;
    
    if(counter_sec<0) {
        counter_sec = counter_sec + 60;
        counter_min = counter_min - 1;
        }
    
    if(counter_min<0) {
        counter_min = counter_min + 60;
        counter_h = counter_h - 1;
        }
    
    if(counter_h<0) {
        counter_h = counter_h + 24;
        counter_day = counter_day - 1;
        }
        
    if(counter_day<0) {
        counter_day = counter_day + 31;
        counter_month = counter_month - 1;
        }
           
    if(counter_month<0) {
        counter_day = 0;
        counter_h = 0;
        counter_min = 0;
        counter_sec = 0;
        }       
    
    var counterStr = '';
                 
    if(counter_day<10) {
        counterStr += "0";
        }   
        
    counterStr += counter_day;
               
    counterStr += ((counter_h < 10) ? ":0" : ":") + counter_h;
    counterStr += ((counter_min < 10) ? ":0" : ":") + counter_min;
    counterStr += ((counter_sec < 10 ) ? ":0" : ":") + counter_sec;
    
    var tempStr='';
    
    for(var i = 0; i<counterStr.length; i++) {
        tempStr += '<img src="">';
        }
        
    imgs = td.getElementsByTagName('img');
            
    imgs[0].src = number[counterStr.charAt(0)].src;
    imgs[1].src = number[counterStr.charAt(1)].src;

    imgs[3].src = number[counterStr.charAt(3)].src;
    imgs[4].src = number[counterStr.charAt(4)].src;
  
    imgs[6].src = number[counterStr.charAt(6)].src;
    imgs[7].src = number[counterStr.charAt(7)].src;
    
    imgs[9].src = number[counterStr.charAt(9)].src;
    imgs[10].src = number[counterStr.charAt(10)].src;
    
    window.setTimeout('countback()',1000); 
    }
    
    
         /*
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
    }

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
    }

function eraseCookie(name) {
	createCookie(name,"",-1);
    }    
         */
         
var sum = 0;
         
function calculate(evt,code) {   
    evt = (evt) ? evt : event;
    
    var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
      
    if (charCode != 13 && code !== undefined) { 
       
        num = document.getElementById('quantity_'+code).value;
        price = document.getElementById('quantum_'+code).value;
        
        if(num<=999 && num>=0) {
            document.getElementById('price_'+code).innerHTML = num * price;
            }
            else {                                
                document.getElementById('quantity_'+code).focus(); 
                alert("A beírt érték nem szám!") ;
                }
        }
        
    spans = taska.getElementsByTagName('span');
    
    sum = 0;
    for(var i=0 ;i < spans.length; i++) {
        sum = sum-0+(spans[i].innerHTML-0);
        }
            
    document.getElementById('sum_price').innerHTML = sum;    
    
    }
    
function change_color(code, color, color_name) {
    
    var dir = "products/falimatrica/" + code + "/normal/";
    
    document.getElementById('product_pic_normal').src = dir + color + "_" + color_name+ ".jpg";
    document.getElementById('color').innerHTML = color_name;
    
    }
    
function confirmDelete(jumpTo) {
	var input_box=confirm("Biztosan törli?");
	if (input_box==true) { 
		eval("location='"+jumpTo+"'");
		}
	}
    
function openPic(imageURL,imageTitle,imageDesc) {

    imageTitle='';
    imageDesc='';
    // Set the horizontal and vertical position for the popup
    PositionX = 100;
    PositionY = 100;
    // Set these value approximately 20 pixels greater than the
    // size of the largest image to be used (needed for Netscape)
    defaultWidth  = 385;
    defaultHeight = 380;
    // Set autoclose true to have the window close automatically
    // Set autoclose false to allow multiple popup windows
    var AutoClose = true;
    // Do not edit below this line...
    // =========
    if (parseInt(navigator.appVersion.charAt(0))>=4){
        var isNN = (navigator.appName == "Netscape") ? 1 : 0;
        var isIE = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
        }
        
    var optNN = 'scrollbars=no,width=' + defaultWidth + ',height=' + defaultHeight + ',left=' + PositionX + ',top=' + PositionY;
    var optIE = 'scrollbars=no,width=150,height=100,left=' + PositionX + ',top=' + PositionY;

    if (isNN) {
        imgWin = window.open('about:blank','',optNN);
        }
        else if (isIE) {
            imgWin = window.open('about:blank','',optIE);
            }
            else {
                imgWin = window.open('about:blank','',optIE);
                isIE = true;
                }
                
    with (imgWin.document){
        writeln('<html><head><title>Loading...</title><style>body{margin-bottom:32px;margin-left:8px;margin-right:8px;margin-top:8px;font-family:tahoma, arial, helvetica, Geneva, sans-serif;}</style>');
        writeln('<sc'+'ript>');
        writeln('var isNN,isIE,isOP');
        writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
        writeln('isNN=(navigator.appName=="Netscape")?1:0;');
        writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
        writeln('isOP=(navigator.appName=="Opera")?1:0;');
        writeln('function reSizeToImage(){');
        writeln('if (isIE){');
        writeln('window.resizeTo(100,100);');
        writeln('width=parseInt(document.images[0].width)+16;');
        writeln('height=parseInt(document.images[0].height)+40;');
        writeln('window.resizeTo(width+8,height+35);}');
        writeln('if (isNN){');       
        writeln('window.innerWidth=document.images["George"].width+16;');
        writeln('window.innerHeight=document.images["George"].height+16;}');
        writeln('if (isOP){');
        writeln('window.resizeTo(100,100);');
        writeln('width=parseInt(document.images[0].width)+25;');
        writeln('height=parseInt(document.images[0].height)+65;');
        writeln('window.resizeTo(width,height);}}');
        //writeln('function doTitle(){document.title="' + imageTitle + '";}');
        writeln('</sc'+'ript>');

        if (!AutoClose) {                            
            writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">');
            }
            else {
                writeln('</head><body bgcolor=ffffff scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
                writeln('<img name="George" src=' + imageURL + ' style="display:block"> <center>' + imageDesc + '</center></body></html>');
                close();
                }                 
        }
    
    }       
    
function taska_check(formobj) {
    if(!document.getElementById('aszf').checked) {
        alert('El kell olvasni az ÁSZF-et!');
        }
        else {
            formobj.submit();
            }
    }
                /*
function getPixelsFromTop(obj){
    objFromTop = obj.offsetTop;
	while(obj.offsetParent!=null) {
	    objParent = obj.offsetParent;
		objFromTop += objParent.offsetTop;
		obj = objParent;
		}
	return objFromTop;
	}
    
function getPixelsFromLEFT(obj){
    objFromLEft = obj.offsetLeft;
	while(obj.offsetParent!=null) {
	    objParent = obj.offsetParent;
		objFromLeft += objParent.offsetLeft;
		obj = objParent;
		}
	return objFromTop;
	}     */
    
    
function drop_down_menu_show(formobj_field) {
    formobj_field.style.position = 'relative';
    formobj_field.style.backgroundColor = '#EBEAEA';
    
    ul=formobj_field.getElementsByTagName('ul');
    
    ul[0].style.display= 'block';
    }
    
function drop_down_menu_hide(formobj_field) {
    formobj_field.style.backgroundColor = '#FBFBFB';
    
    ul=formobj_field.getElementsByTagName('ul');
    
    ul[0].style.display= 'none';
    }
    
function submenu_show(formobj_field) {
    formobj_field.style.position = 'relative';
    formobj_field.style.backgroundColor = '#EBEAEA';
    
    ul=formobj_field.getElementsByTagName('ul');
                  
    ul[0].style.display= 'block';    
    }
    
function submenu_hide(formobj_field) {
    
    ul=formobj_field.getElementsByTagName('ul');
    
    ul[0].style.display='none';
    }
    
function open_material_pic(url) {
    var pic = new Image();
    pic.src = "images/art/" + url;
    
    var w = window.open('','_blank','channelmode=yes,directories=no,fullscreen=no,location=no,menubar=no,resizeable=no,scrollbars=no,status=no,titlebar=no,toolbar=no');
    w.resizeTo(430,475);
    w.moveTo(0,0);
    w.document.write('<table align="center">');
    w.document.write('<tr valign="bottom">');
    w.document.write('<td align="center" style="margin: 0px; padding: 0px"><img src="' + pic.src + '" align="center" border="0" style="padding: 0px; margin: 0px; padding-bottom: 20px"/></td>');
    w.document.write('</tr>');
    w.document.write('</table>');
    w.focus();          
    }
    
function help_item_show(formobj_field) {            

    td = formobj_field.parentNode.parentNode;

    imgs = td.getElementsByTagName('img');
    ps = td.getElementsByTagName('p');
    
    for(i=1; i<imgs.length; i++) {
        imgs[i].src = "images/opretro_help_item_off_pic.gif";
        }
        
    for(i=1; i<ps.length-2; i++) {
        ps[i].style.display = "none";
        i++;
        }

    formobj_field.src = "images/opretro_help_item_on_pic.gif";
    p = formobj_field.parentNode.nextSibling;
    if(p.nodeName!="P") {
        p = p.nextSibling;
        }
    p.style.display = "block";
    }

function system_years(begin) {
    now = new Date();
    now_year  = now.getFullYear(); 
                                       
    td = document.getElementById('system_years');
    td.innerHTML="&copy; " + begin + "-" + now_year + " Opretro";
    }