var asi = null;

function getRandom(hfid, hfid2, image)
{
var rand_no = Math.floor((3-0)*Math.random()) + 1;
document.getElementById(hfid).value = rand_no;
document.write('<input name="checkimage" type="image" id="checkimage" src="../images/'+rand_no+'.jpg" align="absmiddle" border="1" />');
if (rand_no==1) { document.getElementById(hfid2).value ="K7TF35"}
if (rand_no==2) { document.getElementById(hfid2).value ="RWC93G"}
if (rand_no==3) { document.getElementById(hfid2).value ="KIH2S6"}
//alert(document.getElementById("proba").value);
}

function Elkuld()
{
alert("Ellenőrizve000");
sm =new SendMail();
sm.To = "horvathrobert@cartour.hu"; 
sm.Subject = "Partypanzió foglalás"
sm.Body = document.getElementById("Messsage").value;
alert("Ellenőrizve.");
if (sm.send()) {alert("Elküldve.");}
  else alert("Nincs elküldve.");


}

function Ell(kod, szoveg)
{
var jo = false;
var code1 = document.getElementById(kod).value;
var code2 = document.getElementById(szoveg).value;

if (code1==1) {
	if (code2 == "K7TF35")
	  {
	    jo = true;
	  }
}
if (code1==2) {
	if (code2 == "RWC93G")
	  {
	    jo = true;
	  }
}
if (code1==3) {
	if (code2 == "KIH2S6")
	  {
	    jo = true;
	  }
}
if (jo) { Elkuld();}

/*switch (code1)
  {
   case 1:
	alert("Küldés2");
	if (code2 == "K7TF35")
	  {
	    Elkuld();
	  }
	else alert("Hibás ellenőrző kód!");
	break;
   case 2:
	alert("Küldés3");
	if (code2 == "RWC93G")
	  {
	    Elkuld();
	  }
	else alert("Hibás ellenőrző kód!");
  }
*/
}

function getImgWidth(Src)
{
var newImg = new Image();
newImg.src = Src;
var width = newImg.width;
return width;
}

function getImgHeight(Src)
{
var newImg = new Image();
newImg.src = Src;
var height = newImg.height;
return height;
}

function ClosePicture()
{
		parent.document.body.removeChild(parent.window.document.getElementById("DIV_CLOSER"));
//		parent.window.onresize = parent.window.onscroll = null;
//		if (asi) asi.hide();
		parent.document.body.removeChild(parent.window.document.getElementById("szurke"));
}

function CallParentWindowSize(scroll)

{
	var s = (parent.document.all? parent.document.documentElement.scrollTop : parent.window.pageYOffset);
        return s;
}

function ShowPicture(skep, rootkep)
{
	asi = new xFormGrey('ATLATSZO');
	asi.show();
	var oDiv=parent.document.createElement("DIV");	oDiv.className = "CLASS_PICTURE_WINDOW";
	oDiv.id = "DIV_CLOSER";
	oDiv.style["position"] = "absolute";
	var w = getImgWidth(rootkep);
	var h = getImgHeight(rootkep);
	var s = (parent.document.all? parent.document.documentElement.scrollTop : parent.window.pageYOffset);
//	var ps = CallParentWindowSize(scroll);
	var x = 20+s;
	var y = 150;
//((parent.document.body.clientWidth - w) / 2);
	if (y < 0) {y = 10};
// alert(y+"    h:"+h+"   w:"+w);
	oDiv.style["top"] = x+"px";
	oDiv.style["left"] = y+"px";
	oDiv.style["cursor"] = "pointer";
	oDiv.style["overflow"] = "hidden";
	oDiv.innerHTML = "<IMG src = '"+ skep + "' ; onClick='ClosePicture()'; title='Bezáráshoz kattintson a képre...' />";
	parent.document.body.appendChild(oDiv);
	DeleteSelectTags();
}

function xFormGrey(sDivClass)
{
  this.ele = parent.document.createElement('div');
  this.ele.id = "szurke";
  this.ele.className = sDivClass;
  parent.document.body.appendChild(this.ele);
  this.show = function()
  {
    if (this.ele) {
      var ds = xDocSize();
      xMoveTo(this.ele, 0, 0);
      xResizeTo(this.ele, ds.w , ds.h);
    }
  };
  this.hide = function()
  {
    if (this.ele) {
      xResizeTo(this.ele, 10, 10);
      xMoveTo(this.ele, -10, -10);
    }
  };
}

function xHeight(e,h)
{
  if(!(e=xGetElementById(e))) return 0;
  if (xNum(h)) {
    if (h<0) h = 0;
    else h=Math.round(h);
  }
  else h=-1;
  var css=xDef(e.style);
  if (e == parent.document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    h = xClientHeight();
  }
  else if(css && xDef(e.offsetHeight) && xStr(e.style.height)) {
    if(h>=0) {
      var pt=0,pb=0,bt=0,bb=0;
      if (parent.document.compatMode=='CSS1Compat') {
        var gcs = xGetComputedStyle;
        pt=gcs(e,'padding-top',1);
        if (pt !== null) {
          pb=gcs(e,'padding-bottom',1);
          bt=gcs(e,'border-top-width',1);
          bb=gcs(e,'border-bottom-width',1);
        }
        else if(xDef(e.offsetHeight,e.style.height)){
          e.style.height=h+'px';
          pt=e.offsetHeight-h;
        }
      }
      h-=(pt+pb+bt+bb);
      if(isNaN(h)||h<0) return;
      else e.style.height=h+'px';
    }
    h=e.offsetHeight;
  }
  else if(css && xDef(e.style.pixelHeight)) {
    if(h>=0) e.style.pixelHeight=h;
    h=e.style.pixelHeight;
  }
  return h;
}

