var timeoutId;
var TimeoutID;
var mode = 1;



function nowe_okno() {
	window.open('https://www.zagiel.com.pl/kalkulator/jak_kupic.html', 'nowe_okno',
	'width=600,height=500,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
}
function validate_Zagiel() {
	if (document.goShop.id_nazwy_pola_raty_zgoda.checked==false){
		alert ("Zanim złożysz zamówienie, zapoznaj sie z procedura udzielenia kredytu ratalnego eKredyt Żagiel.");
		
		return false;
	} else {
		
		return true;
	}
}




function PoliczRate(koszyk) {
window.open('https://www.zagiel.com.pl/kalkulator/index_smart.php?action=getklientdet_si_rata&shopNo=11490675&goodsValue='+koszyk, 'Policz_rate',
'width=630,height=500,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
}



function getAbsoluteLeft(objectId)
{

	// Get an object left position from the upper left viewport corner

	// Tested with relative and nested objects

	if ( document.getElementById(objectId) == null ) {
		
		alert(document.getElementById(objectId));
		
	}
	
	o = document.getElementById(objectId)

	oLeft = o.offsetLeft            // Get left position from the parent object

	while(o.offsetParent != null) {    // Parse the parent hierarchy up to the document element

		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		o = oParent

	}

	// Return left postion

	return oLeft

}

function makeSublist(parent,child,isSubselectOptional,childVal)
{
	
	$("body").append("<select style='display:none' id='"+parent+child+"'></select>");
	$('#'+parent+child).html($("#"+child+" option"));
	
		var parentValue = $('#'+parent).attr('value');
		//wypelnienie dziecka wartosciami na podstawie indexu rodzica ale tylko podczas initu
		$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());
	
	//domyslna wartosc indexu w dziecku ktora trzeba zaznaczyc moze byc pusta
	childVal = (typeof childVal == "undefined")? "" : childVal ;
	
	//jezeli puste zrob disbled selecta ale tylko podczas initu
	if( $('#'+child).children().length == 0) {
				
				$("#"+child).attr('disabled','disabled');
				$('#'+child).prepend("<option value='0'>brak</option>")
			} else {
				
				if(isSubselectOptional) $('#'+child).prepend("<option value='0'> -- Wybierz -- </option>");
				$("#"+child).attr('disabled','');
			}
	
	//zdarzenie onchange rodzica
	$('#'+parent).change( 
		function()
		{
			var parentValue = $('#'+parent).attr('value');
			//wypelnienie dziecka wartosciami na podstawie indexu rodzica
			$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());
				
			
			//jezeli puste zrob disbled selecta
			if( $('#'+child).children().length == 0) {
				
				$("#"+child).attr('disabled','disabled');
				$('#'+child).prepend("<option value='0'>brak</option>")
			} else {
				
				if(isSubselectOptional) $('#'+child).prepend("<option value='0'> -- Wybierz -- </option>");
				$("#"+child).attr('disabled','');
			}
			
			//zaznaczenie domyslnej opcje w select dziecko
			$('#'+child).trigger("change");
                        $('#'+child).focus();
           $("#"+child+' option[@value="0"]').attr('selected','selected');
		}
	);	
	//zaznaczenie domyslnej opcji w dziecku ale tylko podczas initu
  		$("#"+child+' option[@value="'+ childVal +'"]').attr('selected','selected');
}


/*
 * funkcja przelicza:
 *  - pole netto na brutto jezeli mode = 1
 *  - pole brutto na netto jezeli mode = 2
 * Argumentami funkcji jest pole z cena netto i pole z cena brutto. 
 * 'mode' jest zmienna globalna wiec nie musi byc przekazywane po prostu jezeli:
 *  - netto onfocus mode trzeba ustawic = 1
 *  - brutto onfocus mode trzeba ustawic = 2
 */
