/*Promotions begin*/

function showLayerPromotions(item,promId,layernumPromotions,HaltNow) {
	if (!item) return;
	if (HaltNow!="") {UpdateBlackList(promId);}
	closeAllLayerPromotions(promId,layernumPromotions);
	var actLayer = findLayerPromotions(promId + item);
	var actLink = findLinkPromotions(promId + item + '_link');
	if (actLink) actLink.className = 'A';
	if (actLayer) actLayer.display = '';
}



function closeAllLayerPromotions(promId,layernumPromotions){
	for (i=1 ; i<=layernumPromotions ; i++) {
		var actLayer = findLayerPromotions(promId + i);
		actLayer.display = 'none';
		var actLink = findLinkPromotions(promId + i + '_link');
		if (actLink) 
			actLink.className = 'NA';
	}
}

function hideLayerPromotions(item){
	var actLayer = findLayerPromotions(item);
	actLayer.visibility = 'hidden';
}

function findLayerPromotions(item) {
	if( window.mmIsOpera ) return(document.getElementById(item).style);
	if (document.getElementById) return(document.getElementById(item) ? document.getElementById(item).style : false);
	if (document.all) return(document.all[item] ? document.all[item].style : false);
	return(false);
}

function findLinkPromotions(item) {
	if( window.mmIsOpera ) return(document.getElementById(item));
	if (document.getElementById) return(document.getElementById(item));
	if (document.all) return(document.all[item]);
	return(false);
}
/*Promotions end*/

	
function PopupOpen (fileurl, win)
{
	window.open( fileurl,'gallery',"scrollbars=yes,resizable=no,width=590,height=520");	
	return false;
}





function createActiveXObject(id)
{
  var error;
  var control = null;

  try
  {
    if (window.ActiveXObject)
    {
      control = new ActiveXObject(id);
    }
    else if (window.GeckoActiveXObject)
    {
      control = new GeckoActiveXObject(id);
    }
  }
  catch (error)
  {
    ;
  }
  return control;
}


var WMP7;

if ( navigator.appName != "Netscape" ){   
     //WMP7 = new ActiveXObject('WMPlayer.OCX.7');
     WMP7 = createActiveXObject('WMPlayer.OCX.7');
}


function moviepopup(fn) {
	var s='';
	// Windows Media Player 7 Code
	if ( WMP7 )
	{
	     s+='<OBJECT ID=MediaPlayer width=320 height=305 ';
	     s+=' CLASSID=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6';
	     s+=' standby="Loading Microsoft Windows Media Player components..."';
	     s+=' TYPE="application/x-oleobject">';
	     s+='<PARAM NAME="url" VALUE="http://www.mol.hu/mol_hu/movies/'+fn+'">';
	
	     s+='<PARAM NAME="AutoStart" VALUE="true">';
	     s+='<PARAM NAME="ShowControls" VALUE="true">';
	     s+='<PARAM NAME="uiMode" VALUE="full">';
	     s+='</OBJECT>';
	}
	
	// Windows Media Player 6.4 Code
	else
	{
	     //IE Code
	     s+='<OBJECT ID=MediaPlayer ';
	     s+='CLASSID=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 ';
	     s+='CODEBASE=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715 ';
	     s+='standby="Loading Microsoft Windows Media Player components..." ';
	     s+='TYPE="application/x-oleobject" width="320" height="240">';
	     s+='<PARAM NAME="FileName" VALUE="http://www.mol.hu/mol_hu/movies/'+fn+'">';
	     s+='<PARAM NAME="AutoStart" VALUE="true">';
	     s+='<PARAM NAME="ShowControls" VALUE="1">';
	     s+='<param name="ShowStatusBar" value="1">';
	
	     //Netscape code
	     s+='    <Embed type="application/x-mplayer2"';
	     s+='        pluginspage="http://www.microsoft.com/windows/windowsmedia/"';
	     s+='        filename="http://www.mol.hu/mol_hu/movies/'+fn+'"';
	     s+='        src="http://ncnetshow/station1.asx"';
	     s+='        Name=MediaPlayer';
	     s+='        ShowControls=1';
	     s+='        ShowDisplay=0';
	     s+='        ShowStatusBar=1';
	     s+='        width=320';
	     s+='        height=240>';
	     s+='    </embed>';
	
	     s+='</OBJECT>';
	}
	
	p = window.open('','','toolbar=no,location=no,directories=no,menubar=no,resizable=no,status=no,scrollbars=auto,width=320,height=300'); 
	p.document.write("<HTML><style>body {margin:0px}</style><body>"+s+"</body>");
	p.document.close();
	
}

