/*Promotions begin*/

function showLayerPromotions(item,promId,layernumPromotions,HaltNow) {
	if (HaltNow!="") {UpdateBlackList(promId);}
	closeAllLayerPromotions(promId,layernumPromotions);
	var actLayer = findLayerPromotions(promId + item);
	var actLink = findLinkPromotions(promId + item + '_link');
	actLink.className = 'A';
	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');
		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).style);
	if (document.all) return(document.all[item].style);
	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/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/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/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()
    {
        if (Start==1)
        {   
        var x;
        var Banners = BannerList.split(",");
        for (x in Banners)
            {
            var BannerItems = Banners[x].split(":");
            SwitchPromos(BannerItems[0]+"_",BannerItems[1]);
            }
        }
        Start=1; setTimeout('doSwitching()',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)
    {
    i=0;
    Found=0;
    for (i=0; i<=bcCount; i++)
        {
        if (BlackList[i]==Pattern) {Found=1;}
        }
    if (Found!=1)
        {
        var PromoItems = new Array(MaxLinks)
        for (i=1 ; i<=MaxLinks ; i++)
            {
            var actLayer = findLayerPromotions(Pattern + String(i));
            if (actLayer.display!="none")
                {
                ActualItem=i;
                }
            }
        if ((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 validateEmail(field, form) {
	email_address = form.elements[field].value;
	at = email_address.indexOf('@');
	dot = email_address.indexOf('.');
	
	if (at == -1 || 
		dot == -1 || 
		dot <= at + 1 ||
		dot == 0 || 
		dot == email_address.length - 1
	) {
        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,2}$/)) {
		form.elements['phone2'].focus();
		return false;
	}
	
	if (! phone3.match(/^\d{6,7}$/)) {
		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;
	}
}
/* Validation scripts end */