function translate_netto_to_brutto(nettoField, bruttoField, vatField, formName, precision)
{

	
	if ( document.getElementById(nettoField) == null ) {
		
		alert('Unable to locate ID: ' + nettoField);
		
	}
	
	if ( document.getElementById(bruttoField) == null ) {
		
		alert('Unable to locate ID: ' + bruttoField);
		
	}
	
	if ( document.getElementById(vatField) == null ) {
		
		alert('Unable to locate ID: ' + vatField);
		
	}
	
	netto 	= eval(document.getElementById(nettoField).value);
	brutto 	= eval(document.getElementById(bruttoField).value);
	vat 	= eval(document.getElementById(vatField).options[document.forms[formName].elements[vatField].selectedIndex].text);

	if ( mode == 1 ) {
		
		if ( isNaN(netto) ) {
			
			brutto = 0;
			
		} else {
		
			brutto = roundResult(netto * (1 + vat/100), 4);
				
		}
		
		document.getElementById(bruttoField).value = brutto;
		
	} else {
		
		if ( isNaN(brutto) ) {
			
			netto = 0;
			
		} else {
		
			netto = roundResult(brutto / (1 + vat/100), 4);
				
		}
		
		document.getElementById(nettoField).value = netto;
		
	}
	
}

function getAbsoluteTop(objectId)
{

	if ( document.getElementById(objectId) == null ) {
		
		alert(document.getElementById(objectId));
		
	}
	
	// Get an object top position from the upper left viewport corner

	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get top position from the parent object

	while( o.offsetParent != null )  { // Parse the parent hierarchy up to the document element

		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent

	}

	// Return top position

	return oTop
	
}

/*
 * funkcja zaokragla wartosc, za argumentu przyjmuje:
 *  - elementValue -> wartosc do zaokraglenia
 *  - precission -> dokladnosc
 *  - keepSign -> czy moze byc ujemne (1 -> tak)
 */
function roundResult(elementValue, precission, keepSign)
{
	
	var x;
	var qty = 1;
	var sign = 0;
	
	if ( isNaN(elementValue) ) {
		
		return elementValue;
		
	}
	
	if ( keepSign == null ) {
		
		keepSign = 0;
		
	}
	
	if ( elementValue[0] == "-" ) {
		
		sign = 1;
		
	}
	
	if ( precission == null ) {
		
		precision = 2;
		
	}
	
	for ( x = 0 ; x < precission ; x++ ) {
		
		qty *= 10;
		
	}
	
	// zaokraglamy 
	
	elementValue = Math.round(elementValue*qty)/qty;
	
	return elementValue;
	
}

/*
 * funkcja sprawdza czy pole o zadanym id jest puste, czy tez nie
 */
function is_empty(fieldId)
{
	
	if ( document.getElementById(fieldId) == null ) {
		
		return true;
		
	}
	
	if ( document.getElementById(fieldId).value.length < 1 ) {
		
		return true;
		
	}
	
}

function is_numeric(fieldId)
{
	
	if ( document.getElementById(fieldId) == null ) {
		
		return false;
		
	}
	
	var number_to_go;
	
	number_to_go = parseInt(document.getElementById(fieldId).value);
	
	if ( isNaN(number_to_go) ) {
		
		return false;
		
	}
	
	return true;
	
}
	

// funkcja usuwa wszystkie nie numeryczne wartosci w tym przecinki i kropki 

function remove_non_numeric_values(elementValue, keepSign)
{

	// ponizsza klauzula wyrzuca ze stringa wszystko co nie jest cyfra lub kropka/przecinkiem

	convString = elementValue.replace(/[^0-9-]*/g, '');
	
	return convString;

}

function keep_it_string(elementValue, keepSign)
{
	
	// ponizsza klauzula wyrzuca ze stringa wszystko co nie jest cyfra lub kropka/przecinkiem

	convString = elementValue.replace(/[^A-Za-ząęśćżźółń-]*/g, '');
	
	return convString;

}


function keep_it_int(elementValue, keepSign)
{
	
	var sign = 0;
	
	if ( keepSign == null ) {
		
		keepSign = 0;
		
	}
	
	if ( elementValue[0] == "-" ) {
		
		sign = 1;
		
	}

	// ponizsza klauzula wyrzuca ze stringa wszystko co nie jest cyfra
	convString = elementValue.replace(/[^0-9]*/g, '');
	
	// na koniec wyciac wszystkie zera z poczatku stringi jezeli tylko nie jest to zero
	// poprzedzajace kropke
	while ( convString[0] == '0' ) {

		convString = convString.substring(1, convString.length);

	}
	
	if ( keepSign == 1 && sign == 1 ) {
		
		convString = '-' + convString; 
		
	}
	
	return convString;
	
}