/*AutoPromo begin*/
Start=0;
var BlackList = new Array();
var bcCount = 0;

function doSwitching(triggered)
    {
        if (Start==1 && BannerList != "" && triggered)
        {   
            var x;
            var Banners = BannerList.split(",");
            for (x in Banners)
            {
                var BannerItems = Banners[x].split(":");
                SwitchPromos(BannerItems[0]+"_",BannerItems[1]);
            }
            setTimeout('doSwitching(1)',TimeOut||5000);
        } 
        else if (!Start) {
            Start=1; setTimeout('doSwitching(1)',TimeOut||5000);
        }
    }

function UpdateBlackList(Pattern)
    {
    NoUpdate=0;
    i=0;
    while (i<=bcCount)
        {
        if (BlackList[i]==Pattern) {NoUpdate=1;}
        i++;
        }
    if (NoUpdate!=1) {BlackList[bcCount]=Pattern; bcCount++;}
    }
   
function SwitchPromos(Pattern,MaxLinks)
    {
    var i=0;
    var Found=0;
    for (i=0; i<=bcCount; i++)
        {
        if (BlackList[i]==Pattern) {Found=1;}
        }
    if (Found!=1)
        {
        var PromoItems = new Array(MaxLinks)
        ActualItem = null;
        for (i=1 ; i<=MaxLinks ; i++)
            {
            var actLayer = findLayerPromotions(Pattern + String(i));
            if (actLayer.display!="none")
                {
                ActualItem=i;
                }
            }
        if ((ActualItem == null || ActualItem+1)>MaxLinks) {
        		m=1;
        } 
        else {
        	m=ActualItem+1;
        }
        showLayerPromotions(m,Pattern,MaxLinks,"");
        }
    }
/*AutoPromo end*/

/* Validation scripts start */

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

function validateText(field, form)
{
    if (form.elements[field].value.trim() == "") {
        //form.elements[field].focus();
        return false;
    } else {
        return true;
    }
}

function validateSelect(field, form)
{
    if (form.elements[field].value == 0) {
        //form.elements[field].focus();
        return false;
    } else {
        return true;
    }
}

function validateRadio(field, form)
{
    var el = document.getElementsByName(field);
    var i;
    for (i = 0; i<el.length; i++) {
        if (el[i].checked) return true;
    }
    return false;
}

function validateEmail(field, form) {
	email_address = form.elements[field].value;
	if (! email_address.match(/^[-\w\d._]+\@[-\w\d._]+\.[\w]+$/)) {
        //form.elements[field].focus();
        return false;
    } else {
        return true;
    }
}

function validatePhone(form, required, prefix) {
	phone1 = form.elements[prefix + '1'].value.trim();
	phone2 = form.elements[prefix + '2'].value.trim();
	phone3 = form.elements[prefix + '3'].value.trim();
	
	if (! required && phone1 == '' && phone2 == '' && phone3 == '') {
		return true;
	}
	
	if (phone1 != '' && ! phone1.match(/\d{1,3}$/)) {
		//form.elements['phone1'].focus();
		return false;
	}

	if (! phone2.match(/^\d{1,3}$/)) {
		//form.elements['phone2'].focus();
		return false;
	}
	
	if (! phone3.match(/^\d{6,8}$/)) {
		//form.elements['phone3'].focus();
		return false;
	}
 
	return true;
}

function validateTime(form, prefix) {
	day = form.elements[prefix + 'day'].value.trim();
	hour = form.elements[prefix + 'hour'].value.trim();
	minute = form.elements[prefix + 'minute'].value.trim();
	
	if (! day.match(/^\d{1,2}$/) || day < 1 || day > 31) {
		//form.elements['day'].focus();
		return false;
	}
	
	if (! hour.match(/^\d{1,2}$/) || hour < 1 || hour > 24) {
		//form.elements['hour'].focus();
		return false;
	}
	
	if (! minute.match(/^\d{1,2}$/) || minute < 0 || minute > 59) {
		//form.elements['minute'].focus();
		return false;
	}
	return true;
}

