/* ---------------------------------------------------------------------
/
/     global.js
/     
/     11.01.06 fse
/
/  -------------------------------------------------------------------- */

// ----------------------------------------------------------
//  resets the values of all text/textarea-fields
//  in the "dataform"-form
// ----------------------------------------------------------

function resetform()
{
	var i;
	var fieldType;

	for  (i=1; i < document.dataform.elements.length;i++) {
		fieldType = document.dataform.elements(i).type.toUpperCase()
		if (fieldType == "TEXT" || fieldType == "TEXTAREA") {
			document.dataform.elements(i).value = "";
		}
	}

}


function breakFrameSetScript () {
if (self != top) 
{
	parent.location.href=self.location.href;
} 
}


function createWindow(URL, windowName, width, height) {

    var features =
        'width='        + width +
        ',height='      + height +
        ',directories=yes' +
        ',location=yes'    +
        ',menubar=yes'     +
        ',scrollbars=yes'  +
        ',status=yes'      +
        ',toolbar=yes'   +
        ',Resizable=yes' ;

    window.open (URL, windowName, features);
}


function newWindow(URL, windowName) 
{
	fenster=window.open (URL, windowName, "width=800,height=600,left=0,top=0,scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,location=yes,directories=yes,status=yes");
	setTimeout("fenster.focus()",40);
} 


function popUpWindow(URL, windowName, width, height) {

    var features =
        'width='        + width +
        ',height='      + height +
        ',top=100' +
        ',directories=no' +
        ',location=no'    +
        ',menubar=no'     +
        ',scrollbars=yes'  +
        ',status=no'      +
        ',toolbar=no'   +
        ',Resizable=no' ;

    fenster=window.open (URL, windowName, features);
    setTimeout("fenster.focus()",40);

}


function PTpopUpWindow(URL,sTitle,sPara) 
{
	window.open(URL,sTitle,sPara);
} 


function survey(URL, windowName) 
{
window.location.href="extras/Customer_Survey/Customer_Survey.asp";
window.open (URL, windowName, "width=650,height=650,left=0,top=0,scrollbars=yes,resizable=yes,menubar=no,toolbar=no,location=no,directories=no,status=no");
}

// -----------------------------------------------------------------------
//
//	 used to resize a flash according to the actual screen size
//
//-----------------------------------------------------------------------

function setFlashSizeAccordinglyToWindowsSize(){

//	var x;
	var ratio;
	var flash = document.getElementById('three_tier');

	if (flash != null)
	{
/*
		if (self.innerHeight) // all except Explorer
		{
			x = self.innerWidth;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
			// Explorer 6 Strict Mode
		{
			x = document.documentElement.clientWidth;
		}
		else if (document.body) // other Explorers
		{
			x = document.body.clientWidth;
		}

		// If the width would be wider Then the maxwith (as Set In the css) Then make it the maxwidth

		if (x > 1000) { 
			x = 1000;
		}
*/
		// calcuate the ratio from the given width And height
		ratio = flash.getAttribute('height') / flash.getAttribute('width');
		
		// subtract the width of the fixed Left And Right columns of the webpage To Get the width of the content area
		flash.setAttribute('width',((1000-185)*0.82)*0.93) ;


		// Set the content-areas width as width To the flash And Set the height accordinly by using the calcuated ratio
		flash.setAttribute('height',flash.getAttribute('width') * ratio );


	} // flash != null
}

function setPicSizeAccordinglyToWindowsSize(){
//	var x;
	var ratio;
	var image = document.getElementById('ersatzbildlink').firstChild;

	if (image != null)
	{
/*

		if (self.innerHeight) // all except Explorer
		{
			x = self.innerWidth;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
			// Explorer 6 Strict Mode
		{
			x = document.documentElement.clientWidth;
		}
		else if (document.body) // other Explorers
		{
			x = document.body.clientWidth;
		}

		// If the width would be wider Then the maxwith (as Set In the css) Then make it the maxwidth

		if (x > 1000) { 
			x = 1000;
		}
*/		
		// calcuate the ratio from the given width And height
		ratio = image.getAttribute('height') / image.getAttribute('width');
		
		// subtract the width of the fixed Left And Right columns of the webpage To Get the width of the content area
		image.setAttribute('width',((1000-185)*0.82)*0.93);

		// Set the content-areas width as width To the image And Set the height accordinly by using the calcuated ratio
		image.setAttribute('height',image.getAttribute('width') * ratio );

	} // image != null
}

// used to open a link from a popup
// if opend in an popup the link will open in the main window and close the popup
// if open alone it will open the link in its own href
function openLink(link){
	if (link != null)
	{
		try
		  {
				aufrufer = self.opener;
				if (typeof(aufrufer) == "undefined" || aufrufer == null || aufrufer.name != "stellen") {
					self.location.href = link;
				}
				else {
					aufrufer.location.href  = link;
					self.close();
				} 
		 }
                                     // Zugriff auf aufrufer.name verweigert
                                    // also Zugriff von aussen, daher eigenes Fenster neu laden
		catch(err)
		  {
		           self.location.href = link;		 
                                      }
	}
}
