//-------------------------------------------------------------
//                      Javascript                          ---
//------------------------------------------------------------- 
//-------------------------------------------------------------
//---  © copyright absolute development ag 2005             ---
//-------------------------------------------------------------
//   projekt name  :                                        ---
//   file name     : functions.js                           ---
//   directory     : /_js                                   ---
//   version       : 1.0                                    ---
//   created at    :                                        ---
//   created by    :                                        ---
//   change hisory :                                        ---
//   changed at    :                                        ---
//-------------------------------------------------------------


/* %%%%%%%%%%%% FORM FUNCTIONS %%%%%%%%%%% */ 
// let user confirm; FORM SUBMIT 
function isOKFormSubmit (sFormName,sMessage) 
	{ if(confirm(sMessage)) window.document.forms[sFormName].submit(); } 	

// let user confirm; FORM SUBMIT 2
function isOKFormSubmit2 (sFormName,sMessage, val) 
	{ if(confirm(sMessage)){
	  window.document.forms[sFormName].fld_action.value=val;
	  window.document.forms[sFormName].submit();} 
    } 	
	
function isOKFormSubmit3 (sForm, sMessage, val)
    { if(confirm(sMessage)){
	  sForm.form.fld_action.value=val;
	  sForm.form.submit();} 
    }	
    
// let user confirm; LOCATION   
function isOKlocation (sURL, sMessage) 
	{ if(confirm(sMessage)) {location.href = sURL;} } 	
 
// check / uncheck all checkboxes in form
// sFromname =  Form name (String)
// sCheckboxName = Checkbox Field Name (String)
// bChecked = checked or not (Boolean : true/false)
function checkAllBoxes (sFormName, sCheckboxName, bChecked) 
	{ 
	iUpperBound = document.forms[sFormName].elements[sCheckboxName].length;		
	for(var iX = 0; iX < iUpperBound; iX++)
		document.forms[sFormName].elements[sCheckboxName][iX].checked = bChecked;
	} 	

    
    
 
/* %%%%%%%%%% QUICK SEARCH FUNCTION %%%%%%%%%% */    
// send form    
function quickSearch(){
   // set variables 
   var fname = "frm_quicksearch"; 
   var vaSearchValue = document.forms[fname].fld_searchValue.value;
   var vaSearchValueLen = document.forms[fname].fld_searchValue.value.length;
   
   // check if search value is empty
   if (vaSearchValue == ""){
        alert ("Bitte geben Sie einen Suchbegriff ein");
        document.forms[fname].fld_searchValue.focus();
        return false;
        }
        
   if (vaSearchValueLen <= 3){
        alert ("Bitte geben Sie min. 4 Buchstaben als Suchbegriff ein");
        document.forms[fname].fld_searchValue.focus();
        return false;
        }
   // if ok then submit
   window.document.forms[fname].submit();

}  


/* %%%%%%%%%% SENDTO CHAR-CHECK AND VALIDATOR %%%%%%%%%%% */
// character count
function calcCharLeft(target){
    // set max value for textarea
    var maxLength = 1000;
    if (target.value.length > maxLength){
        target.value = target.value.substring(0,maxLength);
        charleft = 0;}
    else {charleft = maxLength - target.value.length;}
    
    document.frm_sento.msg_len.value = charleft;
}
      
// SENDTO CHECK   
function checkSendTo(sFormName,sMessage){
    // set variables 
    var fname = "frm_sento"; 
    var vaRecipientEmail = document.forms[fname].fld_RecipientEmail.value;
    var vaFromEmail = document.forms[fname].fld_FromEmail.value;
   
    // RECIPIENT EMAIL CHECK
    if (vaRecipientEmail == ""){
        alert ("Bitte geben die Email Adresse des Empfängers ein");
        document.forms[fname].fld_RecipientEmail.focus();
        return false;
        }
    if (vaRecipientEmail != ""){
    	if (vaRecipientEmail.indexOf('@') == -1 && vaRecipientEmail.indexOf('.') == -1 ){
    			alert ("Bitte geben Sie eine gültige EMail Adresse an");
    			document.forms[fname].fld_RecipientEmail.focus();
    			return false;} 
        }        
    // FROM EMAIL CHECK
    if (vaFromEmail == ""){
        alert ("Bitte geben ihre Email Adresse ein");
        document.forms[fname].fld_FromEmail.focus();
        return false;
        }    
    if (vaFromEmail != ""){
    	if (vaFromEmail.indexOf('@') == -1 && vaFromEmail.indexOf('.') == -1 ){
    			alert ("Bitte geben Sie eine gültige EMail Adresse an");
    			document.forms[fname].fld_FromEmail.focus();
    			return false;} 
        }   
    // confirm message 
    if(confirm(sMessage)){window.document.forms[fname].submit();} 	     

}  

/* %%%%%%%%%%%% WINDOW FUNCTIONS %%%%%%%%%%% */ 
// print window
function printWindow(){
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
}




/* %%%%%%%%%% OPEN WINDOW FUNCTIONS %%%%%%%%%% */      
function ImageGallery(link)
    {
        var w=window.open(link,"Gallery","scrollbars=no,resizable=yes,width=576,height=530")
        w.focus();
    }

function Popup(link)
    {
        var w=window.open(link,"galerie","scrollbars=no,resizable=no,width=440,height=550")
        w.focus();
    }
    
