var pathname = (window.location.pathname);var loc = pathname.substring(0,(pathname.lastIndexOf('.n')+4));//control odkazy / oznacit vsechny - pohled dle druhufunction doSelect( frm, nam, sel ){  for (var i = 0; i < frm.elements.length; i++) {    if (frm.elements[i].type == "checkbox") {      if (frm.elements[i].name == nam) {		frm.elements[i].checked = sel;      }    }  }  return false;}//control odkazy / otocit vybre- pohled dle druhu, vsechnyfunction doInvertSelection( frm, nam ){  for (var i = 0; i < frm.elements.length; i++) {    if (frm.elements[i].type == "checkbox") {      if (frm.elements[i].name == nam) {		frm.elements[i].checked = (frm.elements[i].checked) ? false:true;      }    }  }  return false;}//after click on Dotaz na cenu, generates new cookie with processeddocs valuefunction topUP(entry) {	var myValue = entry;	setCookie("StrojeZemanPrice",myValue, 0.001, document.forms[0].dtb.value);}//funkce vracejici UNIDy vybranych strojufunction getMachineIDs(frm, nam, from) {	myString='';	if (from=='1') { //je-li volano z pohledu, kde je policko proccesdocs		for (var i = 0; i < frm.elements.length; i++) {	    	if (frm.elements[i].type == "checkbox") { 		     if (frm.elements[i].name == nam) {      			if (frm.elements[i].checked) {					myString+= frm.elements[i].value+',*,';				}      		}    		}  	}	   } else { //je-li volano z formulare, kde musi byt pole MachineTitle a UNID     myObject = frm.MachineTitle;  	myString=myObject.value+'***'+frm.unid.value + ',*,';  }  return myString;}//control funkce, ktera vyvola dotaz o cenufunction doProcess( frm, nam, from ) {	myString='';     //deleteCookie("StrojeZemanPrice",frm.dtb.value);	if (from=='1') { //znamena z pohledu	myString = getMachineIDs(frm, nam,'1');	} else getMachineIDs(frm, nam,'2');	if (myString!='') topUP(myString);	window.location.href=frm.dtb.value+"priceinfo?OpenForm&lan="+frm.Language.value;}//pomocny prevod na Date()function getexpirydate( nodays){var UTCstring;Today = new Date();nomilli=Date.parse(Today);Today.setTime(nomilli+nodays*24*60*60*1000);UTCstring = Today.toUTCString();return UTCstring;}/** * Sets a Cookie with the given name and value. * * name       Name of the cookie * value      Value of the cookie * [expires]  Expiration date of the cookie (default: end of current session) * [path]     Path where the cookie is valid (default: path of calling document) * [domain]   Domain where the cookie is valid *              (default: domain of calling document) * [secure]   Boolean value indicating if the cookie transmission requires a *              secure transmission */function setCookie(name, value, expires, path){    document.cookie= name + "=" + escape(value) +        ((expires) ? "; expires=" + getexpirydate(expires) : "") +        ((path) ? "; path=" + path : "") }/** * Gets the value of the specified cookie. * * name  Name of the desired cookie. * * Returns a string containing value of specified cookie, *   or null if cookie does not exist. */function getCookie(name){    var dc = document.cookie;    var prefix = name + "=";    var begin = dc.indexOf("; " + prefix);    if (begin == -1)    {        begin = dc.indexOf(prefix);        if (begin != 0) return null;    }    else    {        begin += 2;    }    var end = document.cookie.indexOf(";", begin);    if (end == -1)    {        end = dc.length;    }    return unescape(dc.substring(begin + prefix.length, end-7));}/** * Deletes the specified cookie. * * name      name of the cookie * [path]    path of the cookie (must be same as path used to create cookie) * [domain]  domain of the cookie (must be same as domain used to create cookie) */function deleteCookie(name, path){    if (getCookie(name))    {        document.cookie = name + "=" +             ((path) ? "; path=" + path : "") +                        "; expires=Thu, 01-Jan-70 00:00:01 GMT";    }}//odstrani stroj umisteny na formularifunction doRemoveLink(idx){  message=(document.forms[0].Language.value=='EN') ? 'Are you sure you want to unlist this machine?' : 'Chcete opravdu stroj odebrat ze seznamu?' if (!confirm(message)) return;  var currFiles=document.forms[0].MachineList.value.split('; '); var currFilesTotal=document.forms[0].MachineList.value.split('; ').length; //removes file currFiles[idx]="";  document.forms[0].MachineList.value = currFiles.join('; ');	 //remove div container div=document.getElementById("related-article-"+idx); div.parentNode.removeChild(div);  tempstring = currFiles.join('; '); //v pripade nefunkcnosti omezeni 30znaku, odpovidajici 15ti smazanym strojum, se musi vymyslet lespi fce, ktera uz nebude delat join //s pomoci '; ' if (tempstring.length <=30) {     document.getElementById("priceinfonomachines").style.visibility="visible"; }}//not implemented yetfunction doChooseLink(){ window.open("/" + loc + "/vwLinkPick?OpenView","new_win","width=450,height=350,resizable=yes,scrollbars=yes");}//prida stroj na formularfunction doAddLink(title, unid){		var currTotal=document.forms[0].MachineList.value.split(';').length;		document.forms[0].MachineList.value+='; '+ unid;		var txt = document.createTextNode(" " + title);	var div = document.createElement('div');	var rem = document.createElement('a');	var img = document.createElement('img');	var lnk = document.createElement('a');		lnk.setAttribute('href', document.forms[0].stockdtb.value +'0/' + unid + '?OpenDocument&lan='+document.forms[0].Language.value);	lnk.setAttribute('title', title);	//lnk.setAttribute('target', '_blank');	lnk.appendChild(txt);		img.setAttribute('src', 'images/icons/delete.gif');	img.setAttribute('border', '0');		rem.setAttribute('href','JavaScript:void(doRemoveLink('+currTotal+'));');	rem.appendChild(img);	div.setAttribute('id','related-article-'+currTotal);	div.setAttribute('class','related-article');			div.appendChild(rem);	div.appendChild(lnk);		var container = document.getElementById('related-articles');	container.appendChild(div);}//Precte cookie a zapise do DIVu formular Zadost o cenufunction generateMachines() {	var myString = getCookie("StrojeZemanPrice");	//alert(myString);	if (myString!=null) {	namesList = myString.split(',*,');	for ( i = 0; i < namesList.length; i++) {		doAddLink(namesList[i].split('***')[0], namesList[i].split('***')[1]);		document.getElementById("priceinfonomachines").style.visibility="hidden";	}		namesList='';}}//search funkcefunction returnFalse(s) {doSearch(s);return false;}function doSearch(StringToSearch) {language = document.forms[0].Language.value;if(StringToSearch=='') {	if (language=="EN") {      	alert("Please make sure you have entered string to search");      	} else {alert("Ujist\u011Bte se, \u017Ee jste zadali n\u011Bjak\u00FD \u0159et\u011Bzec k hled\u00E1n\u00ED.");}   	document.forms[0].squery.focus();} else {	window.location.href =(document.forms[0].stockdtb.value + 'search'+language+'?searchview&query=' + escape( StringToSearch ) + '&start=1&count=10&lan='+language);}}/*	ValidEmail - true for valid email, false for invalid*/function ValidEmail(EmailAddr) {	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;		var SpecChar="!#$%^&*()'+{}[]\|:;?/><,~`" + "\"";	var frmValue = new String(EmailAddr.value);	var len = frmValue.length;		if( len < 1 ) { return false; }	for (var i=0;i<len;i++)	{				temp=frmValue.substring(i,i+1)				if (SpecChar.indexOf(temp)!=-1)		 		{					EmailAddr.focus();					if (document.forms[0].Language.value=="EN") {      	alert("Please make sure you have entered valid e-mail address");      	} else {alert("Pros\u00EDm, ujist\u011Bte se, \u017Ee zadan\u00E1 e-mailov\u00E1 adresa je spr\u00E1vn\u00E1.");}	return false;				}	}			if(!reg1.test(frmValue) && reg2.test(frmValue)) 	{ 		return true;	}	EmailAddr.focus();	if (document.forms[0].Language.value=="EN") {      	alert("Please make sure you have entered valid e-mail address");      	} else {alert("Pros\u00EDm, ujist\u011Bte se, \u017Ee zadan\u00E1 e-mailov\u00E1 adresa je spr\u00E1vn\u00E1.");}	return false;}function atLeastOne(field) {var que=false;if (field[0].checked == true) {que = true; return que; }return que;}//submit formularufunction isEmpty(field) {var str=field.value;if (str!="") {return true;}message = (document.forms[0].Language.value=='EN') ? 'Please, fill in this field.' : 'Toto pole je nutn\u00E9 vyplnit'; alert(message);field.focus();return false;}var checkflag = "false";function check(field) {if (checkflag == "false") {for (i = 0; i < field.length; i++) {field[i].checked = true;}checkflag = "true";}else {for (i = 0; i < field.length; i++) {field[i].checked = false; }checkflag = "false"; }}function doSubmit(f,whichform) {switch (whichform)  {    case 'priceinfo': {     							if (f.MachineList.value.length <=30) { 								switch (f.Language.value)								{								case 'EN': message="Please add a machine using \"add machine' link\"";								case 'DE': message="Die Liste ist leer, ben\u00FCtzen Sie \"Maschine zugeben\" Verweis";								default : message="Seznam stroj\u016F je pr\u00E1zdn\u00FD, pou\u017Eijte odkaz \"P\u0159idat stroj\"";								}								alert(message);								return false;							 }    														if(isEmpty(f.CompanyName) && isEmpty(f.PhoneNumber) && ValidEmail(f.InternetAddress)) {							return true; } 							else {return false};							 break;						   }    case 'customeroffer': { 							if(isEmpty(f.CompanyName) && isEmpty(f.PhoneNumber) && ValidEmail(f.InternetAddress)) {							return true; } 							else {return false};							 break;						   }	   case 'emailregistration': { 							if(atLeastOne(f.cNewsletter) && ValidEmail(f.InternetAddress)) {							return true; } 							else {return false};							 break;						   }   case 'emailunsubscribe': { 							if(ValidEmail(f.InternetAddress)) {							return true; } 							else {return false};							 break;						   }    default: {alert('internal error, please use another form'); return false;}      }}function submitEmail(f) {//zkontrolovat, zda je email vyplnen a je vybrana alespon jedna kategorieif (ValidEmail(f.contEmail)) {	window.location.href =f.dtb.value+'registration?OpenForm&email=' + escape( f.contEmail.value ) +'&lan='+f.Language.value; }}