// funkcja usuwa wszystkie nie numeryczne wartosci, zmienia przecinki w kropki, 
// usuwa wszystkie kropki oprocz pierwsze, usuwa wszystkie zera z poczatku cyfry
function keep_it_float(elementValue, keepSign)
{

	var sign = 0;
	
	if ( keepSign == null ) {
		
		keepSign = 0;
		
	}
	
	if ( elementValue[0] == "-" ) {
		
		sign = 1;
		
	}

	// ponizsza klauzula wyrzuca ze stringa wszystko co nie jest cyfra lub kropka/przecinkiem

	convString = elementValue.replace(/[^0-9.,]*/g, '');
	
	// wszystkie przecinki zmieniaja sie w kropki

	convString = convString.replace(',', '.');

	// a nastepnie ucinamy wszystkie kropki oprocz pierwszej

	// nie da sie ukryc ze ponizsza kombinacja replace'ow wynika z faktu,
	// iz autor zna regexp na slowo honoru
	// w tym celu pierwsza kropke zmieniamy w literke 'u'

	convString = convString.replace(/[\.]/, 'u');

	// nastepnie wszystie inne kropki usuwamy

	convString = convString.replace('.', '');

	// na koniec literke u przywracamy do bazowej postaci

	convString = convString.replace('u', '.');

	// na koniec wyciac wszystkie zera z poczatku stringi jezeli tylko nie jest to zero
	// poprzedzajace kropke
	
	while ( ((convString[0] == '0') && (convString[1] != '.')) && ((convString[0] == '0') && (convString[1] != null)) ) {

		convString = convString.substring(1, convString.length);

	}
	
	if ( convString[0] == '.' && ( convString[1] == '' || convString[1] == null ) ) {
		
		convString = '0' + convString;
		
	}
		
	if ( keepSign == 1 && sign == 1 ) {
		
		convString = '-' + convString; 
		
	}
	
	return convString;

}

function checkRecl()
{
	
	if ( document.forms['Main'].elements['nazwa_sprzetu'].value.length < 3 ) {
	
		alert('Musisz podac nazwe reklamowanego towaru.');
		
		document.forms['Main'].elements['nazwa_sprzetu'].focus();
		
		return false;
		
	}
	
	if ( document.forms['Main'].elements['numer_seryjny'].value.length < 2 ) {
		
		alert('Musisz podac numer seryjny reklamowanego towaru.');
		
		document.forms['Main'].elements['numer_seryjny'].focus();
	
		return false;
		
	}
	
	return true;
	
}

function show_me_warning(objectId)
{
	
	if ( timeoutId != null ) {
		
		clearTimeout(timeoutId);
		
	}
	
	if ( document.getElementById(objectId) == null ) {
		
		alert('Obiekt nie istnieje: ' + objectId);
		
		return false; 
		
	}
	
	left = getAbsoluteLeft(objectId);
	top = getAbsoluteTop(objectId);
	
	document.getElementById('warning').style.left = (left - 62) + 'px';
	document.getElementById('warning').style.top = (top - 52) + 'px';
	
	document.getElementById('warning').style.display = '';
	
}

function close_my_warning()
{
	
	document.getElementById('warning').style.display = 'none';
	
}

function reset(variable_field, variant) 
{

	document.forms[''+variant+''].elements[''+variable_field+''].checked = 0;

}

function mark(variable_field, marker)
{
	
	if ( document.getElementById(variable_field) == null ) {
		
		alert('Unable to find ID: ' + variable_field);
		
		return false;
		
	}
	
	if ( document.getElementById(variable_field).type == 'checkbox' ) {

		document.getElementById(variable_field).checked = marker;

	}
		
}

function touch(variable_field) 
{

	if ( document.getElementById(variable_field) == null ) {
		
		//alert('Unable to find ID: ' + variable_field);
		
		return false;
		
	}
	
	if ( document.getElementById(variable_field).checked == 1 ) {

		document.getElementById(variable_field).checked = 0;

	} else {

		document.getElementById(variable_field).checked = 1;

	}

}

function touch_radio(variable_field, field, formName) 
{
	
	if ( document.getElementById(variable_field) == null ) {
		
		alert('Unable to find ID: ' + variable_field);
		
		return false;
		
	}
	
	var length = document.forms[formName].elements[variable_field].length;
	
	var i;
	
	for ( i = 0 ; i < length ; i++ ) {
		
		if ( document.forms[formName].elements[variable_field][i].value == field ) {
			
			document.forms[formName].elements[variable_field][i].checked = 1;
			
		}
		
	}
	
}