function xWidth(e,w)
{
  if(!(e=xGetElementById(e))) return 0;
  if (xNum(w)) {
    if (w<0) w = 0;
    else w=Math.round(w);
  }
  else w=-1;
  var css=xDef(e.style);
  if (e == parent.document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    w = xClientWidth();
  }
  else if(css && xDef(e.offsetWidth) && xStr(e.style.width)) {
    if(w>=0) {
      var pl=0,pr=0,bl=0,br=0;
      if (parent.document.compatMode=='CSS1Compat') {
        var gcs = xGetComputedStyle;
        pl=gcs(e,'padding-left',1);
        if (pl !== null) {
          pr=gcs(e,'padding-right',1);
          bl=gcs(e,'border-left-width',1);
          br=gcs(e,'border-right-width',1);
        }
        else if(xDef(e.offsetWidth,e.style.width)){
          e.style.width=w+'px';
          pl=e.offsetWidth-w;
        }
      }
      w-=(pl+pr+bl+br);
      if(isNaN(w)||w<0) return;
      else e.style.width=w+'px';
    }
    w=e.offsetWidth;
  }
  else if(css && xDef(e.style.pixelWidth)) {
    if(w>=0) e.style.pixelWidth=w;
    w=e.style.pixelWidth;
  }
  return w;
}

function xLeft(e, iX)
{
  if(!(e=xGetElementById(e))) return 0;
  var css=xDef(e.style);
  if (css && xStr(e.style.left)) {
    if(xNum(iX)) e.style.left=iX+'px';
    else {
      iX=parseInt(e.style.left);
      if(isNaN(iX)) iX=xGetComputedStyle(e,'left',1);
      if(isNaN(iX)) iX=0;
    }
  }
  else if(css && xDef(e.style.pixelLeft)) {
    if(xNum(iX)) e.style.pixelLeft=iX+"px";
    else iX=e.style.pixelLeft;
  }
  return iX;
}

function xTop(e, iY)
{
  if(!(e=xGetElementById(e))) return 0;
  var css=xDef(e.style);
  if(css && xStr(e.style.top)) {
    if(xNum(iY)) e.style.top=iY+'px';
    else {
      iY=parseInt(e.style.top);
      if(isNaN(iY)) iY=xGetComputedStyle(e,'top',1);
      if(isNaN(iY)) iY=0;
    }
  }
  else if(css && xDef(e.style.pixelTop)) {
    if(xNum(iY)) e.style.pixelTop=iY+"px";
    else iY=e.style.pixelTop;
  }
  return iY;
}

function xMoveTo(e,x,y)
{
  xLeft(e,x);
  xTop(e,y);
}


function xResizeTo(e,w,h)
{
  xWidth(e,w);
  xHeight(e,h);
}

function al(uzi)
{
alert(uzi);
}

function xDocSize()
{
  var b=parent.document.body, e=parent.document.documentElement;
  var esw=0, eow=0, bsw=0, bow=0, esh=0, eoh=0, bsh=0, boh=0;
  if (e) {
    esw = e.scrollWidth;
    eow = e.offsetWidth;
    esh = e.scrollHeight;
    eoh = e.offsetHeight;
  }
  if (b) {
    bsw = b.scrollWidth;
    bow = b.offsetWidth;
    bsh = b.scrollHeight;
    boh = b.offsetHeight;
  }
  return {w:Math.max(esw,eow,bsw,bow),h:Math.max(esh,eoh,bsh,boh)};
}

function xDef()
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

function xNum()
{
  for(var i=0; i<arguments.length; ++i){if(isNaN(arguments[i]) || typeof(arguments[i])!='number') return false;}
  return true;
}
function xGetElementById(e)
{
  if(typeof(e)=='string') {
    if(parent.document.getElementById) e=parent.document.getElementById(e);
    else if(parent.document.all) e=parent.document.all[e];
    else e=null;
  }
  return e;
}

function xStr(s)
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
  return true;
}

function xGetComputedStyle(e, p, i)
{
  if(!(e=xGetElementById(e))) return null;
  var s, v = 'undefined', dv = parent.document.defaultView;
  if(dv && dv.getComputedStyle){
    s = dv.getComputedStyle(e,'');
    if (s) v = s.getPropertyValue(p);
       
  }
  else if(e.currentStyle) {
    v = e.currentStyle[xCamelize(p)];
  }
  else return null;
  return i ? (parseInt(v) || 0) : v;
}

function xCamelize(cssPropStr)
{
  var i, c, a = cssPropStr.split('-');
  var s = a[0];
  for (i=1; i<a.length; ++i) {
    c = a[i].charAt(0);
    s += a[i].replace(c, c.toUpperCase());
  }
  return s;
}

function DeleteSelectTags()
{
    return true;
}


