/**
---------------------------------------------------------------------------------------------
        EplosNET 3.0.0 PHP keretrendszer 2001-2006
---------------------------------------------------------------------------------------------
	DIV-ek kapcsolgatása
	Példa:
	<div id='menu_01' style="display:block"><a href="javascript:bekapcs('menu_02')">Menü_02</a></div>
	<div id='menu_02' style="display:none">Menü 02</div>
---------------------------------------------------------------------------------------------
*/
var stateCookieName="HunPressState";
var current_idx='';
var protect_idx='';
var newsletterRegDefaultName = '';

function bekapcs(id) {
	var obj=document.getElementById(id);
	if(obj!=null) obj.style.display='';
	current_idx=id;
}
function kikapcs(id) {
	var obj=document.getElementById(id);
	if(id!=protect_idx && obj!=null) obj.style.display='none';
	//current_idx='';
}

function switchtab(id){
	var e;
	//e=document.getElementById("tab1"); e.style.display = "none";
	//e=document.getElementById("tab2"); e.style.display = "none";
	//e=document.getElementById("tab3"); e.style.display = "none";
	//e=document.getElementById(id); e.style.display = "block";
	//current_tab=id;
}

function GetCookie(name)
{
    var index = document.cookie.indexOf(name + "=");
    if (index == -1) return null;
    index = document.cookie.indexOf("=", index) + 1;
    var endstr = document.cookie.indexOf(";", index);
    if (endstr == -1) endstr = document.cookie.length;
    return unescape(document.cookie.substring(index, endstr));
}
                                         
function SetCookie(cookieName,cookieValue,nDays)
{
 var today = new Date();
 var expire = new Date();
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}

function SaveState()
{
	SetCookie(stateCookieName,protect_idx,1);
}

function LoadState()
{
	var str=GetCookie(stateCookieName);
	current_idx=str;
	protect_idx=str;
	bekapcs(current_idx);
}

function setprotect(id)
{
	var tmp=protect_idx;
	protect_idx=id;
	kikapcs(tmp);
}