////////////////////////////
//Menu kategorii
///////////////////////////

var persisteduls=new Object()
var ddtreemenu=new Object()

//////////No need to edit beyond here///////////////////////////

ddtreemenu.createTree=function(treeid, enablepersist, persistdays){
var ultags=document.getElementById(treeid).getElementsByTagName("ul")
if (typeof persisteduls[treeid]=="undefined")
persisteduls[treeid]=(enablepersist==true && ddtreemenu.getCookie(treeid)!="")? ddtreemenu.getCookie(treeid).split(",") : ""
for (var i=0; i<ultags.length; i++)
ddtreemenu.buildSubTree(treeid, ultags[i], i)
if (enablepersist==true){ //if enable persist feature
var durationdays=(typeof persistdays=="undefined")? 1 : parseInt(persistdays)
ddtreemenu.dotask(window, function(){ddtreemenu.rememberstate(treeid, durationdays)}, "unload") //save opened UL indexes on body unload
}
}

ddtreemenu.buildSubTree=function(treeid, ulelement, index){
ulelement.parentNode.className="submenu"
if (typeof persisteduls[treeid]=="object"){ //if cookie exists (persisteduls[treeid] is an array versus "" string)
if (ddtreemenu.searcharray(persisteduls[treeid], index)){
ulelement.setAttribute("rel", "open")
ulelement.style.display="block"
ulelement.parentNode.style.backgroundImage="url("+ddtreemenu.openfolder+")"
}
else
ulelement.setAttribute("rel", "closed")
} //end cookie persist code
else if (ulelement.getAttribute("rel")==null || ulelement.getAttribute("rel")==false) //if no cookie and UL has NO rel attribute explicted added by user
ulelement.setAttribute("rel", "closed")
else if (ulelement.getAttribute("rel")=="open") //else if no cookie and this UL has an explicit rel value of "open"
ddtreemenu.expandSubTree(treeid, ulelement) //expand this UL plus all parent ULs (so the most inner UL is revealed!)
ulelement.parentNode.onclick=function(e){
var submenu=this.getElementsByTagName("ul")[0]
if (submenu.getAttribute("rel")=="closed"){
submenu.style.display="block"
submenu.setAttribute("rel", "open")
ulelement.parentNode.style.backgroundImage="url("+ddtreemenu.openfolder+")"
}
else if (submenu.getAttribute("rel")=="open"){
submenu.style.display="none"
submenu.setAttribute("rel", "closed")
ulelement.parentNode.style.backgroundImage="url("+ddtreemenu.closefolder+")"
}
ddtreemenu.preventpropagate(e)
}
ulelement.onclick=function(e){
ddtreemenu.preventpropagate(e)
}
}

ddtreemenu.expandSubTree=function(treeid, ulelement){ //expand a UL element and any of its parent ULs
var rootnode=document.getElementById(treeid)
var currentnode=ulelement
currentnode.style.display="block"
currentnode.parentNode.style.backgroundImage="url("+ddtreemenu.openfolder+")"
while (currentnode!=rootnode){
if (currentnode.tagName=="UL"){ //if parent node is a UL, expand it too
currentnode.style.display="block"
currentnode.setAttribute("rel", "open") //indicate it's open
currentnode.parentNode.style.backgroundImage="url("+ddtreemenu.openfolder+")"
}
currentnode=currentnode.parentNode
}
}

ddtreemenu.flatten=function(treeid, action){ //expand or contract all UL elements
var ultags=document.getElementById(treeid).getElementsByTagName("ul")
for (var i=0; i<ultags.length; i++){
ultags[i].style.display=(action=="expand")? "block" : "none"
var relvalue=(action=="expand")? "open" : "closed"
ultags[i].setAttribute("rel", relvalue)
ultags[i].parentNode.style.backgroundImage=(action=="expand")? "url("+ddtreemenu.openfolder+")" : "url("+ddtreemenu.closefolder+")"
}
}

