/*
Java Script used for manipulation on IFRAMES
written by : W. Struk WEiTI on 01.06.2010
included by: design.ini
used in    : article.tpl
*/

/* set global domain for iframe intercommunication - very important */
document.domain = 'elka.pw.edu.pl';

global_CommonDomain=false;
global_Doc='';
/* set global domain for iframe intercommunication - very important */

function initiateFrame(iframeID){

    /* set dynamically frame height */
    //setFrameHeight(iframeID);

    // after reload scroll iframe to top
    location.href = '#';
    //window.scrollTo(0,0);
    //alert('top');
}
function initFrame(iobj,minh){

    /* set dynamically frame height */
    iframeID=iobj.id;
    //alert('ID='+iframeID);
    if (minh) {cminh=minh;} else {cminh=400;}
    setFrameHeight(iframeID,cminh);
    //setOurFrameHeight(iframeID);

    // after reload scroll iframe to top
    location.href = '#';
    //window.scrollTo(0,0);
    //alert('top');

//	    alert("CF1="+cframe);
//    cframe.onfocus=startInteracting();
//	    alert("CF3="+cframe);
}

function resetSemSelection(isel){
 iform=isel.form;
 for( i=0; i<iform.elements.length; i++ ) {
    if (iform.elements[i].type.indexOf("select") != -1 ) {
        if (iform.elements[i] != isel) {
	    iform.elements[i].selectedIndex = 0;
	}
    }
 }
}

function checkGroupInput(iform){
//    if (iform.grupa1.value) return true;
 found=0;
 i=0;
 while (!found && i<iform.elements.length) {
//     if ( iform.elements[i].name.indexOf("R_") != -1 ) {
//        if ( iform.elements[i].type.indexOf("checkbox") != -1 ) {
//    	if (iform.elements[i].checked) found++;
        if ( iform.elements[i].type.indexOf("select") != -1 ) {
        	if (iform.elements[i].selectedIndex != 0) {
//		iform.mode.value='grupa';
        	return true;
        	}
	}
       i++;
  }
 alert('Nie wybrano grupy !');
 return false;
}

function loadFrame(iframe,ilang){
  iframeID=iframe.id;
  cframe = document.getElementById(iframeID);
//    alert('BEF='+ilang+' '+iframeID);

  if (cframe != undefined && cframe != null) {

    // check frame domain
    checkFrameDomain(iframeID);

    if (global_CommonDomain){
	cbody=global_Doc.body;
        /* translate dynamically frame content */
	ibody=cbody.innerHTML;

        switch (iframeID) {
	 case '_iframe_employee_list': {
    	    if (ilang==2) {
//alert(ilang);
	    ibody=ibody.replace(/Lista pracowników/gi, 'Employee list');
	    ibody=ibody.replace(/brak w bazie wskazanej osoby:/gi, 'Employee not found:');
	    }
	    ibody=ibody.replace(/<td /gi, '<td style="background:#d5d5d5;color:blue;font-size:120%;font-weight:bold;" ');

	    ibody=ibody.replace(/<\/tbody>\s*<\/table>\s*<table border=1>/gi, '<table border=1>');
	    ibody=ibody.replace(/<\/tbody>\s*<\/table>\s*<table border="1">/gi, '<table border=1>');
	    ibody=ibody.replace(/<table border=1>\s*<tbody>/gi, '');
	    ibody=ibody.replace(/<table border="1">\s*<tbody>/gi, '');
	    ibody=ibody.replace(/<TR>/i, '<table class="emp_list2" border="1"><tbody><TR>');
	    ibody=ibody.replace(/<table class=/gi, '<table width="100%" class=');
//		ibody=ibody.replace(/<h3/i, '<tr><td style="background:#165f8d;"><h3');
//		ibody=ibody.replace(/<\/h3>/i, '<\/h3><\/td><\/tr>');
// special data correction
	    ibody=ibody.replace(/SJ34424@SGH.WAW.PL/, 'sjablonski@stud.elka.pw.edu.pl');
//Muraszkiewicz
	    ibody=ibody.replace(/7853/, '+4822 234 7497');
//Plonski
	    ibody=ibody.replace(/zaworek14@o2.pl/, 'pplonski86@gmail.com');
// special data correction
	    ibody='<style>table.bez td{background:#f2f2f2;} table.emp_list td{background:#c5c5c5;color:blue;font-size:120%;font-weight:bold;}</style>' + ibody;
//		ibody=ibody + '</tbody></table>';
         }
	 default: {
	  a=1;
//		ibody=ibody.replace(/Lista pracowników/gi, 'Employee list');
//		ibody=ibody.replace(/brak w bazie wskazanej osoby:/gi, 'Employee not found:');
		//ibody='<body style="font-size:+4;"> ' + ibody + " </body>"; does not work
         }
        }
//    iname2='Przedmioty';
//    crepl="target='" + iname2 + "'>";
//    ibody=ibody.replace(/ target="przedmioty">/gi, crepl);
//    crepl="target='" + iname2 + "'>";
//    ibody=ibody.replace(/ target='legenda'>/gi, crepl);
    /* set dynamically frame height */
//frameBodyHeight=cbody.scrollHeight;
//alert(frameBodyHeight);

	cbody.innerHTML=ibody;
        frameBodyHeight=cbody.scrollHeight;
//alert(frameBodyHeight);
        cframe.height=frameBodyHeight + 10;
//    alert(cbody.innerHTML);
    }
  }
}