function gotopage(url)
{
	protect_idx=current_idx;
	SaveState();
	document.location.href=url;
}
/**
---------------------------------------------------------------------------------------------
	PopUpImage
---------------------------------------------------------------------------------------------
*/
function PopUpImage(imageURL2,imageWidth2,imageHeight2,imageURL,imageWidth,imageHeight) {

	if (imageURL2) imageURL = imageURL2;
	if (imageWidth2) imageWidth = imageWidth2;
	if (imageHeight2) imageHeight = imageHeight2;
	
	if (imageURL){
		var posLeft=window.screen.width/2 - imageWidth/2;
		var posTop=window.screen.height/2 - imageHeight/2;

		newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop);
		newWindow.document.open();
		newWindow.document.write('<htm'+'l><t'+'itle>Hungaropress.hu</t'+'itle><bo'+'dy bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">');
		newWindow.document.write('<img s'+'rc="'+imageURL+'" width='+imageWidth+' height='+imageHeight+'>');
		newWindow.document.write('</b'+'ody></ht'+'ml>');
		newWindow.document.close();
		newWindow.focus();
	}
}
/**
---------------------------------------------------------------------------------------------
        EplosNET 3.0.0 PHP keretrendszer 2001-2006
        Kancsal Zoltán - mail: kancsal.zoltan@proaction.hu
---------------------------------------------------------------------------------------------
	Javascript oldal nyomtatás - használatához kell egy <DIV id='printReady'>...</DIV>
---------------------------------------------------------------------------------------------
*/
function printSpecial()
{                                                                                                                      
if (document.getElementById != null)                                                                                   
{                                                                                                                      
	var html = '<HTML><HEAD>';                                                                                             
	var printreadyElem = document.getElementById("printready");                                                            
	if (printreadyElem != null)                                                                                            
	{                                                                                                                      
		var headTags = document.getElementsByTagName("head");                                                                  
		if (headTags.length > 0){
			html += headTags[0].innerHTML;                                                                                 
			var r=headTags[0].innerHTML.match(/[^\'\"\=]+\.css/);                                                          
			if(r){                                                                                                         
			if (window.XMLHttpRequest) {                                                                                   
				http_request = new XMLHttpRequest();                                                                       
				if (http_request.overrideMimeType) http_request.overrideMimeType('text/css');                              
			} else if (window.ActiveXObject) {                                                                             
				try {                                                                                                      
					http_request = new ActiveXObject("Msxml2.XMLHTTP");                                                    
				} catch (e) {                                                                                              
					try {                                                                                                  
						http_request = new ActiveXObject("Microsoft.XMLHTTP");                                             
					} catch (e) {r=0;}
				}                                                                                                          
																														   
			} else r=0;
			if(r){
				http_request.open('GET', r, false);                                                                            
				http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                            
				http_request.send(null);                                                                                       
				html+=(http_request.status==200?"\n<STYLE type='text/css'>\n"+http_request.responseText+'\n</STYLE>\n':'');    
			}
			}                                                                                                              
		}                                                                                                                      
		html += '</HE' + 'AD><BOD' + 'Y leftmargin="20" topmargin="20" marginwidth="20" marginheight="20" rightmargin="20" bottommargin="20" onload="setTimeout(\'window.print();\',100);">';                                                                                  
		html += printreadyElem.innerHTML;                                                                                      
	}                                                                                                                      
	else                                                                                                                   
	{                                                                                                                      
		alert("Az oldalnak nem létezik nyomtatható verziója!\nCould not find the printable version of this page");             
		return;                                                                                                                
	}                                                                                                                      
																														   
	html += '</BO' + 'DY></HT' + 'ML>';                          
																														   
	var printWin = window.open("","printSpecial","width=650, height=650, menubar=1, toolbar=1, location=0,status=0,scrollbars=1");                                                                                               
	printWin.document.open();                                                                                              
	printWin.document.write(html);                                                                                         
	printWin.document.close();                                                                                             
	}
}                                                                                                                      

/**
---------------------------------------------------------------------------------------------
        EplosNET 3.0.0 PHP keretrendszer 2001-2006
---------------------------------------------------------------------------------------------
	Javascript - képcsere
	
	példa:
	<a href="#" title="Mentornak" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('menu02','','images/hdr_menu_02a.gif',1)">
	<img src="images/hdr_menu_02.gif" border="0" name="menu02"/>
	</a>
	
---------------------------------------------------------------------------------------------
*/
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
MM_preloadImages('menu_head_01a.gif','menu_head_02a.gif','menu_head_03a.gif','menu_head_04a.gif','menu_head_05a.gif','menu_head_06a.gif','menu_head_07a.gif','lang_en_a.gif','lang_hu_a.gif','tab1_arrow.gif','tab2_arrow.gif','tab3_arrow.gif')

var gAutoPrint = true; 
function printSpecial() 
{ 
	if (document.getElementById != null){ 
		var html = '<HTML><HEAD>'; 
		if (document.getElementsByTagName != null){ 
			var headTags = document.getElementsByTagName("head"); 
			if (headTags.length > 0) html += headTags[0].innerHTML; 
		} 
		html += '</HE' + 'AD><BOD' + 'Y class="printext" leftmargin="30" style="background-color:#ffffff;" topmargin="30" marginwidth="30" marginheight="30" rightmargin="30" bottommargin="30">'; 
		var printreadyElem = document.getElementById("printready"); 
		if (printreadyElem != null){ 
			html += printreadyElem.innerHTML; 
		}else{ 
			alert("Az oldalnak nem létezik nyomtatható verziója! Could not find the print version of this page!"); 
			return; 
		} 
		html += '<script type=text/javascript>document.print();</'+'script></BO' + 'DY></HT' + 'ML>'; 
		var printWin = window.open("","printSpecial","width=600, height=400, menubar=1, toolbar=1, location=0,status=0,scrollbars=1"); 
		printWin.document.open(); 
		printWin.document.write(html); 
		printWin.document.close(); 
		if (gAutoPrint) 
			printWin.print(); 
	}else{  
		alert("Az Ön böngészője sajnos nem támogatja a nyomtatási funkciót! Sorry, the print ready feature is only available in modern browsers!"); 
	} 
}

/**
---------------------------------------------------------------------------------------------
        EplosNET 3.0.0 PHP keretrendszer 2001-2006
        Baldaszti Zoltan - mail: baldaszti.zoltan@proaction.hu
---------------------------------------------------------------------------------------------
	Javascript DIV ablak
---------------------------------------------------------------------------------------------
*/
var active = 0, coordsX=0,coordsY=0,dragWind;
function divwin_close(){
	dragWind.style.display='none';
}
function divwin_open(url, windowId, x, y, w, h){
	dragWind = document.getElementById('window'+windowId);
	if(dragWind==null){
		allWin = document.getElementById("windows");
		if(allWin==null) alert("Please insert <DIV id='windows'></DIV> in your code.");
		allWin.innerHTML+="<div id='window"+windowId+"' class='wins'><IFRAME id='container"+windowId+"' width=100% height=100% src='' frameborder=0 scrolling=no></IFRAME></div>";
		dragWind = document.getElementById('window'+windowId);
	}
	dragCont = document.getElementById('container'+windowId);
	dragCont.src = url;
	dragWind.style.display = 'block';
	dragWind.style.top = y;
	dragWind.style.left = x;
	dragWind.style.width = w;
	dragWind.style.height = h;
	dragWind.style.zIndex = 10;
}
document.onmouseup = new Function("active=0");
document.onselectstart = new Function("return false");

function FocusSearchField()
{
	var obj = document.getElementById('txbQuery1');
	if (obj != null) obj.focus();
	var obj = document.getElementById('txbQuery2');
	if (obj != null) obj.focus();
	var obj = document.getElementById('txbQuery3');
	if (obj != null) obj.focus();
	var obj = document.getElementById('txbQuery4');
	if (obj != null) obj.focus();
	var obj = document.getElementById('txbQuery5');
	if (obj != null) obj.focus();
	var obj = document.getElementById('txbQuery6');
	if (obj != null) obj.focus();
	
}

/**
    Lekezeli a szállítási mód változtatását
*/
function changeShippingMode()
{
    var div1 = document.getElementById('shipping_curier');
    var div2 = document.getElementById('shipping_pick_pack_point');
    var value = 'curier';
	
    if (document.f.rbtShippingModes != undefined){
		for (var i=0; i < document.f.rbtShippingModes.length; i++){
			if (document.f.rbtShippingModes[i].checked)
				value = document.f.rbtShippingModes[i].value;
		}
    }
    if (value=='curier'){
        if (div1!=null) div1.style.display = 'block';
        if (div2!=null) div2.style.display = 'none';
    }else{
        if (div1!=null) div1.style.display = 'none';
        if (div2!=null) div2.style.display = 'block';
    }
}


/**
    Lekezeli a pick pack pont kiválasztást
*/
function selectPickPackPoint()
{
    var div = document.getElementById('pick_pack_point');
    var url = location.href; 
    var input = document.f.oplPickPackPoints;

    if (input.selectedIndex>0){
        div.innerHTML = '<img src="images/ajax-loader-2.gif">';
        div.style.display = 'block';
       
        if (url.indexOf('?') != -1) url = url.substring(0, url.indexOf('?', 14));
        setTimeout('loadPickPackPoint("'+url+'?pickPackPointId='+input.options[input.selectedIndex].value+'")', 200);
    }
}
/**
    Betölti a Pick Pack Pont adatait
    @argURL     string      Ajax URL
*/
function loadPickPackPoint(argURL)
{
    var html = ajaxLoad(argURL);
    var div = document.getElementById('pick_pack_point');
    var link = document.getElementById('pickpackpointlink');
	
	div.innerHTML = '<a href="'+link.href+'" target="new"></a>'+html;
}
/**
 *Módosítja a DIV állapotát
*/
function switchdiv(enable,divid)
{
	var obj = document.all?document.all[divid]:document.getElementById(divid);
    if (obj!=null)
        if (obj.style!=null)
            obj.style.display=(enable?"block":"none");
}


/**
    AJAX hívás
    @argURL        string        URL cím
*/
function ajaxLoad(argURL)
{
    var http_request=null;
    document.cursor='progress';
    //létrehozzuk az objektumot
    if (window.XMLHttpRequest) {
        //Mozilla és minden más értelmes böngésző
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) http_request.overrideMimeType('text/html');
    } else if (window.ActiveXObject) {
        //hülye IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }

    }
    if(!http_request) {    document.cursor='default';return('ERROR');}
    //lekérjük a megadott urlt, és visszaadjuk a tartalmát
    http_request.open('GET', argURL, false);
    http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
    http_request.send(null);
    document.cursor='default';
    return(http_request.status==200?http_request.responseText:'');
}

/**
	Elküldi a hírlevél-regisztrációt
	@argMessage1	string		Hiányzó név esetén megjelenő hibaüzenet
	@argMessage2	string		Hibás e-mail cím esetén megjelenő üzenet
*/
function sendNewsletterRegistration(argMessage1, argMessage2)
{
	if (document.newsletter.txbName.value	== newsletterRegDefaultName) document.newsletter.txbName.value ='';
		
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var email = document.newsletter.txbEmail.value;
	
	if (document.newsletter.txbName.value == ''){ alert(argMessage1); document.newsletter.txbName.focus(); return false;}
	else if (email == ''){ alert(argMessage2);document.newsletter.txbEmail.focus(); return false;}
	else if (reg.test(email) == ''){ alert(argMessage2);document.newsletter.txbEmail.focus(); return false;}


	var loading = document.getElementById('loading');
	if (loading!==null){
		loading.style.display='block';
		loading.innerHTML = '<img src="images/ajax-loader-3.gif">';
	}
	document.newsletter.submit();
	for (i=0;i<document.newsletter.elements.length;i++)
		document.newsletter.elements[i].disabled = true;
}
/**
 *	Kiteszi a hírlevél-reg. folyamat végén megszületű üzenetet
 *	@argMessage	string		Üzenet
*/
function newsletterRegistrationMessage(argMessage)
{
	for (i=0;i<document.newsletter.elements.length;i++)
		document.newsletter.elements[i].disabled = false;
	var loading = document.getElementById('loading');
	if (loading!==null)	loading.style.display='none';
	if (argMessage) alert(argMessage);
	document.newsletter.txbEmail.value = '';
	document.newsletter.txbName.value = '';
}
/**
	A CMS index admin felületéhez szükséges
*/
function OpenDialogWindow(iWidth,iHeight,URL)
{
var iLeft=window.screen.width/2 - iWidth/2;
var iTop=window.screen.height/2 - iHeight/2 - 25;

if (objDialogWindow != null)
{
if (!objDialogWindow.closed)
{
objDialogWindow.close();
while (fClosed != objDialogWindow.closed)
{
fClosed = objDialogWindow.closed;
}
}
}
objDialogWindow=window.open(URL,"_blank",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=' + iWidth + ',height=' + iHeight + ',screenX=' + iLeft + ',screenY=' + iTop + ',left=' + iLeft + ',top=' + iTop);
}

