//fix for grey border around activex
function desact(){
	n=navigator.userAgent;
	w=n.indexOf("MSIE");
	if((w>0)&&(parseInt(n.charAt(w+5))>5)){
		T=["object","embed","applet"];
		for(j=0;j<2;j++){
			E=document.getElementsByTagName(T[j]);
				for(i=0;i<E.length;i++){
					P=E[i].parentNode;
					H=P.innerHTML;
					P.removeChild(E[i]);
					P.innerHTML=H;
				}
		}
	}
}

function previewLocal(fileName, fieldName) {

var url = 'file:///' + fileName;
//if (document.layers && location.protocol.toLowerCase() != 'file:' && navigator.javaEnabled()) {
	//alert('ok');
	//netscape.security.PrivilegeManager.enablePrivilege('UniversalFileRead');
	document[fieldName].src= url;
//}
}


function checkPrints(value) {
	if (isNaN(value) || value <1) {
		value = 1;
	}
	return value;
}

function clickPlus(value) {
	value++;
	return value;
	//alert(value);
}

function clickMinus(value) {
	if (value>1) {
		value--;
	}
	return value;
	//alert(value);
}

function submitCalc() {
	document.order.action_calc.click();
}


function submitOgone(postUrl) {
var theAction = postUrl;
//alert (theAction);
document.order.action = theAction;
document.order.submit();
}

function orderCalc(){
//alert("flag refr en nu...");
document.order.frmAction.value="step4";
document.order.action_calc.click();
}

 var milisec=0 ;
 var seconds=10 ;
 var clicked = false;


function displayFinish()
{


	 document.f_confirm.counter.value='10' ;


	 if (milisec == 0 && seconds == 0 && clicked == false) {
		//document.order.action.value = "confirm";
		document.f_confirm.button.click();
		clicked = true;
	 }
	 if (milisec<=0){
		milisec=9 ;
		seconds-=1 ;
	 }
	 if (seconds<=-1){
		milisec=0 ;
		seconds+=1 ;
	 }
	 else
		milisec-=1 ;
		document.f_confirm.counter.value=seconds ;
		setTimeout("displayFinish()",100) ;

}

function displayConfirm()
{

//

 if (milisec == 0 && seconds == 0 && clicked == false) {
	//document.order.action.value = "confirm";
	document.order.action_confirm.click();
	clicked = true;
 }
 if (milisec<=0){
	milisec=9 ;
	seconds-=1 ;
 }
 if (seconds<=-1){
	milisec=0 ;
	seconds+=1 ;
 }
 else{
	milisec-=1 ;
	document.order.counter.value=seconds ;
	setTimeout("displayConfirm()",100) ;
}


}




var popUpPix=0;
function popUpWindow(URLStr, left, top, width, height) {

	if(popUpPix){
		if(!popUpPix.closed) popUpPix.close();
	}
	popUpPix = open(URLStr, 'popUpPix', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function progress() {
	w = document.body.clientWidth;
	h = document.body.clientHeight;
	document.post_files.but_verd.disabled=true;
	document.post_files.submit();
	popUpWindow('scripts/popup_progress.php', w/2, h/2, 250, 30);
}

/*
function closePopUp(){
try {
	popUpPix.close();
}

catch(err){
}

}
function calculateTotal(objAdd){

    var toAdd = parseFloat(objAdd.value);
    var total = parseFloat(document.getElementById('total').innerHTML);



    if (objAdd.checked){
        document.getElementById('total').innerHTML = Math.round((total += toAdd)*100)/100;
        try {
            document.getElementById(objAdd.name).style.display= '';
        }catch (err){  }

    }else{
        document.getElementById('total').innerHTML = Math.round((total -= toAdd)*100)/100;
        try {
            document.getElementById(objAdd.name).style.display= 'none';
        }catch (err){  }
    }


}
*/

function calculateTotal(pic, id){
	var objPic = pic;
    var objAdd = document.getElementById(id);
    var toAdd =  parseFloat(document.getElementById('valor_'+id).value);
    var total = parseFloat(document.getElementById('total').innerHTML);

    if (objAdd.value == '1')
    {
        objAdd.value = '0';
        document.getElementById('total').innerHTML = Math.round((total -= toAdd)*100)/100;
        document.getElementById(objAdd.name).style.display= 'none';
        objPic.className = 'checkbox';
    }
    else
    {
        objAdd.value = '1';
        document.getElementById('total').innerHTML = Math.round((total += toAdd)*100)/100;
        document.getElementById(objAdd.name).style.display= '';
        objPic.className = 'checkbox_check';
    }

}


function closePopUp (){
	try{
		window.open('./cgi-bin/uber_uploader_progress.pl?close_pop=1','uploadWin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=295,height=160,left=350,top=300');
	}
	catch(err){
		//alert (err);
	}
}



function convertToPixel(objCm){
		if (objCm.value != ''){
			cmValue = objCm.value.replace(",", ".");
			if (!isNaN(parseFloat(cmValue))){
				pxValue = parseFloat(cmValue) * 118.1333;
				document.getElementById(objCm.name.substring(0, objCm.name.length-3)).value = parseInt(pxValue);
			}
		}
}


function createArrGroup(){

		var allGroups = document.getElementsByName('chkGroup');
		var arrGroups = 0;
		var rValue = false

		document.getElementById('errorGroup').style.display = 'none';

		for (var i = 0; i<allGroups.length; i++ ){
				if (allGroups[i].checked){
					arrGroups += ','+allGroups[i].value;
					rValue = true;
				}
		}



		if (rValue){
			document.getElementById('chkArrGroup').value = arrGroups;
		}else{
			document.getElementById('errorGroup').style.display = '';
		}
		return rValue;


}



//Bgcolor effect
function applyColor(obj){
	obj.style.background = "#AACFFF";
}

function restoreColor(obj){
	obj.style.background = "#FFFFFF";
}


//Show / Hide Groups formats
function showFormat(groupID){

	var statusGroup = document.getElementById('tr_'+groupID).style.display;

	if (statusGroup == 'none'){
		document.getElementById('tr_'+groupID).style.display = '';
		document.getElementById('img_'+groupID).src = 'images/groupMin.gif';

	}else{
		document.getElementById('tr_'+groupID).style.display = 'none';
		document.getElementById('img_'+groupID).src = 'images/groupPlus.gif';

	}
}

//checks if enter has been pressed or not
function submitViaEnter(evt){ //e is event object passed from function invocation
	evt = (evt) ? evt : event;
    var target = (evt.target) ? evt.target : evt.srcElement;
    var form = target.form;
    var charCode = (evt.charCode) ? evt.charCode :
        ((evt.which) ? evt.which : evt.keyCode);
    if (charCode == 13) {
        //if (validateForm(form)) {
	        //alert("ok enteeeer");
            form.submit();
            return false;
        //}
    }
    return true;

}