function setDivSrc(divID, csrc){
    cdiv = document.getElementById(divID);
    cdiv.innerHTML=csrc;
//    alert('DS3='+cdiv.innerHTML);


cform=document.employee_search;
cdata=cform.s_nazwisko.value;
//cdata=escape(cdata);

//cdata='&#347;liwa';
cform.s_nazwisko.value=cdata;

//alert(cform.s_nazwisko.value);

    return true;
}

function setDivSrc2(divID, csrc){
    cdiv = parent.document.getElementById(divID);
    cdiv.innerHTML=csrc;
//    alert('DS3='+cdiv.innerHTML);


cform=document.employee_search;
cdata=cform.s_nazwisko.value;
//cdata=escape(cdata);

//cdata='&#347;liwa';
cform.s_nazwisko.value=cdata;

//alert(cform.s_nazwisko.value);

    return true;
}


function setFrameHeight(iframeID,minh){

    // check frame domain
    checkFrameDomain(iframeID);

    if (global_CommonDomain) {
        cbody=global_Doc.body
        /* translate dynamically frame content */
	ibody=cbody.innerHTML;
/*
        ibody=ibody.replace(/<script>/i,
//'<script>\n<!--\nfunction elka_manageLinks(event) {\nalert("iframe");\nreturn false;\n}\n alert("this");\ndocument.onclick=elka_manageLinks;\n-->\n</script><script>alert("added");');
//'<script language="JavaScript" type="text/javascript">function elka_manageLinks(event) {alert("iframe");return false;} alert("this");document.onclick=elka_manageLinks;</script><script>');
'<script language="JavaScript" type="text/javascript">\n<!--\n alert("this");\n//-->\n</script>\n<script>');
*/
//        ibody=ibody.replace(/CDATA\[ \*\//i, 'CDATA[*/ alert("after CDATE");');

    /* set dynamically frame height */
    //framePageHeight=cframe.getAttribute('height');
	frameBodyHeight=cbody.scrollHeight;
//    alert("SIZE="+ frameBodyHeight);
///    alert("SIZE1="+ cframe.height);
///    cframe.style.height=frameBodyHeight + 10;   // works only for IE
	cfh=frameBodyHeight + 10;
	if (minh) {
	    if (minh > cfh) {cfh=cminh;}
	}
	cframe.height=frameBodyHeight + 10;		// works for IE, FF
//    alert("SIZE2="+ cframe.height);

    }
}
function checkFrameDomain(iframeID){
//  iframeID=iframe.id;
  global_CommonDomain=false;
  commonDomainError=false;
  cframe = document.getElementById(iframeID);
//    alert('BEF='+ilang+' '+iframeID);

  if (cframe != undefined && cframe != null) {
//    global_Doc=cframe.name;
//    alert('BEF=');
    try{	// for IE
	global_Doc = cframe.contentDocument;
    }
    catch(error){
	commonDomainError=true;
//	alert(error);
    }
    if (!commonDomainError) {
	global_Doc = cframe.contentDocument;
        if (global_Doc == undefined || global_Doc == null) global_Doc = cframe.contentWindow.document;
	if (global_Doc != undefined && global_Doc != null) {
	    try{
		cdomain=global_Doc.domain;
	    }
	    catch(error){
		commonDomainError=true;
//		alert(error);
	    }
	    if (!commonDomainError) {
		if (global_Doc.domain == document.domain) {
		    global_CommonDomain=true;
		}
	    }
	}
    }
  }
/*
    if (!global_CommonDomain) {
	alert("Unknown common domain !!!\nPlease, contact administrator.");
    }
*/
}

function changeMetaData(cobj){

//alert(cobj.parent.document.lista_osob_frame);

    //window.scrollTo(0,0);
//     <meta name="Content-Type" content="text/html; charset=utf-8" />

return;

  var metaArray = document.getElementsByName('Content-Type'); 
  for (var i=0; i<metaArray.length; i++) { 
//   document.getElementsByName('Content-Type'); 
//    metaArray.content='text/html; charset=iso-8859-2';
//    document.write(metaArray[i].content + '<br>'); 
  }
    document.getElementsByName('Content-Type')[0].content='text/html; charset=iso-8859-2';
/*
    metaArray[0].content='text/html; charset=iso-8859-2';
    document.write(document.getElementsByName('Content-Type')[0].content + '<br>'); 
    window.location.reload();

//window.parent.frames[0].location.reload();"


    alert('CH='+document.getElementsByName('Content-Type')[0].content); 
*/
//    alert('CH='+document.getElementsByName('Content-Type')[0].content); 
}

function popupWin(act,wnam,w,h,l,t) {
 if (wnam=="") wnam="Help";
 conf="resizable=yes,scrollbars=yes";
 if (w<=0) w=800; conf=conf + ",width=" + w;
 if (h<=0) h=640; conf=conf + ",height=" + h;
 if (l<=0) l=0; conf=conf + ",left=" + l;
 if (t<=0) t=0; conf=conf + ",top=" + t;
 wnam=window.open(act,wnam,conf);
 wnam.focus();
}

/* TESTS */


/* end of TESTS */

/* end of file */