ddtreemenu.rememberstate=function(treeid, durationdays){ //store index of opened ULs relative to other ULs in Tree into cookie
var ultags=document.getElementById(treeid).getElementsByTagName("ul")
var openuls=new Array()
for (var i=0; i<ultags.length; i++){
if (ultags[i].getAttribute("rel")=="open")
openuls[openuls.length]=i //save the index of the opened UL (relative to the entire list of ULs) as an array element
}
if (openuls.length==0) //if there are no opened ULs to save/persist
openuls[0]="none open" //set array value to string to simply indicate all ULs should persist with state being closed
ddtreemenu.setCookie(treeid, openuls.join(","), durationdays) //populate cookie with value treeid=1,2,3 etc (where 1,2... are the indexes of the opened ULs)
}

////A few utility functions below//////////////////////

ddtreemenu.getCookie=function(Name){ //get cookie value
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return ""
}

ddtreemenu.setCookie=function(name, value, days){ //set cookei value
var expireDate = new Date()
//set "expstring" to either future or past date, to set or delete cookie, respectively
var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days))
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}

ddtreemenu.searcharray=function(thearray, value){ //searches an array for the entered value. If found, delete value from array
var isfound=false
for (var i=0; i<thearray.length; i++){
if (thearray[i]==value){
isfound=true
thearray.shift() //delete this element from array for efficiency sake
break
}
}
return isfound
}

ddtreemenu.preventpropagate=function(e){ //prevent action from bubbling upwards
if (typeof e!="undefined")
e.stopPropagation()
else
event.cancelBubble=true
}

ddtreemenu.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent(tasktype, functionref)
}


//tooltip

function hide_layer()
{

	if ( TimeoutID != null ) {
		
		clearTimeout(TimeoutID);
		setTimeout('go_and_hide()', 200);	
		
	} else {
	
		setTimeout('go_and_hide()', 200);
	
	}

}

function toggle_visibility(elementId, clean)
{
	
	if ( clean == '' ) {
		
		clean = 0;
		
	}
	
	if ( document.getElementById(elementId).style.display == 'none' ) {
		
		unhide(elementId);
		
	} else {
		
		hide(elementId, clean);
		
	}
	
}

function go_and_hide()
{

	var pre = document.getElementById('loading');

	pre.style.display='none';
	pre.innerHTML = "&nbsp;";
	
}

function check_if_good_to_go(formName)
{

	if ( document.forms[formName].elements['block'].value == 0 ) {
		
		return true;
	
	} else {
		
		document.forms[formName].elements['block'].value = 0;

		return false;
		
	}
	
}


function hide(elementId, clean)
{
	
	if ( clean == null ) {
		
		clean = 0;
		
	}
	
	document.getElementById(elementId).style.display = 'none';
	
	if ( clean ) {

		document.getElementById(elementId).innerHTML = '';
		
	}
	
}

function unhide(elementId)
{
	
	if ( TimeoutID != null ) {
		
		clearTimeout(TimeoutID);
		
	}
	
	document.getElementById(elementId).style.display = '';
	
}

function hide_autofield_sec(variant, fieldName, clean)
{
	
	if ( clean == 'null' ) {
		
		clean = 0;
		
	}
	
	if (variant == 1) {
	
		hide(fieldName, clean);
		
	} else {
	
		TimeoutID = setTimeout('hide_autofield_sec(1, \''+fieldName+'\', '+clean+')', 250);
		
	}
	
}

function detectBrowser()
{
	
	if ( !document.all ) {
		
		return 1; // mozilla type
		
	} else {
		
		var version = /MSIE \d+.\d+/
		
		return 0; // ie type
	
	}

}


/*
 * ustawiamy polozenie tooltipa, jezeli 'parentId' jest rozny od -1 to ustawiamy tooltipa
 * wzgledem elementu 'parentId', w przeciwnym przypadku centrum ekranu skorygowane
 * o korekte top i left
 */
function set_tooltip_position(tooltipNameId, parentId, korektaTop, korektaLeft, toolTipWidth)
{
		
	var x, y;
	
	if ( parentId != -1 ) {

		x = getAbsoluteLeft(parentId);
		y = getAbsoluteTop(parentId);
		
	} else {
		
		if ( detectBrowser() ) {

			y = window.pageYOffset;
			x = window.pageXOffset;
			
		} else {
			
			y = document['documentElement'].scrollTop;
			x = document['documentElement'].scrollLeft;

		}
		
	}
	
	document.getElementById(tooltipNameId).style.left = x + korektaLeft + 'px';
	document.getElementById(tooltipNameId).style.top = y + korektaTop + 'px';
	
	document.getElementById(tooltipNameId).style.width = toolTipWidth + 'px';
		
}