function pup(where)
	{ 
        var w = window.open(where, "graphic_win", "scrollbars=1,resizable=0,width=526,height=312")
        w.focus()
	}
 
function askTheExpert()
    {
	    var newWind=window.open('expert.cfm?aoid=#vaArticleObjectID#','remote','width=576,height=530 top=0 left=0');
	    if (newWind.opener == null){ 
		    newWind.opener = window;}
	}
    
var tipWin = null;  
function streamWin(str)
    {
        window.open(str,'tipWin1','width=489,height=400,resizeable=no,scrollbars=no');
    }
    function streamStream(str)
    {
        window.open(str,'tipWin1','width=430,height=345,resizeable=no,scrollbars=no');
    }
    
function streamMotion(str)
    {
        window.open(str,'tipWin2','width=555,height=385,resizeable=no,scrollbars=no');  
    }
    
 function streamBirdseye(str)
    {
        window.open(str,'tipWin2','width=510,height=405,resizeable=no,scrollbars=no');  
    }
    
function streamWinInd(str)
    {
        window.open(str,'tipWin','width=300,height=420,resizeable=no,scrollbars=no');
    }
    
function streamWint(str)
    {
        window.open(str,'tipWin','width=300,height=365,resizeable=no,scrollbars=no');
    }
    
function ImageDetail(link)
	{
		var w=window.open(link,"ImageDetail","scrollbars=no,resizable=yes,width=576,height=530")
		w.focus();
	}

function OpenQuiz(link)
	{
		var w=window.open(link,"Gallery","scrollbars=no,resizable=no,width=650,height=490")
		w.focus();
	}	
	
function OpenHelp(link)
	{
		var w=window.open(link,"helpScreen","scrollbars=yes,resizable=yes,width=550,height=500,left=100,top=100,toolbar=no,status=yes")
		w.focus();
	}	

function nomina(str)
    {
        window.open(str,'tipWin','width=650,height=480,resizeable=no,scrollbars=no');
    }
    
function streamapero1(str)
    {
        window.open(str,'tipWin1','width=650,height=500,resizeable=no,scrollbars=no');
    }    

 function streamapero2(str)
    {
        window.open(str,'tipWin2','width=650,height=500,resizeable=no,scrollbars=no');
    } 

 function streamapero3(str)
    {
        window.open(str,'tipWin3','width=400,height=308,resizeable=no,scrollbars=no');
    } 
function orbit(str)
    {
        window.open(str,'tipWin3','width=480,height=440,resizeable=no,scrollbars=no');
    } 
	
function orbitbig(str)
    {
        window.open(str,'tipWin3','width=1020,height=700,resizeable=no,scrollbars=no');
    } 

function StreamTally(str)
    {
        window.open(str,'tipWin1','width=624,height=305,resizeable=no,scrollbars=no');
    } 
	
function StreamTally2(str)
    {
        window.open(str,'tipWin2','width=400,height=244,resizeable=no,scrollbars=no');
    } 
function on2(str)
    {
        window.open(str,'tipWin','width=450,height=510,resizeable=no,scrollbars=no');
    } 
function spycam(str)
    {
        window.open(str,'tipWin','width=650,height=400,resizeable=no,scrollbars=no');
    } 	
function eHealth(str)
    {
        window.open(str,'tipWin1','width=380,height=210,resizeable=no,scrollbars=no');
    } 	
function eHealth_on2(str)
    {
        window.open(str,'tipWin2','width=460,height=258,resizeable=no,scrollbars=no');
    } 
function apero2005_7(str)
    {
        window.open(str,'tipWin1','width=662,height=392,resizeable=no,scrollbars=no');
    } 
function apero2005_8(str)
    {
        window.open(str,'tipWin2','width=662,height=392,resizeable=no,scrollbars=no');
    } 
function eichhof2(str)
    {
        window.open(str,'tipWin','width=590,height=330,resizeable=no,scrollbars=no');
    } 
	
function TW1(str)
    {
        window.open(str,'tipWin','width=502,height=282,resizeable=no,scrollbars=no');
    } 
	
function TW2(str)
    {
        window.open(str,'tipWin','width=512,height=284,resizeable=no,scrollbars=no');
    } 
function oMedia(str,w,h,name){
		if(name != ''){
			windowName = name;
		}else{
			windowName = "win1";
		}
        window.open(str,windowName,'width='+w+',height='+h+',resizeable=no,scrollbars=no');
    } 	
/*    // SENDTO CHECK   
function chk_formular_xcelsius(){
    // set variables 
    var fname = "frm_xcelsius"; 
    var el_len = document.forms[fname].elements.length;
    for (i=0;i<el_len;i++) {
        if (document.forms[fname].elements[i].type == "text") {
            elname = document.forms[fname].elements[i].name;
            myprefix = elname.substring(0,3);
            myrealname = elname.substring(4,elname.length);
            myvalue = document.forms[fname].elements[i].value;
            error = myprefix == "req" && myvalue == "";
            if (!error && myprefix == "req" && myrealname == "email") {
                error = myvalue.indexOf('@') == -1 || myvalue.indexOf('.') == -1;
            }
            if (error){
                alert ("Bitte füllen sie das Feld "+myrealname.substring(0,1).toUpperCase()+myrealname.substring(1,myrealname.length)+" korrekt aus");
                document.forms[fname].elements[i].focus();
                return false;
            }
        }
    }
    return true;
}  
*/