function validatePostalCode(field, form) {
    if (!form.elements[field].value.match(/^\d{4}$/)) {
        //form.elements[field].focus();
        return false;
    } else {
        return true;
    }
}

function validatePostalCode6(field, form) {
    if (!form.elements[field].value.match(/^\d{4,6}$/)) {
        //form.elements[field].focus();
        return false;
    } else {
        return true;
    }
}

function validateNumber(field, form, min, max) {
    if (!form.elements[field].value.match(/^\d+$/)) {
        return false;
    } else {
        if (min != undefined && form.elements[field].value < min) return false;
        if (max != undefined && form.elements[field].value > max) return false;
        return true;
    }
}

/* Validation scripts end */

/** Kirowski kerdoiv tartalmak **/
function popupWindow(mypage, myname, w, h, scroll) {
    var winl = 70;
    var wint = 70;
    winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no,status=1'
    win = window.open(mypage, myname, winprops)
    if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
// Cookie tools
function setCookie(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 getCookie(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);
}

function checkPopup(site) {
    if ( getCookie("popupShown") != 1 )
    { 
        popupWindow('http://ad2.kirowski.com/mol_kerdoiv/popup.php?site='+site,'questionnaire',400,240,1);
        setCookie("popupShown",1);
    }
}
// -->

//-----------------------------------------------------
//onmeretezo popupablak kepeknek
//-----------------------------------------------------
 function picwin(img)
 {
 popup = window.open('','','toolbar=no,location=no,directories=no,menubar=no,resizable=yes,status=no,scrollbars=auto,width=200,height=100');

 var sz = " "
 + "function getElementStyle(elementId) {"
 + " if (document.getElementById)"
 + " return document.getElementById(elementId).style;"
 + " else if (document.all) "
 + " return document.all[elementId].style;"
 + " else if (document.layers) "
 + " document.layers[elementId];"
 + "}"
 + "function updateWindow() { "
 + " getElementStyle('wait').display='none';"
 + " resizeTo(document.images[0].width+40,document.images[0].height+60);"
 + " window.clearInterval(timer);"
 + "}"
 + "var timer = null;"
 + "function checkImage() { "
 + " if (document.images.length>0 && (document.images[0].width>0 || document.images[0].height>0)) { "
 + " resizeTo(document.images[0].width+40,document.images[0].height+60);"
 + " window.clearInterval(timer);"
 + " } "
 + "}"
 + "timer = window.setInterval(checkImage, 500);";




 popup.document.write("<HTML><head><script>"+sz+"</script></head>");
 popup.document.write('<BODY>');
 popup.document.write('<div id="wait" name="wait" style="position:absolute;left:10px;top:10px; font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: black; background-color: #eee; padding: 2px;">Loading...</div>');
 popup.document.write('<IMG name=kep id=kep src="'+img+'"  border=0 onclick="self.close()" onLoad="');
 popup.document.write("updateWindow()");
 popup.document.write('"></BODY></HTML>');
 popup.document.close();
 }

//-----------------------------------------------------                                            
//Dokumentum szelesseget lekeri                                                                    
//-----------------------------------------------------                                            
function getInnerWidth() {                                                                         
    if (self.innerWidth) //Minden kiveve explorer                                                  
    {                                                                                              
        return self.innerWidth;                                                                    
    }                                                                                              
    else if (document.documentElement && document.documentElement.clientWidth) // Explorer 6 strict
    {                                                                                              
        return document.documentElement.clientWidth;                                               
    }                                                                                              
    else if (document.body) // Minden mas explorer                                                 
    {                                                                                              
        return document.body.clientWidth;                                                          
    }                                                                                              
    return false;                                                                                  
}                                                                                                  

/* Slovnaft calculatora */
function changeDev(){
    var ch       = 30.126;

    var devtype  = document.getElementById('chEur');
    var srcdev   = document.getElementById('chdev1');
    var srcdest  = document.getElementById('chdev2');
    
    switch(devtype.value){
        case '1':
            srcdest.value = srcdev.value * ch;
            break;
        case '2':
            srcdest.value = srcdev.value / ch;
            break;
    }
    
}

/* gri_ipieca_and_ungc_compliance_table OPEN / CLOSE */
function handlerTableOpenClose(el){
    $(el).parent('div').eq(0).toggleClass('openTable');
    return false;
}
