<!--
//################################################
//Functions for CAD - MINMAX Functionality
//################################################

function pause(ms)
{
    if(!ms) return;
    var x = (new Date()).getTime();
    while(ms > (new Date()).getTime() - x){;}
}


//################################################
// set Attributes isolated CAD
function SSFormValues_setAttr(variablen)	
{
	document.goCAD.variablen.value=variablen;
}

//################################################
// set FormValues isolated CAD
function SSFormValues_iso(model_id,model_drawing,model_src)	
{
	var strPath = window.location.pathname;
	FormValues_general();
	document.goCAD.subtab.value='';
	document.goCAD.cadstring.value='';
	document.goCAD.artID.value='';
	document.goCAD.rule.value='';
	document.goCAD.SCorCAD.value='CAD';
	document.goCAD.stvModel.value=model_src;
	document.goCAD.stvID.value=model_id;
	document.goCAD.prodinfopic.value=model_drawing;
	//ShowDebugWindow();
	SSFormValues_submit();
}
// submit FormValues isolated CAD
function SSFormValues_submit()	
{
	document.goCAD.submit();
}

//################################################
// set and submit FormValues integrated CAD
function SSFormValues_int(translated_cadstring,cadvariants,articleID)	
{
	FormValues_general();
	document.goCAD.subtab.value=cadvariants;
	document.goCAD.cadstring.value=translated_cadstring;
	document.goCAD.artID.value=articleID;
	document.goCAD.SCorCAD.value='CAD';
	//ShowDebugWindow();
	document.goCAD.submit();
}

//################################################
// set and submit FormValues ShoppingCart
function SSFormValues_sc(translated_cadstring,cadvariants,articleID,translated_scstring)	
{
	//onClick="SSFormValues_sc('','','4774','123**Produktname************'+location.href+'****')
	FormValues_general();
	document.goCAD.subtab.value=cadvariants;
	document.goCAD.cadstring.value=translated_cadstring;
	document.goCAD.artID.value=articleID;
	document.goCAD.SCorCAD.value='SC';
	document.goCAD.shoppingcart.value=translated_scstring;
	//ShowDebugWindow();
	document.goCAD.submit();
}				

//################################################
//set general FormValues 
function FormValues_general()	
{
	strPath = window.location.pathname;
	strPath = strPath.replace(/\\/g,"/");
	if (strPath.search(/.:/) == 1)
	{
		strPath = strPath.substr(1);						
	}
	var KatPath = strPath.split("/");
	document.goCAD.catalogPath.value=KatPath[KatPath.length-2];
	document.goCAD.backto.value=KatPath[KatPath.length-1];
	document.goCAD.used_charset.value=document.charset;
}

//################################################
//show Debug-Window - CAD hidden field entries of form for PHP 
var newWindow;
function ShowDebugWindow()
	{
	if (newWindow)
	newWindow.close();
	newWindow = window.open('about:blank','debugwdw','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=800,height=500');
	newWindow.document.write("<html><head><title>Debug</title>\n");
	newWindow.document.write("</head>\n<body style='background-color:white;font-family:Arial, Helvetica, Times Roman'>\n");
	var ampersand_char = 0;
	newWindow.document.write("<table style='font-size:10pt;border:1px solid black;width:100%'>\n");
	newWindow.document.write("<tr><td colspan='2' style='background-color:#CCCCCC'><b>Debug of CC Stylesheet 3.1.x - CAD</b></td></tr>\n");
	for (i=0; i<document.goCAD.childNodes.length;i++)
		{
		newWindow.document.write("<tr><td style='background-color:#DDDDDD'>" + document.goCAD.childNodes[i].getAttribute('name') + "</td><td style='background-color:#EDEDED'>" + document.goCAD.childNodes[i].getAttribute('value') + "</td> </tr>\n");
		}
	newWindow.document.write("</table>\n");
	newWindow.document.write("\n<CENTER><FORM><INPUT TYPE='BUTTON' class='button' VALUE='Close' onClick='window.close()'></FORM></CENTER>");
	newWindow.document.write("</body></html>");
	newWindow.focus();
	}

//################################################
//checkValues of Min-Max Fields
function CheckMinMax(id,feld,min,max,step,default_value)
{
//alert('id: ' + id + ' - - feld: '   + feld + ' - - min: '  + min + ' - - max: '  + max + ' - - step: '  + step + ' - - default_value: ' + default_value);
if(isNaN(feld) == true)
	{
	myAlert(minmax_novalue);
	document.getElementById(id).value = default_value;
	return false;
	}
 else
	{
	feld = Math.round(feld*100)/100;
	min = Math.round(min*100)/100;
	max = Math.round(max*100)/100;
	step = Math.round(step*100)/100;
	default_value = Math.round(default_value*100)/100;				
	//alert('id: ' + id + ' - - feld: '   + feld + ' - - min: '  + min + ' - - max: '  + max + ' - - step: '  + step + ' - - default_value: ' + default_value);						
	}
 if (feld == 0)
	{
	myAlert(minmax_zero);
	document.getElementById(id).value = default_value;
	return false;
	}

 if (feld > max)
	{
	myAlert(minmax_max + " " +  max);
	document.getElementById(id).value = default_value;
	return false;
	}
 if (feld < min)
	{
	myAlert(minmax_min + " " + min);
	document.getElementById(id).value = default_value;
	return false;
	}
 if (Math.round((feld - min)*100) % Math.round(step * 100) != 0)
	{		
	v2 = Math.round((min+step)*100)/100;
	v3 = Math.round((v2+step)*100)/100;
	myAlert(minmax_step + " " + min + " - " + v2 + " - " + v3 + " ...");
	document.getElementById(id).value = default_value;
	return false;
	}
 else
	{
	document.getElementById(id).value = feld;
	}
return true;
}
	
	
function neuerbrowser(theURL,winName,targetName,features)
{
	eval(winName+"=window.open('"+theURL+"','"+targetName+"','"+features+"')");
	if (winName=='CADsettings'){
		CADsettings.focus();
	};
}

function changeView(view)
{
	ValuesChanged("", "");
	location.href="viewChange.php?view="+view+"&pre=CAD&values="+sValue;
}