/*
 * publiczna funkcja, ktora wyswietla komunikat o tresci 'message' przez 'time' sekund,
 * tooltip jest pozycjonowany wzgledem 'parentId', pozycja jest przesunieta wzgledem 
 * osi x oraz osi y gdzie lewy gorny rog to wspolrzedna 0,0 a dolny prawy rog to np. 100, 100
 *
 */
function show_tooltip(parentId, message, time, x_axis, y_axis, width)
{

	if ( parentId == null ) {
		
		return false;
		
	}
	
	if ( time == null ) {
		
		time = 1;
		
	}
	
	if ( width == null ) {
		
		width = 300;
		
	}
	
	if ( x_axis == null ) {
		
		x_axis = 0;
		
	}
	
	if ( y_axis == null ) {
		
		y_axis = 0;
		
	}
	
	set_tooltip_position('tooltip', parentId, y_axis, x_axis, width); 
	document.getElementById('tooltip').innerHTML = '' + message + '';
	unhide('tooltip');
	TimeoutID = setTimeout('hide(\'tooltip\')', time * 1000);
	
}

/*
 * funkcja odpala ajaxowe wyslanie danego forma (celem jest standardowe action="")
 * efekt pracy tej funkcji ustawia sie wzgledem wlasnie ogladanego ekranu (nie ma ryzyka,
 * ze uzytkownik jest przeskrolowany na dol i go nie zobaczy)
 */
function sendFormToScript(formName, width, axis_x, axis_y, divName)
{
	
	if ( width == null ) {
		
		width = 860;
		
	}
	
	if ( axis_y == null ) {
		
		axis_y = 0;
		
	}
	
	if ( axis_x == null ) {
		
		axis_x = 0;
		
	}
	
	if ( divName == null ) {
		
		divName = 'window';
		
	}
	
	set_tooltip_position(divName, -1, axis_y, axis_x, width);
	
	var content = document.getElementById(divName+'Body');
	var pre = document.getElementById(divName);
	
	advAJAX.assign(document.getElementById(formName), {

		onError: function(obj) { 
			
			pre.style.display = '';			
			content.innerHTML = '<font color="red"><strong><center>' +  obj.status + '</center></strong></font>';

		},

		onFinalization: function(obj) {
			
			content.innerHTML = obj.responseText;
			
		},
		
		onLoading: function() {

			pre.style.display = '';			
			content.innerHTML = '<font color="red"><strong><center>Loading</center></strong></font>';
			
		}
		
	});
	
}

// f zaznaczajaca/odznaczajaca wszystkie checkboxy
function check_all_fnc(hook)
{
	var formHook = document.check_form;
	if (hook.checked == true)
	{
		for (var a=0; a<formHook.length; a++)
		if (formHook.elements[a].type == "checkbox")
		{
			formHook.elements[a].checked = true;
		}
	}
	else
	{
		for (var a=0; a<formHook.length; a++)
		if (formHook.elements[a].type == "checkbox")
		{
			formHook.elements[a].checked = false;
		}
	}
} 

function show_me_standard_window(scriptName, top, left, divName, width, parentId, variables)
{

	if ( top == null ) {
		
		top = 0;
		
	}
	
	if ( left == null ) {
		
		left = 0;
		
	}
	
	if ( width == null ) {
		
		width = 650;
		
	}
	
	if ( divName == null ) {
		
		divName = 'window';
		
	} 
	
	if ( parentId == null) {
		
		parentId = -1;
		
	}
	
	var content = document.getElementById(divName+'Body');
	var pre = document.getElementById(divName);
	
	set_tooltip_position(divName, parentId, 80 + top, 30 + left, width);
	
	advAJAX.post({ url: '' + scriptName + '',
	
		parameters : {
			"variables" : variables
		},
	
		onError : function(obj) { 
			
			pre.style.display = '';			
			content.innerHTML = '<font color="red"><strong><center>' +  obj.status + '</center></strong></font>';

		},
		
		onLoading : function(obj) {

			pre.style.display = '';			
			content.innerHTML = '<font color="red"><strong><center>Loading</center></strong></font>';
			
		},
		
		onFinalization: function(obj) {
			
			content.innerHTML = obj.responseText;
			
		}
		
	});
	
}