/****************************************************************************************************
program type:               Javascript include file
name: 			    popup.js
description:                this file contains the functions for creating and closing a popup window

copyright � 2005 by FIRMENPUNKT GmbH

client:                     -
documentation:              - 
date (dd/mm/yyyy):          01/06/2005
created by (with email):    andrea wildberger <aw@firmenpunkt.de>
last modified (dd/mm/yyyy): 
reason for modification:    
modified by (with email):   

function		|arguments          | return             |   description
------------------------------------------------------------------------------------------------------
ClosePopup      |-                  |-                   |   Closes the popup window
CreatePopup     |url, width, height | true or false      |   Creates a popup window

*****************************************************************************************************/


	var pop = null; // declare variable pop and set to null

	/**************************************************************************
	function:                   ClosePopup
	description:                Closes the open popup created with CreatePopup
	calling parameter:          -
	return:                     -
	templates used:             -
	date (dd/mm/yyyy):          01/06/2005
	created by:                 andrea wildberger <aw@firmenpunkt.de>
	last modified (dd/mm/yyyy): 
	reason of modification:     
	modified by:                
	**************************************************************************/
	function ClosePopup() {
		if (pop && !pop.closed) pop.close(); // if pop exists and not closed close the popup
	}
	
	/**************************************************************************
	function:                   CreatePopup
	description:                creates an popup window and load an url 
								within this popup
	calling parameter:          url, width, height
	return:                     true or false (true = continue without popup,
								false=continue with popup
	templates used:             -
	date (dd/mm/yyyy):          01/06/2005
	created by:                 andrea wildberger <aw@firmenpunkt.de>
	last modified (dd/mm/yyyy): 
	reason of modification:     
	modified by:                
	**************************************************************************/	
	function CreatePopup(url,width,height) {
		if (!url) return true; //  If there is no URL  Return true and continue without popup
			
		if(width) width += 20; // if there exists a width add 20 pixels to the width
		else width = 500; // set width to 500 (standard width)

		if(height) height += 25; // if there exists a height add  25 pixels to the height
		else height = 1000; // set height to 400 (standard height)
			
		// build argument string for window.open function
		var args = 'width='+width+',height='+height+',resizable=no,toolbar=no,status=no,location=no,menubar=no,scrollbars=yes';
		
		ClosePopup(); // if there is already a popup open, close it
	
		pop = window.open(url,'win',args); // open the new popup windows

		if(pop) return false; //  if the creation of the popup was successful, return false => stop all other activities 
		else return true; // return true => continue without popup
	}
	
	function addfavorite() {
		if(arguments.length > 0)
			var product_name = '   '+arguments[0];
		else
			var product_name = '';
		if (document.all) {
			window.external.addFavorite(window.location.href,'Porta-italia'+product_name);//Sustain IE6,IE7.
		} else if (window.sidebar) {
			window.sidebar.addPanel('Porta-italia'+product_name, window.location.href, "");//Sustain FireFox;
		}
	} 
	
	function $(){
	var len = arguments.length;
	var obj;
	if(len > 2 || len < 1){
		alert("error");
		return false;	
	}
	if(arguments[1] == "id" || arguments[1] == undefined)
		obj = document.getElementById(arguments[0]);
	if(arguments[1] == "name")
		obj = document.getElementByName(arguments[0]);
	return obj;
}

function changeObjectImage(oSelf){
	var sSelfUrl = oSelf.src;
	$('ObjectImage').parentNode.href = oSelf.src.replace('ObjectThumb_','');
	oSelf.src = $('ObjectImage').src.replace('Object_','ObjectThumb_');
	$('ObjectImage').src = sSelfUrl.replace('Thumb','');
}
